diff --git a/python/django/security/django-no-csrf-token.html b/python/django/security/django-no-csrf-token.html index 5d06d2a24e..6f888ae445 100644 --- a/python/django/security/django-no-csrf-token.html +++ b/python/django/security/django-no-csrf-token.html @@ -10,6 +10,34 @@ + +
+ +
+ + +
+
+ {% csrf_token %} + + +
+
+ + +
+
+ {% csrf_token %} + + +
+ +
+ + +
+
+
@@ -97,3 +125,49 @@
+ + +
+
+ {% csrf_token %} +
+ {% if x %} +
+ {{ y }} +
+ {% endif %} +
+
+ + +
+
+
+ + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
diff --git a/python/django/security/django-no-csrf-token.yaml b/python/django/security/django-no-csrf-token.yaml index 174d640029..55defde6e6 100644 --- a/python/django/security/django-no-csrf-token.yaml +++ b/python/django/security/django-no-csrf-token.yaml @@ -14,6 +14,11 @@ rules: regex: (?i)(post|put|delete|patch) - pattern-not-inside: "...{% csrf_token %}..." - pattern-not-inside: "...{{ $VAR.csrf_token }}..." + options: + # the default limit of 10 newlines per ellipsis is smaller than a realistic + # form body, which both hides the csrf_token exemption and stops the rule + # from matching longer forms at all + generic_ellipsis_max_span: 50 message: Manually-created forms in django templates should specify a csrf_token to prevent CSRF attacks. languages: [generic] severity: WARNING