py-ast-taint.py Assign handler never removed a name from the tainted set on reassignment, so a source-then-constant/sanitizer rebind (g=os.getenv(); g='safe'; os.system(g), or x=shlex.quote(x)) kept stale taint and fired false AST-CMD-EXEC findings. Assign now clears taint for target names when the RHS is not a source. No cross-expression propagation added — the f-string/concat/alias recall gap (#27) stays deferred to v8. #28: added fixtures+assertions locking the tainted subprocess/os.system AST-CMD-EXEC sink and the open(...,'w') AST-FILE-WRITE sink. Suite 1931/0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcQyMTQfyrsAapaCMPxTtQ
This commit is contained in:
parent
629a5e6e8c
commit
76f190cf78
4 changed files with 69 additions and 0 deletions
|
|
@ -151,6 +151,11 @@ def analyze_scope(body):
|
|||
if src:
|
||||
for name in (n for t in node.targets for n in assigned_names(t)):
|
||||
tainted[name] = (node.lineno, src)
|
||||
else:
|
||||
# Rebinding to a non-source value (constant, sanitizer call, ...)
|
||||
# kills the taint for that name in this scope.
|
||||
for name in (n for t in node.targets for n in assigned_names(t)):
|
||||
tainted.pop(name, None)
|
||||
if isinstance(node.value, ast.Call) and dotted(node.value.func) == "open" \
|
||||
and is_write_open(node.value):
|
||||
for name in (n for t in node.targets for n in assigned_names(t)):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue