Skip to content

Commit 5901478

Browse files
committed
Python: Fix DataflowQueryTest
You're only allowed to have `result=OK` if there is a sink on that line...
1 parent cd596f5 commit 5901478

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
missingAnnotationOnSink
2+
testFailures
3+
failures

python/ql/test/experimental/query-tests/Security/CWE-409/test.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async def bomb(file_path):
1515
a = myfile.readline()
1616

1717
with zipfile.ZipFile(file_path) as myzip:
18-
with myzip.open('ZZ', mode="w") as myfile: # $result=OK
18+
with myzip.open('ZZ', mode="w") as myfile: # $ SPURIOUS: result=BAD
1919
myfile.write(b"tmpppp")
2020

2121
zipfile.ZipFile(file_path).read("aFileNameInTheZipFile") # $ result=BAD
@@ -26,9 +26,9 @@ async def bomb(file_path):
2626
tarfile.TarFile.gzopen(file_path).extractall() # $ result=BAD
2727
tarfile.TarFile.open(file_path).extractfile("file1.txt") # $ result=BAD
2828

29-
tarfile.open(file_path, mode="w") # $result=OK
30-
tarfile.TarFile.gzopen(file_path, mode="w") # $result=OK
31-
tarfile.TarFile.open(file_path, mode="r:") # $ result=BAD
29+
tarfile.open(file_path, mode="w") # ok, writing
30+
tarfile.TarFile.gzopen(file_path, mode="w") # ok, writing
31+
tarfile.TarFile.open(file_path, mode="r:") # potential problem, depending on usage
3232
import shutil
3333

3434
shutil.unpack_archive(file_path) # $ result=BAD
@@ -63,14 +63,14 @@ async def bomb(file_path):
6363
pandas.read_xml(path_or_buffer=file_path, compression='gzip') # $ result=BAD
6464

6565
# no compression no DOS
66-
pandas.read_table(file_path, compression='tar') # $result=OK
67-
pandas.read_xml(file_path, compression='tar') # $result=OK
68-
69-
pandas.read_csv(filepath_or_buffer=file_path, compression='tar') # $result=OK
70-
pandas.read_json(file_path, compression='tar') # $result=OK
71-
pandas.read_sas(file_path, compression='tar') # $result=OK
72-
pandas.read_stata(filepath_or_buffer=file_path, compression='tar') # $result=OK
73-
pandas.read_table(file_path, compression='tar') # $result=OK
74-
pandas.read_xml(path_or_buffer=file_path, compression='tar') # $result=OK
66+
pandas.read_table(file_path, compression='tar')
67+
pandas.read_xml(file_path, compression='tar')
68+
69+
pandas.read_csv(filepath_or_buffer=file_path, compression='tar')
70+
pandas.read_json(file_path, compression='tar')
71+
pandas.read_sas(file_path, compression='tar')
72+
pandas.read_stata(filepath_or_buffer=file_path, compression='tar')
73+
pandas.read_table(file_path, compression='tar')
74+
pandas.read_xml(path_or_buffer=file_path, compression='tar')
7575

7676
return {"message": "bomb"}

0 commit comments

Comments
 (0)