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

Skip to content

Commit c127b10

Browse files
committed
Create re.compile().ReMethod test
1 parent be09ffe commit c127b10

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

python/ql/src/experimental/Security/CWE-730/re_bad.py renamed to python/ql/src/experimental/Security/CWE-730/unit_tests/re_bad.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# move outside test folder
2+
13
from flask import request, Flask
24
import re
35

@@ -7,16 +9,18 @@
79
@app.route("/direct")
810
def direct():
911
pattern = request.args['pattern']
10-
1112
re.search(pattern, "")
1213

1314

1415
@app.route("/compile")
1516
def compile():
1617
pattern = re.compile(request.args['pattern'])
17-
1818
pattern.search("")
1919

2020

21+
@app.route("/compile_direct")
22+
def compile_direct():
23+
re.compile(request.args['pattern']).search("")
24+
2125
# if __name__ == "__main__":
2226
# app.run(debug=True)

python/ql/src/experimental/Security/CWE-730/re_good.py renamed to python/ql/src/experimental/Security/CWE-730/unit_tests/re_good.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# move outside test folder
2+
13
from flask import request, Flask
24
import re
35

@@ -7,16 +9,19 @@
79
@app.route("/direct")
810
def direct():
911
pattern = re.escape(request.args['pattern'])
10-
1112
re.search(pattern, "")
1213

1314

1415
@app.route("/compile")
1516
def compile():
1617
pattern = re.compile(re.escape(request.args['pattern']))
17-
1818
pattern.search("")
1919

2020

21+
@app.route("/compile_direct")
22+
def compile_direct():
23+
re.compile(re.escape(request.args['pattern'])).search("")
24+
25+
2126
# if __name__ == "__main__":
2227
# app.run(debug=True)

0 commit comments

Comments
 (0)