Skip to content

alexgreensh/repo-forensics / skills/repo-forensics

repo-forensics

Flagged

Security 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.

FileKindSize
.gitignoreother193 B
SKILL.mdskill md43.4 KB
checksums.jsonconfig10.8 KB
checksums.json.sigother64 B
data/README.mdmarkdown1.3 KB
data/compromised_versions.jsonconfig188.3 KB
data/rule_ids.csvother35.3 KB
data/rulepacks/.gitkeepother221 B
data/rulepacks/dead_anchors.jsonconfig9.0 KB
data/rulepacks/mcp_security.jsonconfig31.2 KB
data/rulepacks/runtime_dynamism.jsonconfig46.7 KB
data/rulepacks/sast.jsonconfig107.6 KB
data/rulepacks/secrets.jsonconfig30.4 KB
data/rulepacks/shared.jsonconfig4.4 KB
data/rulepacks/skill_threats.jsonconfig95.4 KB
data/runtime_floors.jsonconfig2.3 KB
data/yara/cryptominers.yarother1.8 KB
data/yara/hacktools.yarother2.2 KB
data/yara/malware.yarother2.2 KB
data/yara/manifest.jsonconfig8.0 KB
data/yara/webshells.yarother2.5 KB
references/cursor-hook-contract.mdmarkdown5.6 KB
references/kernel_privesc_sandbox_pack.mdmarkdown5.0 KB
references/mcp-attack-patterns.mdmarkdown8.7 KB
references/research_sources.mdmarkdown8.0 KB
references/threat_patterns.mdmarkdown20.3 KB
scripts/_context_gate.pyscript21.7 KB
scripts/_ed25519.pyscript5.1 KB
scripts/_pyc_unmarshal.pyscript17.1 KB
scripts/_shared_patterns.pyscript4.8 KB
scripts/adjudication.pyscript16.4 KB
scripts/adjudication_bridge.pyscript1.0 KB
scripts/aggregate_json.pyscript69.2 KB
scripts/auto_scan.pyexecutablescript152.1 KB
scripts/corpus_sync.pyscript10.0 KB
scripts/cursor_pre_scan.pyscript22.5 KB
scripts/dast_sandbox.sbother1.6 KB
scripts/dead_anchors_extract.pyscript14.8 KB
scripts/dead_anchors_probe.pyscript27.1 KB
scripts/forensics_core.pyscript176.5 KB
scripts/gen_rule_ids.pyscript8.6 KB
scripts/hook_adapter.pyscript19.4 KB
scripts/ioc_manager.pyscript49.6 KB
scripts/parse_pnpm_lock.pyscript7.9 KB
scripts/pre_scan.pyscript143.5 KB
scripts/pypi_pins.pyscript8.1 KB
scripts/refresh_controller.pyexecutablescript48.4 KB
scripts/refresh_threat_dbs.pyexecutablescript19.4 KB
scripts/rule_loader.pyscript44.8 KB
scripts/rulepack_feed.pyscript26.4 KB
scripts/run_forensics.shexecutablescript20.3 KB
scripts/sarif_export.pyscript18.6 KB
scripts/scan_agent_skills.pyscript33.2 KB
scripts/scan_archive.pyscript29.1 KB
scripts/scan_ast.pyscript44.9 KB
scripts/scan_binary.pyscript10.9 KB
scripts/scan_bytecode.pyscript28.2 KB
scripts/scan_dast.pyscript28.8 KB
scripts/scan_dataflow.pyscript15.4 KB
scripts/scan_dead_anchors.pyscript15.9 KB
scripts/scan_decode.pyscript37.5 KB
scripts/scan_dependencies.pyscript124.5 KB
scripts/scan_devcontainer.pyscript8.5 KB
scripts/scan_entropy.pyscript15.6 KB
scripts/scan_entrypoint.pyscript34.3 KB
scripts/scan_git_config.pyscript96.3 KB
scripts/scan_git_forensics.pyscript24.1 KB
scripts/scan_history.pyscript14.5 KB
scripts/scan_infra.pyscript54.3 KB
scripts/scan_integrity.pyscript41.0 KB
scripts/scan_lifecycle.pyscript65.1 KB
scripts/scan_manifest_drift.pyscript47.0 KB
scripts/scan_mcp_security.pyscript42.3 KB
scripts/scan_oversize.pyscript11.7 KB
scripts/scan_post_incident.pyscript36.9 KB
scripts/scan_provenance.pyscript19.4 KB
scripts/scan_runtime_dynamism.pyscript23.5 KB
scripts/scan_runtime_floors.pyscript33.5 KB
scripts/scan_sast.pyscript59.1 KB
scripts/scan_secrets.pyscript11.9 KB
scripts/scan_skill_threats.pyscript102.4 KB
scripts/scan_splitstream.pyscript29.5 KB
scripts/scan_yara.pyscript19.7 KB
scripts/session_scan.pyscript54.1 KB
scripts/suppressions.pyscript15.4 KB
scripts/validate_manifests.pyscript13.7 KB
scripts/verify_install.pyscript26.2 KB
scripts/vuln_feed.pyscript31.1 KB
tests/conftest.pyscript13.4 KB
tests/corpus/DEAD_ANCHORS_CORPUS.mdmarkdown2.3 KB
tests/corpus/budgets.jsonconfig5.6 KB
tests/cursor_helpers.pyscript12.6 KB
tests/fixtures/legacy_main_blocks.jsonconfig10.3 KB
tests/fixtures/powershell_verdict_corpus.jsonconfig114.9 KB
tests/golden/parity_mcp_security.jsonconfig17.5 KB
tests/golden/parity_runtime_dynamism.jsonconfig31.7 KB
tests/golden/parity_sast.jsonconfig59.8 KB
tests/golden/parity_secrets.jsonconfig18.8 KB
tests/golden/parity_skill_threats.jsonconfig48.8 KB
tests/parity_corpus.pyscript6.3 KB
tests/powershell_hook.pyscript8.2 KB
tests/report_builders.pyscript5.0 KB
tests/schemas/sarif-schema-2.1.0.jsonconfig109.1 KB
tests/shell_compat.pyscript2.2 KB
tests/test_adjudication_bridge.pyscript832 B
tests/test_adjudication_containment.pyscript1.4 KB
tests/test_adjudication_output.pyscript20.0 KB
tests/test_adjudication_suppressions.pyscript18.7 KB
tests/test_advisory_adjudication.pyscript1.3 KB
tests/test_agent_relay_rules.pyscript7.8 KB
tests/test_aggregate_json.pyscript10.0 KB
tests/test_auto_scan_patterns.pyscript10.5 KB
tests/test_benign_corpus.pyscript16.4 KB
tests/test_benign_new_scanners.pyscript6.1 KB
tests/test_build_output_skip.pyscript10.6 KB
tests/test_capability_ledger.pyscript18.8 KB
tests/test_codex_install.pyscript10.0 KB
tests/test_codex_marketplace.pyscript3.3 KB
tests/test_comment_false_positives.pyscript2.2 KB
tests/test_composer_dependencies.pyscript4.0 KB
tests/test_compromised_versions.pyscript51.2 KB
tests/test_context_gate.pyscript32.4 KB
tests/test_coverage_status.pyscript7.6 KB
tests/test_css_compounding_shrink.pyscript20.8 KB
tests/test_cursor_adapter.pyscript7.8 KB
tests/test_cursor_benign.pyscript3.4 KB
tests/test_cursor_degrade.pyscript12.7 KB
tests/test_cursor_install.pyscript17.1 KB
tests/test_cursor_latency.pyscript7.2 KB
tests/test_cursor_parity.pyscript5.8 KB
tests/test_cursor_redteam_fn.pyscript4.9 KB
tests/test_cursor_tamper_modify.pyscript14.2 KB
tests/test_cursor_wiring.pyscript32.3 KB
tests/test_d1_yara_correlation.pyscript9.2 KB
tests/test_dead_anchors_extract.pyscript7.6 KB
tests/test_dead_anchors_probe.pyscript19.7 KB
tests/test_evidence_engine_parity.pyscript8.1 KB
tests/test_evidence_model.pyscript11.4 KB
tests/test_forensics_core.pyscript79.2 KB
tests/test_fp_hardening_r3.pyscript9.7 KB
tests/test_fp_hardening_r4.pyscript18.8 KB
tests/test_fp_regression_pairs.pyscript62.5 KB
tests/test_fp_structural.pyscript21.2 KB
tests/test_freshness.pyscript6.2 KB
tests/test_frontmatter_validity.pyscript7.0 KB
tests/test_gpg_rce_hotfix.pyscript4.8 KB
tests/test_hook_inert_data.pyscript6.1 KB
tests/test_hook_scripts.pyscript14.0 KB
tests/test_inspection_cpu_budget.pyscript11.6 KB
tests/test_ioc_manager.pyscript55.4 KB
tests/test_kernel_privesc_rules.pyscript27.8 KB
tests/test_legit_precision_regressions.pyscript6.8 KB
tests/test_lethal_trifecta.pyscript20.7 KB
tests/test_manifest_signature.pyscript1.5 KB
tests/test_manifest_validity.pyscript2.9 KB
tests/test_monotonic_trust_e2e.pyscript4.4 KB
tests/test_non_breaking_contract.pyscript22.7 KB
tests/test_openclaw_install.pyscript6.6 KB
tests/test_pack_parity.pyscript24.8 KB
tests/test_parse_pnpm_lock.pyscript10.7 KB
tests/test_plugin_checkout_provenance.pyscript11.1 KB
tests/test_powershell_hook_wire.pyscript10.6 KB
tests/test_powershell_verdict_corpus.pyscript6.2 KB
tests/test_pr44_hardening.pyscript6.5 KB
tests/test_pre_scan.pyscript19.6 KB
tests/test_pre_scan_composer.pyscript7.4 KB
tests/test_precondition_fields.pyscript4.6 KB
tests/test_provenance_offline.pyscript2.5 KB
tests/test_published_rulepack_feed_current.pyscript1.4 KB
tests/test_py38_compat.pyscript3.3 KB
tests/test_pypi_pinned_versions.pyscript19.3 KB
tests/test_pyproject_string_forms.pyscript2.2 KB
tests/test_redteam_fn_regression.pyscript32.5 KB
tests/test_reflective_fetch_execute.pyscript23.5 KB
tests/test_reflective_review_fixes.pyscript17.8 KB
tests/test_refresh_controller.pyscript19.9 KB
tests/test_refresh_rulepacks.pyscript12.4 KB
tests/test_review_gate_regressions.pyscript9.3 KB
tests/test_rule_loader.pyscript23.2 KB
tests/test_rulepack_feed.pyscript38.1 KB
tests/test_run_forensics_json.pyscript1012 B
tests/test_run_scanner_fail_loud.pyscript6.5 KB
tests/test_runtime_floors.pyscript19.8 KB
tests/test_sandbox_probing_rules.pyscript9.6 KB
tests/test_sarif_export.pyscript19.9 KB
tests/test_scan_agent_skills.pyscript31.3 KB
tests/test_scan_archive.pyscript11.6 KB
tests/test_scan_ast.pyscript12.8 KB
tests/test_scan_binary.pyscript15.3 KB
tests/test_scan_bytecode.pyscript21.5 KB
tests/test_scan_dast.pyscript32.1 KB
tests/test_scan_dataflow.pyscript7.1 KB
tests/test_scan_dead_anchors.pyscript11.5 KB
tests/test_scan_decode.pyscript28.0 KB
tests/test_scan_dependencies.pyscript37.8 KB
tests/test_scan_devcontainer.pyscript8.5 KB
tests/test_scan_entropy.pyscript11.2 KB
tests/test_scan_entrypoint.pyscript19.5 KB
tests/test_scan_git_config.pyscript58.5 KB
tests/test_scan_git_config_review_fixes.pyscript33.3 KB

