Test the env-file-read spellings and log names that mutants survived
This commit is contained in:
@@ -22,20 +22,19 @@ def env_file_breaches(call: Call, home: str) -> list[Breach]:
|
||||
|
||||
|
||||
def reads(call: Call, path: pathlib.Path, home: str) -> bool:
|
||||
"""Whether a Read, a Grep or else a Bash command reads path."""
|
||||
if call.tool == "Read":
|
||||
return names(resolved(call.cwd, text(call.given, "file_path"), home), path)
|
||||
if call.tool == "Grep":
|
||||
searched = resolved(call.cwd, text(call.given, "path") or ".", home)
|
||||
return names(searched, path) or holds(searched, path) and not ignored(path)
|
||||
if call.tool == "Bash":
|
||||
command = text(call.given, "command")
|
||||
relative = os.path.relpath(path, home)
|
||||
spellings = "|".join(re.escape(spelling) for spelling in (str(path), *(f"{prefix}/{relative}" for prefix in ("~", "$HOME", "${HOME}"))))
|
||||
# Bounded on both sides, so a longer path that holds a spelling, such as ~/.claude/.envrc, is another file.
|
||||
spelt = re.search(rf"(?<![\w./~-])(?:{spellings})(?![\w.-])", command)
|
||||
named = (resolved(simple.directory, word, home) for simple in simple_commands(command, call.cwd, home) for word in simple.words)
|
||||
return spelt is not None or any(names(word, path) for word in named)
|
||||
return False
|
||||
command = text(call.given, "command")
|
||||
relative = os.path.relpath(path, home)
|
||||
spellings = "|".join(re.escape(spelling) for spelling in (str(path), *(f"{prefix}/{relative}" for prefix in ("~", "$HOME", "${HOME}"))))
|
||||
# Bounded on both sides, so a longer path that holds a spelling, such as ~/.claude/.envrc, is another file.
|
||||
spelt = re.search(rf"(?<![\w./~-])(?:{spellings})(?![\w.-])", command)
|
||||
named = (resolved(simple.directory, word, home) for simple in simple_commands(command, call.cwd, home) for word in simple.words)
|
||||
return spelt is not None or any(names(word, path) for word in named)
|
||||
|
||||
|
||||
def names(given: str, path: pathlib.Path) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user