feat(model): a region that spans the flow, not just a function

contributor-scan 2.4, closing the no-go task 2.2 recorded.

VAmPI's SQL injection is a request parameter reaching `get_by_username`
in api_views/users.py, passed to `User.get_user` in models/user_model.py,
interpolated into a query string and executed there. Source and sink are
in different functions and different modules. Regions were per-function,
so neither region saw both ends and the engine was silent on the most
ordinary shape a real injection bug has.

`reachableByFlows` was never the limitation -- it follows calls already.
The limitation was the QUESTION. Sinks were filtered to the labeled
function's own body, so a crossing flow had no sink to end at.

Three changes, each with a reason it is sound rather than convenient:

**An entry point is the trust boundary.** parameter_sources was off for
repository scans because a repository's parameters are not all attacker
input. An entry point's are, by definition -- that is what makes it an
entry point. The driver turns it on only for regions the mapper found and
named, and leaves it off for walker fallbacks and for named functions that
are not entry points.

**Sinks may sit below the handler.** taint.sc admits sinks in methods
reachable from the labeled method through the call graph, bounded at
ENTRY_POINT_CALL_DEPTH = 3: handler -> service -> data access, which is
where these bugs live. Unbounded would make the question about most of the
repository rather than about this entry point, and make it unaffordable.

**The finding names the sink, not the asker.** A crossing flow ends in
another file and another function, so Verdict carries the evidence's own
`path:line:function` and the site uses it. Reporting
`models/user_model.py:73:get_by_username` would name a place that does not
exist: line 73 is inside get_user.

Also: labeled methods are now resolved by name AND file. `get_user` exists
in more than one module of a real repository, which a corpus of one-file
excerpts could never surface.

Measured on the same checkout and budget as 2.2:

  VAmPI-SQLI    missed -> model_entailed at models/user_model.py:73:get_user
  known found   0 of 2 before 2.2's fixes, 1 of 2 in 2.2, 2 of 2 now
  entailed      7 -> 8
  query time    40.9s -> 37.4s
  peak RSS      869MB -> 827MB
  cost          $0.0067, unchanged

Asking the bigger question cost nothing measurable here: file scoping and
call-graph following pull in opposite directions and roughly cancel at this
size. That is one 520-line repository, and VAmPI is now the repository this
change was developed against -- the exact overfitting shape Req 8 exists to
catch. The depth bound and the entry-point rule mean nothing general until
a checkout nobody tuned against says so.

Gates byte-identical.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01T7XD7x5KonMdmGRkp63EQG
This commit is contained in:
Marius Ciepluch
2026-09-09 09:27:19 +02:00
co-authored by Claude Opus 5
parent 177c7f3719
commit ca7b5ba370
9 changed files with 355 additions and 27 deletions
+27 -3
View File
@@ -268,8 +268,32 @@ def test_a_witness_line_is_read_whatever_follows_the_number() -> None:
Splitting on the comma produced sites like `config.py:17): permissive literal '0.0.0.0':?` -- a line
number no editor can open and no consumer can compare.
"""
from openultrasast.model.ladder import Rung, Verdict
from openultrasast.model.pipeline import _site
assert _site("config.py", "", "permissive literal '0.0.0.0' (line 17): permissive") == "config.py:17:?"
assert _site("a.py", "run", "flow reaches os.system (line 9, via x)") == "a.py:9:run"
assert _site("a.py", "run", "no line at all") == "a.py:?:run"
def at(witness: str) -> Verdict:
return Verdict(rung=Rung.ENTAILED, family="injection", witness=witness)
assert _site("config.py", "", at("permissive literal '0.0.0.0' (line 17): permissive")) == "config.py:17:?"
assert _site("a.py", "run", at("flow reaches os.system (line 9, via x)")) == "a.py:9:run"
assert _site("a.py", "run", at("no line at all")) == "a.py:?:run"
def test_an_arbiter_that_knows_where_the_evidence_is_names_that_file() -> None:
"""Once a flow may cross modules, the region that asked is not where the answer lives.
VAmPI's SQL injection is reached from a handler in api_views/users.py and executed in
models/user_model.py. Reporting it against the handler sends a contributor to the wrong file.
"""
from openultrasast.model.ladder import Rung, Verdict
from openultrasast.model.pipeline import _site
crossed = Verdict(
rung=Rung.ENTAILED,
family="injection",
witness="username -> execute",
location="models/user_model.py:73:get_user",
)
# The asking region is api_views/users.py:get_by_username; every part of the site is the sink's instead.
assert _site("api_views/users.py", "get_by_username", crossed) == "models/user_model.py:73:get_user"