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: Enforce use of get_object_from_key for Confirmation fetching.

Mateusz Mandera72e5664031e5
diff --git a/tools/semgrep.yml b/tools/semgrep.yml
index d0dc16cc5df..5e04f673460 100644
--- a/tools/semgrep.yml
+++ b/tools/semgrep.yml
@@ -166,3 +166,18 @@ rules:
...
message: "Use change_user_is_active to mutate user_profile.is_active"
severity: ERROR
+
+ - id: confirmation-object-get
+ languages: [python]
+ patterns:
+ - pattern-either:
+ - pattern: Confirmation.objects.get(...)
+ - pattern: Confirmation.objects.filter(..., confirmation_key=..., ...)
+ - pattern-not-inside: |
+ def get_object_from_key(...):
+ ...
+ paths:
+ exclude:
+ - zerver/tests/
+ message: "Do not fetch a Confirmation object directly, use get_object_from_key instead"
+ severity: ERROR