Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions codeql_issue_testruleset2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
from flask import request, Flask
import re


# Clear-text logging of sensitive information
# did not trigger an alert in codeQL somehow...
print(f"[INFO] Environment: {os.environ}")

# attempt to trigger a warning in codeQL
# Regular expression injection
@app.route("/direct")
def direct():
unsafe_pattern = request.args["pattern"]
re.search(unsafe_pattern, "")

Check failure

Code scanning / CodeQL

Regular expression injection

This regular expression depends on a [user-provided value](1) and is executed by [re.search](2).


@app.route("/compile")
def compile():
unsafe_pattern = request.args["pattern"]
compiled_pattern = re.compile(unsafe_pattern)

Check failure

Code scanning / CodeQL

Regular expression injection

This regular expression depends on a [user-provided value](1) and is executed by [re.search](2).
compiled_pattern.search("")
7 changes: 0 additions & 7 deletions regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,3 @@
def direct():
unsafe_pattern = request.args["pattern"]
re.search(unsafe_pattern, "")


@app.route("/compile")
def compile():
unsafe_pattern = request.args["pattern"]
compiled_pattern = re.compile(unsafe_pattern)
compiled_pattern.search("")