Skip to content

Commit eed8b3e

Browse files
committed
Python: Add more tests for MaD sources
1 parent 0839742 commit eed8b3e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

python/ql/test/library-tests/frameworks/data/test.ext.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ extensions:
2323
- ["testlib", "Member[ArgPos].Member[MyClass].Subclass.Member[otherSelfTest].Parameter[0]", "test-source"]
2424
- ["testlib", "Member[ArgPos].Member[MyClass].Subclass.Member[anyParam].Parameter[any]", "test-source"]
2525
- ["testlib", "Member[ArgPos].Member[MyClass].Subclass.Member[anyNamed].Parameter[any-named]", "test-source"]
26+
# test steps through content
27+
- ["testlib", "Member[source_dict].DictionaryElement[key].Member[func].ReturnValue", "test-source"]
28+
- ["testlib", "Member[source_dict_any].DictionaryElementAny.Member[func].ReturnValue", "test-source"]
29+
# TODO: Add support for list/tuples
30+
# - ["testlib", "Member[source_list].ListElement.Member[func].ReturnValue", "test-source"]
31+
# - ["testlib", "Member[source_tuple].TupleElement[0].Member[func].ReturnValue", "test-source"]
2632

2733
- addsTo:
2834
pack: codeql/python-all

python/ql/test/library-tests/frameworks/data/test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,17 @@ def anyNamed(self, name1, name2=2): # Parameter[any-named] matches all non-self
117117
testlib.foo().bar().fuzzyCall(getSource()) # NOT OK
118118
testlib.foo(lambda x: x.fuzzyCall(getSource())) # NOT OK
119119
otherlib.fuzzyCall(getSource()) # OK
120+
121+
# defining sources through content steps
122+
123+
# dictionaries
124+
testlib.source_dict["key"].func() # source
125+
testlib.source_dict["safe"].func() # not a source
126+
lambda k: testlib.source_dict_any[k].func() # source
127+
128+
# TODO: implement support for lists
129+
lambda i: testlib.source_list[i].func()
130+
131+
# TODO: implement support for tuples
132+
testlib.source_tuple[0].func() # a source
133+
testlib.source_tuple[1].func() # not a source

0 commit comments

Comments
 (0)