Skip to content

Commit dbde99d

Browse files
committed
Python: Add test cases.
1 parent cb6276e commit dbde99d

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

python/ql/test/query-tests/Security/CWE-116-BadTagFilter/tst.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
re.compile(r"""<!--.*-->""", re.IGNORECASE | re.DOTALL), # OK - we don't care regexps that only match comments
88
re.compile(r"""<!--.*--!?>""", re.IGNORECASE | re.DOTALL), # OK
99
re.compile(r"""<!--.*--!?>""", re.IGNORECASE), # NOT OK, does not match newlines
10-
11-
10+
re.compile(r"""(?is)<!--.*--!?>"""), # OK
11+
re.compile(r"""(?i)<!--.*--!?>"""), # NOT OK, does not match newlines [NOT DETECTED]
1212
re.compile(r"""<script.*?>(.|\s)*?<\/script[^>]*>""", re.IGNORECASE), # NOT OK - doesn't match inside the script tag
1313
re.compile(r"""<script[^>]*?>.*?<\/script[^>]*>""", re.IGNORECASE), # NOT OK - doesn't match newlines inside the content
1414
re.compile(r"""<script(\s|\w|=|")*?>.*?<\/script[^>]*>""", re.IGNORECASE | re.DOTALL), # NOT OK - does not match single quotes for attribute values

python/ql/test/query-tests/Security/CWE-730-ReDoS/ReDoS.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,4 @@
105105
| redos.py:391:15:391:25 | (\\u0061\|a)* | This part of the regular expression may cause exponential backtracking on strings starting with 'X' and containing many repetitions of 'a'. |
106106
| unittests.py:5:17:5:23 | (\u00c6\|\\\u00c6)+ | This part of the regular expression may cause exponential backtracking on strings starting with 'X' and containing many repetitions of '\u00c6'. |
107107
| unittests.py:9:16:9:24 | (?:.\|\\n)* | This part of the regular expression may cause exponential backtracking on strings containing many repetitions of '\\n'. |
108+
| unittests.py:11:20:11:28 | (?:.\|\\n)* | This part of the regular expression may cause exponential backtracking on strings containing many repetitions of '\\n'. |

python/ql/test/query-tests/Security/CWE-730-ReDoS/unittests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
# Treatment of line breaks
88
re.compile(r'(?:.|\n)*b') # No ReDoS.
99
re.compile(r'(?:.|\n)*b', re.DOTALL) # Has ReDoS.
10+
re.compile(r'(?i)(?:.|\n)*b') # No ReDoS.
11+
re.compile(r'(?s)(?:.|\n)*b') # Has ReDoS.
12+
re.compile(r'(?is)(?:.|\n)*b') # Has ReDoS. [NOT DETECTED]

0 commit comments

Comments
 (0)