Skip to content

Commit 0b3f28f

Browse files
yoffCopilot
andcommitted
Python: drop MISSING: keyword from inline annotations that now match
After the dataflow flip to the new shared CFG + SSA, several inline test annotations of the form `# $ MISSING:<tag>` are no longer accurate: the new dataflow now produces the documented result, and the test suite was flagging this with `Fixed missing result: <tag>` entries in `.expected` files. Per the inline-expectation convention, the `MISSING:` keyword should be dropped (so the annotation becomes a regular positive assertion) rather than blessing the `.expected` to absorb the `Fixed missing` diagnostic. Affected: - `experimental/library-tests/CallGraph-type-annotations/type_annotations.py:29` (`tt=Foo.method`) - `experimental/library-tests/CallGraph/code/conditional_in_argument.py:18` (`tt=X.bar`) - `experimental/library-tests/CallGraph/code/funky_regression.py:15` (`tt=Wat.f2`) - `library-tests/frameworks/lxml/taint_test.py:83` (`tainted`) - `query-tests/Resources/FileNotAlwaysClosed/resources_test.py:49,141,237` (`Alert`) The `inline-taint-test-demo/taint_test.py:41` case is intentionally left in place: that file is a meta-test demonstrating the inline-expectation framework's behaviour when both `# $ tainted` and `MISSING: tainted` are attached to the same line. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3f9c603 commit 0b3f28f

9 files changed

Lines changed: 7 additions & 14 deletions

File tree

python/ql/test/experimental/library-tests/CallGraph-type-annotations/InlineCallGraphTest.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
testFailures
22
| type_annotations.py:6:16:6:32 | Comment # $ tt=Foo.method | Missing result: tt=Foo.method |
33
| type_annotations.py:16:16:16:32 | Comment # $ tt=Foo.method | Missing result: tt=Foo.method |
4-
| type_annotations.py:29:5:29:14 | Attribute() | Fixed missing result: tt=Foo.method |
54
debug_callableNotUnique
65
pointsTo_found_typeTracker_notFound
76
typeTracker_found_pointsTo_notFound

python/ql/test/experimental/library-tests/CallGraph-type-annotations/type_annotations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_variable_annotation():
2626
x = eval("Foo()")
2727
x : Foo
2828
# Currently fails because there is no flow from the class definition to the type annotation.
29-
x.method() # $ MISSING: tt=Foo.method
29+
x.method() # $ tt=Foo.method
3030

3131
def test_no_variable_annotation():
3232
x = eval("Foo()")

python/ql/test/experimental/library-tests/CallGraph/InlineCallGraphTest.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
testFailures
2-
| code/conditional_in_argument.py:18:5:18:11 | Attribute() | Fixed missing result: tt=X.bar |
3-
| code/funky_regression.py:15:9:15:17 | Attribute() | Fixed missing result: tt=Wat.f2 |
42
debug_callableNotUnique
53
pointsTo_found_typeTracker_notFound
64
| code/class_attr_assign.py:10:9:10:27 | Attribute() | my_func |

python/ql/test/experimental/library-tests/CallGraph/code/conditional_in_argument.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def func(cond=True):
1515

1616
# the conditional in the argument makes us stop tracking the class instance :|
1717
x.foo(1 if cond else 0) # $ pt,tt=X.foo
18-
x.bar() # $ pt=X.bar MISSING: tt=X.bar
18+
x.bar() # $ pt=X.bar tt=X.bar
1919

2020

2121
func() # $ pt,tt=func

python/ql/test/experimental/library-tests/CallGraph/code/funky_regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def func(self, foo):
1212
except Exception as e:
1313
raise e
1414

15-
self.f2() # $ pt=Wat.f2 MISSING: tt=Wat.f2
15+
self.f2() # $ pt=Wat.f2 tt=Wat.f2
1616

1717

1818
# ==============================================================================

