Answer security round 1: 0 🔴, 1 🟡 (0 misread); refuse a Grep with a glob over a folder holding an ignored env-file, and file item 370 for recursive Bash searches
CI / tests (pull_request) Successful in 2m36s
CI / tests (pull_request) Successful in 2m36s
This commit is contained in:
@@ -27,7 +27,8 @@ def reads(call: Call, path: pathlib.Path, home: str) -> bool:
|
||||
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)
|
||||
# ripgrep's --glob overrides its ignore files, so an ignored file is skipped only by a Grep without one.
|
||||
return names(searched, path) or holds(searched, path) and (bool(text(call.given, "glob")) or not ignored(path))
|
||||
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}"))))
|
||||
@@ -51,5 +52,5 @@ def holds(folder: str, path: pathlib.Path) -> bool:
|
||||
|
||||
|
||||
def ignored(path: pathlib.Path) -> bool:
|
||||
"""Whether the checkout holding path ignores it: Grep runs ripgrep, which skips such a file in a folder it searches."""
|
||||
"""Whether the checkout holding path ignores it: Grep runs ripgrep, which skips such a file in a folder it searches unless a glob names it."""
|
||||
return not isinstance(guarded_git(str(path.parent), "check-ignore", "--quiet", path.name), Failure)
|
||||
|
||||
Reference in New Issue
Block a user