mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
copy, pop, get, getitem, setdefault
Also add read steps to taint tracking.
Reading from a tainted collection can be done in two situations:
1. There is an acces path
In this case a read step (possibly from a flow summary)
gives rise to a taint step.
2. There is no access path
In this case an explicit taint step (possibly via a flow
summary) should exist.
50 lines
796 B
Python
50 lines
796 B
Python
import os.path
|
|
|
|
from flask import Flask, request
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
def source():
|
|
return request.args.get("path", "")
|
|
|
|
|
|
def normalize(x):
|
|
return os.path.normpath(x)
|
|
|
|
|
|
@app.route("/path")
|
|
def simple():
|
|
x = source()
|
|
open(x) # $result=BAD
|
|
|
|
|
|
@app.route("/path")
|
|
def normalization():
|
|
x = source()
|
|
y = normalize(x)
|
|
open(y) # $result=BAD
|
|
|
|
|
|
@app.route("/path")
|
|
def check():
|
|
x = source()
|
|
if x.startswith("subfolder/"):
|
|
open(x) # $result=BAD
|
|
|
|
|
|
@app.route("/path")
|
|
def normalize_then_check():
|
|
x = source()
|
|
y = normalize(x)
|
|
if y.startswith("subfolder/"):
|
|
open(y) # $result=OK
|
|
|
|
|
|
@app.route("/path")
|
|
def check_then_normalize():
|
|
x = source()
|
|
if x.startswith("subfolder/"):
|
|
y = normalize(x)
|
|
open(y) # $result=BAD
|