python/ql/test/library-tests/frameworks/lxml/InlineTaintTest.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ argumentToEnsureNotTaintedNotMarkedAsSpurious
22
untaintedArgumentToEnsureTaintedNotMarkedAsMissing
33
| taint_test.py:133:13:133:35 | taint_test.py:133 | ERROR, you should add `# $ MISSING: tainted` annotation | tree_arg.getroot().text |
44
testFailures
5-
| taint_test.py:83:13:83:19 | ch.text | Fixed missing result: tainted |
65
| taint_test.py:133:37:133:82 | Comment # $ tainted # Type tracking from the type hint | Missing result: tainted |

python/ql/test/library-tests/frameworks/lxml/taint_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test():
8080
for ch in elem:
8181
ensure_tainted(
8282
ch, # $ tainted
83-
ch.text # $ MISSING: tainted # API node getASubscript() appears to not consider things like for loops
83+
ch.text # $ tainted
8484
)
8585

8686
buf = io.StringIO(src)

python/ql/test/query-tests/Resources/FileNotAlwaysClosed/FileNotAlwaysClosed.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ testFailures
3030
| resources_test.py:20:10:20:25 | File may not be closed if $@ raises an exception. | Unexpected result: Alert |
3131
| resources_test.py:30:14:30:29 | File may not be closed if $@ raises an exception. | Unexpected result: Alert |
3232
| resources_test.py:39:14:39:29 | File may not be closed if $@ raises an exception. | Unexpected result: Alert |
33-
| resources_test.py:49:14:49:29 | File may not be closed if $@ raises an exception. | Fixed missing result: Alert |
3433
| resources_test.py:58:14:58:29 | File may not be closed if $@ raises an exception. | Unexpected result: Alert |
3534
| resources_test.py:69:11:69:26 | File may not be closed if $@ raises an exception. | Unexpected result: Alert |
3635
| resources_test.py:79:11:79:26 | File may not be closed if $@ raises an exception. | Unexpected result: Alert |
3736
| resources_test.py:91:11:91:26 | File may not be closed if $@ raises an exception. | Unexpected result: Alert |
38-
| resources_test.py:141:11:141:26 | File may not be closed if $@ raises an exception. | Fixed missing result: Alert |
3937
| resources_test.py:182:15:182:54 | File may not be closed if $@ raises an exception. | Unexpected result: Alert |
4038
| resources_test.py:225:11:225:26 | File may not be closed if $@ raises an exception. | Unexpected result: Alert |
41-
| resources_test.py:237:11:237:26 | File may not be closed if $@ raises an exception. | Fixed missing result: Alert |
4239
| resources_test.py:252:11:252:25 | File may not be closed if $@ raises an exception. | Unexpected result: Alert |
4340
| resources_test.py:275:10:275:35 | File may not be closed if $@ raises an exception. | Unexpected result: Alert |

python/ql/test/query-tests/Resources/FileNotAlwaysClosed/resources_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def closed7():
4646
def not_closed8():
4747
f8 = None
4848
try:
49-
f8 = open("filename") # $ MISSING:Alert # not closed on exception
49+
f8 = open("filename") # $ Alert # not closed on exception
5050
f8.write("Error could occur")
5151
finally:
5252
if f8 is None: # We don't precisely consider this condition, so this result is MISSING. However, this seems uncommon.
@@ -138,7 +138,7 @@ def may_raise():
138138

139139
#Not handling all exceptions, but we'll tolerate the false negative
140140
def not_closed17():
141-
f17 = open("filename") # $ MISSING:Alert # not closed on exception
141+
f17 = open("filename") # $ Alert # not closed on exception
142142
try:
143143
f17.write("IOError could occur")
144144
f17.write("IOError could occur")
@@ -234,7 +234,7 @@ def closed21(path):
234234

235235

236236
def not_closed22(path):
237-
f22 = open(path, "wb") # $ MISSING:Alert # not closed on exception
237+
f22 = open(path, "wb") # $ Alert # not closed on exception
238238
try:
239239
f22.write(b"foo")
240240
may_raise()

0 commit comments

Comments
 (0)