fix: tighten agent patch hygiene
Some checks failed
CI / test (push) Has been cancelled
CI / test (pull_request) Has been cancelled

This commit is contained in:
Christian Meyer
2026-08-31 03:02:42 +02:00
parent 25ed6a8439
commit c2028fa256
4 changed files with 38 additions and 4 deletions

View File

@@ -20,6 +20,8 @@ _PROTECTED_FILES = {
"compose.yaml",
}
_CODE_SUFFIXES = {".php", ".js", ".ts", ".vue", ".css", ".py"}
_TEMPORARY_SUFFIXES = {".bak", ".backup", ".orig", ".rej", ".swp", ".temp", ".tmp"}
_TEMPORARY_NAMES = {"debug.php", "test_debug.php", "scratch.php"}
def validate_changes(
@@ -54,6 +56,8 @@ def validate_changes(
raise ValueError(f"Protected path changed: {name}")
if name in _PROTECTED_FILES or name.startswith(_PROTECTED_PREFIXES):
raise ValueError(f"Protected deployment path changed: {name}")
if path.suffix.lower() in _TEMPORARY_SUFFIXES or path.name.lower() in _TEMPORARY_NAMES:
raise ValueError(f"Temporary artifact changed: {name}")
if workspace.has_symlink(name):
raise ValueError(f"Symbolic links are not allowed in agent changes: {name}")
if path.suffix in _CODE_SUFFIXES and not name.startswith(("tests/", "docs/")):