alexgreensh/repo-forensics / skills/repo-forensics
repo-forensics
FlaggedSecurity forensics for git repos, AI skills, and MCP servers. Audits dependencies, detects prompt injection, credential theft, runtime dynamism, manifest drift, known CVEs, CISA KEV (actively exploited) vulns, and 2026 attack patterns. Not for fixing vulnerabilities or pentesting.
tests/test_provenance_offline.py
View on GitHub"""--offline must keep scan_provenance from calling npm / gh (both contact
their registries). Fake npm and gh binaries log every call; under --offline
the log must stay empty, both for the scanner alone and through
run_forensics.sh."""
import os
import stat
import subprocess
import sys
import pytest
from shell_compat import sh_argv
pytestmark = pytest.mark.skipif(
sys.platform == "win32", reason="fake binaries are POSIX shell scripts")
SKILL_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SCANNER = os.path.join(SKILL_DIR, "scripts", "scan_provenance.py")
RUNNER = os.path.join(SKILL_DIR, "scripts", "run_forensics.sh")
def _setup(tmp_path):
bindir = tmp_path / "bin"
bindir.mkdir()
log = tmp_path / "calls.log"
for tool in ("npm", "gh"):
fake = bindir / tool
fake.write_text(
"#!/bin/sh\n"
f'echo "{tool} $*" >> "{log}"\n'
"exit 1\n"
)
fake.chmod(fake.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
repo = tmp_path / "repo"
repo.mkdir()
(repo / "package.json").write_text('{"name": "x", "version": "1.0.0"}\n')
(repo / "package-lock.json").write_text(
'{"name": "x", "lockfileVersion": 3, "packages": {}}\n')
env = dict(os.environ)
env["PATH"] = str(bindir) + os.pathsep + env.get("PATH", "")
return repo, log, env
def _calls(log):
return log.read_text() if log.exists() else ""
def test_scanner_online_calls_fakes(tmp_path):
"""Sanity: the fakes are on PATH and get called without --offline."""
repo, log, env = _setup(tmp_path)
subprocess.run([sys.executable, SCANNER, str(repo), "--format", "json"],
env=env, capture_output=True, text=True, timeout=60)
calls = _calls(log)
assert "npm audit signatures" in calls
assert "gh attestation verify" in calls
def test_scanner_offline_skips_npm_and_gh(tmp_path):
repo, log, env = _setup(tmp_path)
result = subprocess.run(
[sys.executable, SCANNER, str(repo), "--format", "json", "--offline"],
env=env, capture_output=True, text=True, timeout=60)
assert result.returncode == 0, result.stderr
assert result.stdout.strip().startswith("[")
assert _calls(log) == ""
def test_run_forensics_offline_skips_npm_and_gh(tmp_path):
repo, log, env = _setup(tmp_path)
subprocess.run(sh_argv(RUNNER, str(repo), "--offline", "--format", "json"),
env=env, capture_output=True, text=True, timeout=300)
assert _calls(log) == ""
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |