fix(report): raise RuntimeError on non-object run.json (fixes #1109) (#1116)

This commit is contained in:
RAJVARDHAN PATIL
2026-08-20 13:41:04 -07:00
committed by GitHub
parent fe758af4fc
commit e152c4c7c0
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -346,7 +346,7 @@ def _load_resume_state(args: argparse.Namespace, parser: argparse.ArgumentParser
)
try:
state = read_run_record(run_dir)
except RuntimeError as exc:
except (RuntimeError, TypeError) as exc:
parser.error(f"--resume {args.resume}: run.json unreadable: {exc}")
args.targets_info = state.get("targets_info") or []
+15
View File
@@ -227,3 +227,18 @@ def test_resume_still_requires_targets_or_a_workspace(
cli_main.parse_arguments()
assert "has no targets_info" in capsys.readouterr().err
def test_resume_non_object_run_json_exits(tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]) -> None:
monkeypatch.chdir(tmp_path)
run_dir = tmp_path / "strix_runs" / "pentest_abcd"
run_dir.mkdir(parents=True)
(run_dir / "run.json").write_text("[]", encoding="utf-8")
monkeypatch.setattr(sys, "argv", ["strix", "--resume", "pentest_abcd"])
with pytest.raises(SystemExit) as exc_info:
cli_main.parse_arguments()
assert exc_info.value.code == 2
captured = capsys.readouterr()
assert "run.json unreadable" in captured.err
assert "not an object" in captured.err