Repository navigation
fix(refutation): prove only the allowlists that are constant and stable - #247
Merged
Merged
Conversation
…t keys out of lookups A list or set built by list() or set() proves a membership test only while the function only reads it; a lookup in a dict display carries the taint of its values, unpacked mappings and later stores, never of its keys.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the approach agreed in #239.
What proves a value:
.keys();frozenset,set,tupleorlistof one of these;frozensetof a display, of constants, bound once and never rebound.ModuleCollectionsAnalysis. It shares the "bound once, never rebound" rule withModuleStringsAnalysisthroughmodule_bindings.ALLOWED = frozenset(...)) is loaded as theSymboloffrozenset. The refutation therefore recognises it by the span of the name in the function's HIR.{...}[key],.get(key[, default])) carries the taint of its values, of what was stored in it and of the default, never the taint of the key.What does not prove a value:
allowed = ["ls"]; allowed.append(x); if cmd in allowedwas refuted and is now a hotspot. The same holds for a display passed to a call, or with an unpacked element (("ls", *extra)).Verification
tests/test_allowlist_shapes.py, new: 34 tests through the bundledcommand-injectionrule. 13 of them fail on main. No existing test changed.test_packaging.py::test_the_version_has_one_source_of_truth, which also fails on main (locally installed metadata).ruff checkandmypyclean.full-stack-fastapi-templatefails on coverage (43 files and 198 functions observed, 42 and 194 expected) on main too; its findings are identical with and without this change.