Skip to content
Merged
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
11 changes: 8 additions & 3 deletions src/coretrace_python/bundled/models/django/django_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
)


_TARGET_ONLY = ((TaintKind.REDIRECT, (0,)),)


def _sym(path: str) -> SymbolId:
return SymbolId(f"python.{path}")

Expand All @@ -107,9 +110,11 @@ class DjangoModels(ModelPlugin):
Sink(_sym("django.http.response.HttpResponse"), TaintKind.HTML),
Sink(_sym("django.template.Template"), TaintKind.HTML),
Sink(_sym("django.http.FileResponse"), TaintKind.PATH),
Sink(_sym("django.shortcuts.redirect"), TaintKind.REDIRECT),
Sink(_sym("django.http.HttpResponseRedirect"), TaintKind.REDIRECT),
Sink(_sym("django.http.HttpResponsePermanentRedirect"), TaintKind.REDIRECT),
# Only the target is a redirect: the other arguments of ``redirect`` are route
# parameters resolved through the URL configuration.
Sink(_sym("django.shortcuts.redirect"), TaintKind.REDIRECT, _TARGET_ONLY),
Sink(_sym("django.http.HttpResponseRedirect"), TaintKind.REDIRECT, _TARGET_ONLY),
Sink(_sym("django.http.HttpResponsePermanentRedirect"), TaintKind.REDIRECT, _TARGET_ONLY),
Sanitizer(_sym("django.utils.html.escape"), TaintKind.HTML),
Sanitizer(_sym("django.utils.html.conditional_escape"), TaintKind.HTML),
*(AuthorizationGuard(_sym(decorator), label) for decorator, label in _AUTHORIZATION_DECORATORS),
Expand Down
8 changes: 6 additions & 2 deletions src/coretrace_python/bundled/models/flask/flask_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
)


_TARGET_ONLY = ((TaintKind.REDIRECT, (0,)),)


def _sym(path: str) -> SymbolId:
return SymbolId(f"python.{path}")

Expand All @@ -40,8 +43,9 @@ class FlaskModels(ModelPlugin):
Sink(_sym("flask.Response"), TaintKind.HTML),
Sink(_sym("flask.Markup"), TaintKind.HTML),
Sink(_sym("flask.send_file"), TaintKind.PATH),
Sink(_sym("flask.redirect"), TaintKind.REDIRECT),
Sink(_sym("werkzeug.utils.redirect"), TaintKind.REDIRECT),
# ``redirect(location, code)``: the status code is not a target.
Sink(_sym("flask.redirect"), TaintKind.REDIRECT, _TARGET_ONLY),
Sink(_sym("werkzeug.utils.redirect"), TaintKind.REDIRECT, _TARGET_ONLY),
Sink(_sym("flask.request.files.save"), TaintKind.PATH),
Sanitizer(_sym("werkzeug.utils.secure_filename"), TaintKind.PATH),
Sanitizer(_sym("flask.escape"), TaintKind.HTML),
Expand Down
18 changes: 0 additions & 18 deletions tests/regression/expected/DjangoGoat.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,12 @@
"functions_analysed": 39
},
"findings": [
{
"file": "authentication/views.py",
"line": 33,
"rule": "open-redirect",
"function": "sign_up"
},
{
"file": "authentication/views.py",
"line": 57,
"rule": "sql-injection",
"function": "log_in"
},
{
"file": "authentication/views.py",
"line": 82,
"rule": "open-redirect",
"function": "profile_update"
},
{
"file": "djangogoat/settings.py",
"line": 24,
Expand All @@ -36,12 +24,6 @@
"rule": "hardcoded-credential",
"function": "after_all"
},
{
"file": "notes/views.py",
"line": 86,
"rule": "open-redirect",
"function": "conversation"
},
{
"file": "requirements_app.txt",
"line": 2,
Expand Down
Loading
Loading