tests/test_scan_binary.py

View on GitHub
"""Tests for scan_binary.py - Binary Camouflage Scanner."""

import os
import struct
import scan_binary as scanner


def _make_valid_pe_bytes():
    """Build a minimal but structurally valid MZ+PE stub (no actual code)."""
    # DOS header: MZ magic + e_lfanew at offset 0x3C pointing to offset 0x40
    dos_header = bytearray(64)
    dos_header[0:2] = b'MZ'
    struct.pack_into('<I', dos_header, 0x3C, 0x40)  # e_lfanew = 0x40

    # PE signature at offset 0x40
    pe_sig = b'PE\x00\x00'

    # Pad to make a recognizable blob
    padding = bytes(32)
    return bytes(dos_header) + pe_sig + padding


class TestEmbeddedPe:
    def test_png_with_embedded_pe_is_critical(self, tmp_path):
        """PNG file with a valid PE at a non-zero offset should trigger a CRITICAL finding."""
        png_header = bytes([
            0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,  # PNG magic
            0x00, 0x00, 0x00, 0x0d,                              # IHDR length
            0x49, 0x48, 0x44, 0x52,                              # IHDR type
        ])
        # Pad PNG area then embed PE at offset 256
        filler = bytes(256 - len(png_header))
        pe_blob = _make_valid_pe_bytes()
        content = png_header + filler + pe_blob

        evil_png = tmp_path / "image.png"
        evil_png.write_bytes(content)

        findings = scanner.scan_embedded_pe(str(evil_png), "image.png")
        critical = [f for f in findings if f.severity == "critical"]
        assert len(critical) >= 1, f"Expected CRITICAL embedded PE finding, got: {[f.title for f in findings]}"
        assert any("embedded pe" in f.title.lower() for f in critical)
        assert any(f.category == "embedded-executable" for f in critical)

    def test_normal_png_no_finding(self, tmp_path):
        """A clean PNG file without any PE content should produce no findings."""
        png_header = bytes([
            0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
            0x00, 0x00, 0x00, 0x0d,
            0x49, 0x48, 0x44, 0x52,
        ])
        content = png_header + bytes(512)

        clean_png = tmp_path / "clean.png"
        clean_png.write_bytes(content)

        findings = scanner.scan_embedded_pe(str(clean_png), "clean.png")
        assert len(findings) == 0, f"Expected no findings for clean PNG, got: {[f.title for f in findings]}"

    def test_exe_is_skipped(self, tmp_path):
        """A normal .exe file (MZ at offset 0) should not trigger embedded PE detection."""
        pe_blob = _make_valid_pe_bytes()
        exe_file = tmp_path / "normal.exe"
        exe_file.write_bytes(pe_blob)

        findings = scanner.scan_embedded_pe(str(exe_file), "normal.exe")
        assert len(findings) == 0, f"Expected no findings for .exe, got: {[f.title for f in findings]}"

    def test_dll_is_skipped(self, tmp_path):
        """A .dll file should be skipped regardless of content."""
        pe_blob = _make_valid_pe_bytes()
        dll_file = tmp_path / "lib.dll"
        dll_file.write_bytes(pe_blob)

        findings = scanner.scan_embedded_pe(str(dll_file), "lib.dll")
        assert len(findings) == 0, f"Expected no findings for .dll, got: {[f.title for f in findings]}"

    def test_pdf_with_embedded_pe_is_critical(self, tmp_path):
        """A PDF containing an embedded PE should also be detected."""
        pdf_header = b'%PDF-1.4\n'
        filler = bytes(128)
        pe_blob = _make_valid_pe_bytes()
        content = pdf_header + filler + pe_blob

        evil_pdf = tmp_path / "document.pdf"
        evil_pdf.write_bytes(content)

        findings = scanner.scan_embedded_pe(str(evil_pdf), "document.pdf")
        critical = [f for f in findings if f.severity == "critical"]
        assert len(critical) >= 1, f"Expected CRITICAL finding in PDF, got: {[f.title for f in findings]}"

    def test_mz_without_valid_pe_sig_no_finding(self, tmp_path):
        """MZ bytes without a valid PE signature should not trigger a finding."""
        # MZ at offset 64 but e_lfanew points to garbage (no PE\x00\x00)
        content = bytes(64) + b'MZ' + bytes(256)
        fake_bin = tmp_path / "fake.bin"
        fake_bin.write_bytes(content)

        findings = scanner.scan_embedded_pe(str(fake_bin), "fake.bin")
        assert len(findings) == 0, f"Expected no finding for MZ-only (no PE sig), got: {[f.title for f in findings]}"

    def test_tiny_file_skipped(self, tmp_path):
        """Files under 64 bytes should be skipped entirely."""
        tiny = tmp_path / "tiny.png"
        tiny.write_bytes(b'MZ' + bytes(30))

        findings = scanner.scan_embedded_pe(str(tiny), "tiny.png")
        assert len(findings) == 0, "Expected no findings for tiny file"


