MCPcopy
hub / github.com/openai/plugins / require_unchanged_target

Function require_unchanged_target

plugins/codex-security/scripts/workbench_db.py:1659–1692  ·  view source on GitHub ↗
(scan: sqlite3.Row)

Source from the content-addressed store, hash-verified

1657
1658
1659def require_unchanged_target(scan: sqlite3.Row) -> None:
1660 if scan["diff_target_kind"] != "working_tree" and not scan["target_snapshot_digest"]:
1661 return
1662 target = require_target(scan["target_path"])
1663 if scan["target_revision"] == "unversioned":
1664 current_digest = directory_content_digest(
1665 target,
1666 excluded=(Path(scan["scan_dir"]),),
1667 )
1668 if current_digest != scan["target_snapshot_digest"]:
1669 raise SystemExit(
1670 "Directory contents changed while the scan was running. Start a new scan."
1671 )
1672 return
1673 if git_revision(target) == "unversioned":
1674 raise SystemExit("The scan target revision no longer matches the selected target.")
1675 current_head = require_git_worktree_head(target)
1676 expected_head = (
1677 scan["diff_head_revision"]
1678 if scan["diff_target_kind"] == "working_tree"
1679 else scan["target_revision"]
1680 )
1681 if current_head != expected_head:
1682 raise SystemExit("Repository HEAD changed while the scan was running. Start a new scan.")
1683 current_digest = worktree_content_digest(target)
1684 expected_digest = (
1685 scan["diff_content_digest"]
1686 if scan["diff_target_kind"] == "working_tree"
1687 else scan["target_snapshot_digest"]
1688 )
1689 if current_digest != expected_digest:
1690 raise SystemExit(
1691 "Working-tree contents changed while the scan was running. Start a new scan."
1692 )
1693
1694
1695def scan_local_file_digest(scan_dir: Path, relative_path: str) -> str:

Callers 1

complete_scan_lockedFunction · 0.85

Calls 5

directory_content_digestFunction · 0.90
git_revisionFunction · 0.90
worktree_content_digestFunction · 0.90
require_targetFunction · 0.85

Tested by

no test coverage detected