This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rules: | |
| - id: identical-is-comparison | |
| pattern: $S is $S | |
| message: "Found identical comparison using is" | |
| languages: [python] | |
| severity: ERROR | |
| - id: none-comparison-ok | |
| pattern: $S is None | |
| message: "is None is OK" | |
| languages: [python] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rules: | |
| - id: return-inside-finally | |
| pattern: | | |
| try: | |
| $A | |
| except $B: | |
| $C | |
| finally: | |
| $X | |
| return $Y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rules: | |
| - id: django-number-fields | |
| patterns: | |
| - pattern-inside: | | |
| class $M(...): | |
| ... | |
| - pattern-either: | |
| - pattern: $F = django.db.models.DecimalField(...) | |
| - pattern: $F = django.db.models.FloatField(...) | |
| message: "Found a fractional number field. Variable name: $F" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rules: | |
| - id: use-decimalfield-for-money | |
| patterns: | |
| - pattern-inside: | | |
| class $M(...): | |
| ... | |
| - pattern: $F = django.db.models.FloatField(...) | |
| - pattern-where-python: "'price' in vars['$F'] or 'amount' in vars['$F'] or 'subtotal' in vars['$F'] or 'donation' in vars['$F'] or 'fee' in vars['$F'] or 'salaray' in vars['$F'] or 'precio' in vars['$F']" | |
| message: "Found a FloatField used for variable $F. Use DecimalField for currency fields to avoid float-rounding errors." | |
| languages: [python] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rules: | |
| - id: avoid-raw-sql | |
| patterns: | |
| - pattern-either: | |
| - pattern: $MODEL.objects.raw($QUERY, ...) | |
| - pattern: django.db.models.expressions.RawSQL(...) | |
| message: "You should be very careful whenever you write raw SQL. Consider using Django ORM before raw SQL. See https://docs.djangoproject.com/en/3.0/topics/db/sql/#passing-parameters-into-raw" | |
| languages: [python] | |
| severity: ERROR | |
| - id: no-null-string-field |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rules: | |
| - id: handler-assignment-from-multiple-sources | |
| patterns: | |
| - pattern-inside: | | |
| func $HANDLER(..., $R *http.Request, ...) { | |
| ... | |
| } | |
| - pattern-not: | | |
| $VAR = true | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rules: | |
| - id: password-empty-string | |
| patterns: | |
| - pattern-either: | |
| - pattern: | | |
| $MODEL.set_password($EMPTY) | |
| ... | |
| $MODEL.save() | |
| - pattern: | | |
| $VAR = $EMPTY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rules: | |
| - id: hidden-goroutine | |
| patterns: | |
| - pattern-not: | | |
| func $FUNC(...) { | |
| go func() { | |
| ... | |
| }(...) | |
| $MORE | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rules: | |
| - id: django-request-sink-attribute | |
| patterns: | |
| - pattern-inside: | | |
| def $F(...): | |
| ... | |
| - pattern-either: | |
| - pattern: | | |
| $V = request.$X | |
| ... |
OlderNewer