Files
violin/tests/pentest_docs/test_pentest_docs_task3_ptai_sidecar.py
Violin ea7e094528 Remediate audit P0/P1 findings; migrate tests to green
- state.py: fcntl/msvcrt file locking, reservation+finalization, history
  verification, remove dead subprocess bridges (p1-lock)
- hypotheses.py: enforce canonical status, phase/host/service/port match,
  reject unrelated hypotheses (p1-hyp)
- tools.py/__init__.py: retain kwargs (task_id), lifecycle hooks wired
  (REGISTERED_TOOLS + no-op-then-active hooks) (p1-life)
- Migrate tests from tests/*.py to tests/guard + tests/pentest_docs; align
  to actual API (handle_target returns ips[0], handle_exec_burst fail-closed,
  PTT self-certify uses real batch_id, post-exploitation requires hypothesis)
- scoping.md: add checkpoint.json continuity-artifact drift note
- pyproject.toml: v1.2.0, per-file-ignores for tests/scripts (E402/S101)
- Add .pytest-tmp-plugin/ to .gitignore

64 passed; ruff clean.
2026-07-12 20:57:55 +01:00

47 lines
1.6 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
TOOL_CATALOG = ROOT / "skills/pentest/references/tool-catalog.md"
TOOLS = ROOT / "skills/pentest/playbooks/tools.md"
EXPLOITATION = ROOT / "skills/pentest/playbooks/exploitation.md"
def read(path: Path) -> str:
return path.read_text(encoding="utf-8")
def test_ptai_is_optional_and_never_registered_as_live_mcp() -> None:
catalog = read(TOOL_CATALOG)
tools = read(TOOLS)
combined = catalog + "\n" + tools
assert "pentest-ai / ptai (optional, external)" in combined
assert "does NOT register `ptai mcp` as a live tool" in combined
assert "bypass `violin_exec`/`check-command`" in combined
assert "ptai output is NEVER auto-in-scope" in combined
def test_ptai_has_gate_preserving_sidecar_and_recipe_patterns() -> None:
combined = "\n".join(read(path) for path in (TOOL_CATALOG, TOOLS, EXPLOITATION))
for required in [
"Sidecar import",
"Recipe wrapper",
"$ENG_DIR/evidence/exploitation/ptai/",
"produce a Violin receipt",
"re-pass `check-command`",
"Discovery: `command -v ptai`",
]:
assert required in combined
def test_exploitation_requires_ptai_evidence_to_stay_candidate_until_revalidated() -> None:
exploitation = read(EXPLOITATION)
assert "ptai evidence starts as candidate evidence only" in exploitation
assert "cannot become Validated from ptai's verdict alone" in exploitation
assert (
"proof_type: idempotent_replay" in exploitation
or "proof_type: differential" in exploitation
)