class TestAudioSteganography:
    """Regression tests for the audio-steg PE validation (PR #43).

    A bare 'MZ' pair is only 2 bytes, so it recurs by pure chance roughly
    every 64 KB inside entropy-coded audio; flagging it as an executable was a
    critical-severity false positive on ordinary audio. The fix requires a real
    PE structure (e_lfanew -> 'PE\\x00\\x00'), and that structural check reads
    the signature at ``offset + e_lfanew`` (relative to the MZ), so it must NOT
    regress a genuine embedded PE into a missed detection.
    """

    # Non-text, non-exec-magic filler: none of these bytes is 0x4D ('M') or
    # 0x7F, so no accidental 'MZ' / '\\x7fELF' magic appears, and only 2 of the
    # 8 bytes are printable so the separate "text content in audio" heuristic
    # (>90% printable) never trips either.
    _FILLER = bytes([0xA5, 0x5A, 0xC3, 0x00, 0x11, 0xF0, 0x9D, 0x42])

    def _filler(self, n):
        return (self._FILLER * (n // len(self._FILLER) + 1))[:n]

    def test_bare_mz_in_audio_no_finding(self, tmp_path):
        """FALSE-POSITIVE guard: a bare 'MZ' inside audio entropy, with no valid
        PE structure behind it, must NOT be flagged as an executable."""
        # header + filler + bare MZ (e_lfanew bytes are filler => nonsense) + filler
        content = b'ID3\x03\x00\x00\x00\x00\x00\x00' + self._filler(4000) \
            + b'MZ' + self._filler(60000)
        f = tmp_path / "song.mp3"
        f.write_bytes(content)

        findings = scanner.scan_audio_steganography(str(f), "song.mp3")
        assert not any("Executable" in x.title for x in findings), (
            f"bare MZ in audio wrongly flagged as executable: {[x.title for x in findings]}"
        )

    def test_bare_mz_with_forged_absolute_pe_no_finding(self, tmp_path):
        """A 'PE\\x00\\x00' planted at the ABSOLUTE offset named by e_lfanew (rather
        than relative to the MZ) must not satisfy validation -- guards against
        reintroducing the absolute-offset read as a forgeable bypass."""
        data = bytearray(b'ID3\x03\x00\x00\x00\x00\x00\x00' + self._filler(60000))
        mz_at = 3000
        data[mz_at:mz_at + 2] = b'MZ'
        struct.pack_into('<I', data, mz_at + 0x3C, 0x80)   # e_lfanew = 0x80
        data[0x80:0x84] = b'PE\x00\x00'                     # PE at ABSOLUTE 0x80
        f = tmp_path / "forged.mp3"
        f.write_bytes(bytes(data))

        findings = scanner.scan_audio_steganography(str(f), "forged.mp3")
        assert not any("Executable" in x.title for x in findings), (
            "forged absolute-offset PE wrongly validated as an embedded executable"
        )

    def test_real_embedded_pe_in_mp3_is_flagged(self, tmp_path):
        """TRUE-POSITIVE: a structurally valid PE embedded at a non-zero offset in
        an .mp3 must be flagged (the relative-offset fix must not lose this)."""
        content = b'ID3\x03\x00\x00\x00\x00\x00\x00' + self._filler(2000) \
            + _make_valid_pe_bytes() + self._filler(60000)
        f = tmp_path / "carrier.mp3"
        f.write_bytes(content)

        findings = scanner.scan_audio_steganography(str(f), "carrier.mp3")
        titles = [x.title for x in findings]
        assert any("Executable" in t for t in titles), (
            f"real embedded PE in .mp3 not flagged (false negative): {titles}"
        )

    def test_real_embedded_pe_in_wav_is_flagged(self, tmp_path):
        """TRUE-POSITIVE for .wav: search starts past the 44-byte RIFF header, and
        a valid PE after it must still be flagged."""
        content = b'RIFF' + self._filler(2040) + _make_valid_pe_bytes() \
            + self._filler(60000)
        f = tmp_path / "carrier.wav"
        f.write_bytes(content)

        findings = scanner.scan_audio_steganography(str(f), "carrier.wav")
        titles = [x.title for x in findings]
        assert any("Executable" in t for t in titles), (
            f"real embedded PE in .wav not flagged (false negative): {titles}"
        )


class TestScanBinaryMain:
    """Regression tests for Issue #38: the `os.access(filepath, os.X_OK)` branch
    on a data file (no exec magic, no shebang) must emit a LOW
    permission-hygiene finding, NOT HIGH binary-camouflage. Magic mismatch /
    embedded-PE upstream branches stay CRITICAL (no regression)."""

    def _run_main(self, args, monkeypatch):
        """Invoke scanner.main() with the given argv and capture emitted JSON.
        Returns the parsed JSON dict (findings live at `--format json` output)."""
        import sys as _sys
        import io
        import json as _json
        from contextlib import redirect_stdout
        buf = io.StringIO()
        monkeypatch.setattr(_sys, "argv", ["scan_binary.py", *args, "--format", "json"])
        with redirect_stdout(buf):
            scanner.main()
        out = buf.getvalue().strip()
        # scanner emits a status line "[*] Scanning ..." BEFORE the JSON;
        # strip that prefix so json.loads succeeds.
        if out.startswith("["):
            return _json.loads(out)
        return _json.loads(out.split("\n", 1)[1])

    def test_exec_bit_on_json_is_low_permission_hygiene(self, tmp_path, monkeypatch):
        """A .json file with +x but no exec magic must surface a LOW finding
        under category=permission-hygiene. Issue #38: a HIGH/binary-camouflage
        was amplifying false positives on every data file with the bit set."""
        if os.name != 'posix':
            return  # chmod semantics differ on Windows; regression is POSIX-only.
        data = tmp_path / "data.json"
        data.write_bytes(b'{"hello": "world"}\n')
        os.chmod(data, 0o755)
        findings = self._run_main([str(tmp_path)], monkeypatch)
        exec_findings = [f for f in findings
                         if "Executable" in f["title"] or "executable" in f["title"].lower()
                         or "permission" in f["category"].lower()]
        assert exec_findings, f"expected at least one finding for chmod +x data file: {findings}"
        # No HIGH binary-camouflage for data file with only exec bit + no magic.
        high_camo = [f for f in exec_findings
                     if f["severity"] == "high" and f["category"] == "binary-camouflage"]
        assert high_camo == [], (
            "Issue #38: chmod +x on a data file (no exec magic, no shebang) "
            "must NOT be HIGH/binary-camouflage. Got: "
            f"{[(f['title'], f['severity'], f['category']) for f in high_camo]}"
        )
        # The LOW permission-hygiene finding is still emitted (we want the
        # signal, just at the right severity).
        low_hygiene = [f for f in exec_findings
                       if f["severity"] == "low" and f["category"] == "permission-hygiene"]
        assert low_hygiene, (
            "expected a LOW permission-hygiene finding for chmod +x data file, "
            f"got: {[(f['title'], f['severity'], f['category']) for f in exec_findings]}"
        )

    def test_exec_bit_on_markdown_is_low_permission_hygiene(self, tmp_path, monkeypatch):
        """Same expectation for .md files."""
        if os.name != 'posix':
            return
        readme = tmp_path / "README.md"
        readme.write_bytes(b"# Title\n")
        os.chmod(readme, 0o755)
        findings = self._run_main([str(tmp_path)], monkeypatch)
        # Only findings that pertain to this file
        per_file = [f for f in findings if f["file"].endswith("README.md")]
        assert per_file, f"expected at least one finding for README.md: {findings}"
        high_camo = [f for f in per_file
                     if f["severity"] == "high" and f["category"] == "binary-camouflage"]
        assert high_camo == [], (
            "Issue #38: chmod +x on .md must NOT be HIGH/binary-camouflage. "
            f"Got: {[(f['title'], f['severity'], f['category']) for f in high_camo]}"
        )

    def test_exec_bit_on_png_is_low_permission_hygiene(self, tmp_path, monkeypatch):
        """Same expectation for .png files. (PNG content is unrelated; what
        matters is no exec magic and no shebang, both already skipped above.)"""
        if os.name != 'posix':
            return
        # A real (non-PE) PNG so the magic-mismatch and embedded-PE branches
        # don't trip on it. Valid 1x1 PNG: \x89PNG\r\n\x1a\n + IHDR chunk.
        png = tmp_path / "img.png"
        png.write_bytes(
            b"\x89PNG\r\n\x1a\n"
            b"\x00\x00\x00\x0dIHDR"
            b"\x00\x00\x00\x01\x00\x00\x00\x01"
            b"\x08\x02\x00\x00\x00\x90wS\xde"
            b"\x00\x00\x00\x0cIDATx\x9cc\xf8\xcf\xc0\x00\x00\x00\x03\x00\x01"
            b"\x9b\x9c\xd8\xa9"
            b"\x00\x00\x00\x00IEND\xaeB`\x82"
        )
        os.chmod(png, 0o755)
        findings = self._run_main([str(tmp_path)], monkeypatch)
        per_file = [f for f in findings if f["file"].endswith("img.png")]
        high_camo = [f for f in per_file
                     if f["severity"] == "high" and f["category"] == "binary-camouflage"]
        assert high_camo == [], (
            "Issue #38: chmod +x on a clean PNG must NOT be "
            f"HIGH/binary-camouflage. Got: {[(f['title'], f['severity'], f['category']) for f in high_camo]}"
        )

    def test_embedded_pe_remains_critical(self, tmp_path):
        """No regression: a PNG with an embedded valid PE must still produce a
        CRITICAL embedded-executable finding (this branch is upstream of the
        chmod +x demote and was explicitly excluded from the Issue #38 fix)."""
        png_header = bytes([
            0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
            0x00, 0x00, 0x00, 0x0d,
            0x49, 0x48, 0x44, 0x52,
        ])
        filler = bytes(256 - len(png_header))
        pe_blob = _make_valid_pe_bytes()
        png = tmp_path / "evil.png"
        png.write_bytes(png_header + filler + pe_blob)
        findings = scanner.scan_embedded_pe(str(png), "evil.png")
        crit = [f for f in findings if f.severity == "critical"
                and f.category == "embedded-executable"]
        assert crit, f"embedded-PE branch must remain CRITICAL, got: {findings}"

    def test_magic_mismatch_remains_critical(self, tmp_path, monkeypatch):
        """No regression: a .png with ELF magic (a real camouflaged binary) must
        still produce a CRITICAL binary-camouflage finding. This branch is
        upstream of the chmod +x demote and was explicitly excluded from the
        Issue #38 fix."""
        png = tmp_path / "trojan.png"
        png.write_bytes(b"\x7fELF" + b"\x00" * 200)  # ELF magic, .png extension
        findings = self._run_main([str(tmp_path)], monkeypatch)
        crit_camo = [f for f in findings
                     if f["file"].endswith("trojan.png")
                     and f["severity"] == "critical"
                     and f["category"] == "binary-camouflage"]
        assert crit_camo, (
            "magic-mismatch branch must remain CRITICAL/binary-camouflage; "
            f"got: {findings}"
        )
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: 472kUpdated Claude CodeCodexVerifiedInstall
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: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall