Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 361bee8

Browse files
committed
Python: Tests inspired by reverse read check
1 parent 527c415 commit 361bee8

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

  • python/ql/test/experimental/dataflow/coverage

python/ql/test/experimental/dataflow/coverage/test.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,3 +591,35 @@ def return_from_inner_scope(x):
591591

592592
def test_return_from_inner_scope():
593593
SINK(return_from_inner_scope([])) #$ flow="SOURCE, l:-3 -> return_from_inner_scope(..)"
594+
595+
596+
# Inspired by reverse read inconsistency check
597+
def insertAtA(d):
598+
d["a"] = SOURCE
599+
600+
def test_reverse_read_subscript():
601+
d = {"a": NONSOURCE}
602+
l = [d]
603+
insertAtA(l[0])
604+
SINK(d["a"]) #$ MISSING:flow="SOURCE, l-6 -> d['a']""
605+
606+
def test_reverse_read_dict_arg():
607+
d = {"a": NONSOURCE}
608+
dd = {"d": d}
609+
insertAtA(**dd)
610+
SINK(d["a"]) #$ MISSING:flow="SOURCE, l-12 -> d['a']""
611+
612+
613+
class WithA:
614+
def setA(self, v):
615+
self.a = v
616+
617+
def __init__(self):
618+
self.a = ""
619+
620+
621+
def test_reverse_read_subscript_cls():
622+
withA = WithA()
623+
l = [withA]
624+
l[0].setA(SOURCE)
625+
SINK(withA.a) #$ MISSING:flow="SOURCE, l:-1 -> self.a"

0 commit comments

Comments
 (0)