Files
violin/tests/pentest_docs/test_pentest_docs_task4_checkpoint.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

44 lines
1.4 KiB
Python

import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
TEMPLATE = ROOT / "skills/pentest/templates/checkpoint.json"
SCOPING = ROOT / "skills/pentest/playbooks/scoping.md"
SKILL = ROOT / "skills/pentest/SKILL.md"
def test_checkpoint_template_has_minimal_resume_schema():
data = json.loads(TEMPLATE.read_text(encoding="utf-8"))
assert data["version"] == 1
expected = {
"engagement_id",
"eng_dir",
"scope_file",
"phase_current",
"ptt_file",
"history_file",
"hypotheses_file",
"phase_summary_file",
"last_checkpoint",
"open_items",
}
assert expected.issubset(data)
forbidden = ["token", "docker", "zap", "container", "bearer", "api_key", "secret"]
serialized = json.dumps(data).lower()
assert not any(term in serialized for term in forbidden)
def test_scoping_bootstrap_writes_checkpoint_from_template():
text = SCOPING.read_text(encoding="utf-8")
assert "checkpoint.json" in text
assert "skills/pentest/templates/checkpoint.json" in text
assert "$ENG_DIR/state/checkpoint.json" in text
assert "phase_current" in text
def test_skill_drift_guard_mentions_checkpoint_on_phase_change():
text = SKILL.read_text(encoding="utf-8")
assert "checkpoint.json" in text
assert "phase change" in text.lower()
assert "$ENG_DIR/state/checkpoint.json" in text