Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

semgrep: Strengthen HTML and SQL injection checks.

Anders Kaseorga113a42e1124
diff --git a/tools/semgrep-py.yml b/tools/semgrep-py.yml
index d0ebd640ba1..d8cef8b91d0 100644
--- a/tools/semgrep-py.yml
+++ b/tools/semgrep-py.yml
@@ -135,6 +135,9 @@ rules:
pattern-either:
- pattern: markupsafe.Markup(... .format(...))
- pattern: markupsafe.Markup(f"...")
+ - pattern: markupsafe.Markup(f"..." "...")
+ - pattern: markupsafe.Markup("..." f"...")
+ - pattern: markupsafe.Markup("..." f"..." "...")
- pattern: markupsafe.Markup(... + ...)
severity: ERROR
message: "Do not write an HTML injection vulnerability please"
@@ -142,17 +145,29 @@ rules:
- id: sql-format
languages: [python]
pattern-either:
- - pattern: ... .execute("...".format(...))
- - pattern: ... .execute(f"...")
- - pattern: ... .execute(... + ...)
+ - pattern: ... .execute("...".format(...), ...)
+ - pattern: ... .execute(f"...", ...)
+ - pattern: ... .execute(f"..." "...", ...)
+ - pattern: ... .execute("..." f"...", ...)
+ - pattern: ... .execute("..." f"..." "...", ...)
+ - pattern: ... .execute(... + ..., ...)
- pattern: psycopg2.sql.SQL(... .format(...))
- pattern: psycopg2.sql.SQL(f"...")
+ - pattern: psycopg2.sql.SQL(f"..." "...")
+ - pattern: psycopg2.sql.SQL("..." f"...")
+ - pattern: psycopg2.sql.SQL("..." f"..." "...")
- pattern: psycopg2.sql.SQL(... + ...)
- pattern: django.db.migrations.RunSQL(..., "..." .format(...), ...)
- pattern: django.db.migrations.RunSQL(..., f"...", ...)
+ - pattern: django.db.migrations.RunSQL(..., f"..." "...", ...)
+ - pattern: django.db.migrations.RunSQL(..., "..." f"...", ...)
+ - pattern: django.db.migrations.RunSQL(..., "..." f"..." "...", ...)
- pattern: django.db.migrations.RunSQL(..., ... + ..., ...)
- pattern: django.db.migrations.RunSQL(..., [..., "..." .format(...), ...], ...)
- pattern: django.db.migrations.RunSQL(..., [..., f"...", ...], ...)
+ - pattern: django.db.migrations.RunSQL(..., [..., f"..." "...", ...], ...)
+ - pattern: django.db.migrations.RunSQL(..., [..., "..." f"...", ...], ...)
+ - pattern: django.db.migrations.RunSQL(..., [..., "..." f"..." "...", ...], ...)
- pattern: django.db.migrations.RunSQL(..., [..., ... + ..., ...], ...)
severity: ERROR
message: "Do not write a SQL injection vulnerability please"