Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration test for node false negative pattern #895

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from builtins import _test_sink, _test_source

class Node:
def __init__(self, val=None):
self.val = val
self.next = None

def linked_list_pattern(x):
b = Node(x)
c = Node()
d = Node()

d.next = c
c.next = b
e = d.next.next.val

_test_sink(e) # false negative

# Pysa treats memory as flat and doesn't understand aliases.
# It fails to recognize that `d.next` -> `c` and `c.next` -> `b`,
# so it misses that `e` (i.e., `d.next.next.val`) is derived from `x`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def _test_sink(arg: TaintSink[Test, Via[special_sink]]): ...

def _test_source() -> TaintSource[Test, Via[special_source]]: ...