Skip to content

Commit

Permalink
fix: use shared import rule
Browse files Browse the repository at this point in the history
  • Loading branch information
elsapet committed May 16, 2024
1 parent 6fb766a commit fd21b28
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
27 changes: 13 additions & 14 deletions rules/python/lang/insecure_cookie.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
imports:
- python_shared_lang_import2
patterns:
- pattern: |
$<COOKIE_SESSION>['secure'] = $<FALSE>
Expand Down Expand Up @@ -31,20 +33,17 @@ auxiliary:
- pattern: $<COOKIE_CLASS>
filters:
- variable: COOKIE_CLASS
regex: \A(http\.)?(cookies\.)?(Simple|Base)Cookie\z
- pattern: from http.cookies import $<COOKIE_CLASS>
filters:
- variable: COOKIE_CLASS
values:
- SimpleCookie
- BaseCookie
- pattern: from http.cookies import $<COOKIE_CLASS> as $<!>$<_>
filters:
- variable: COOKIE_CLASS
values:
- SimpleCookie
- BaseCookie

detection: python_shared_lang_import2
scope: cursor
filters:
- variable: MODULE1
values: [http]
- variable: MODULE2
values: [cookies]
- variable: NAME
values:
- BaseCookie
- SimpleCookie
languages:
- python
severity: medium
Expand Down
15 changes: 11 additions & 4 deletions rules/python/shared/django/http_response.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
type: shared
imports:
- python_shared_lang_import2
languages:
- python
patterns:
- HttpResponse
- from django.http import $<!>HttpResponse
- from django.http import HttpResponse as $<!>$<_>
- pattern: $<HTTP_RESPONSE>
filters:
- variable: HTTP_RESPONSE
regex: \A(django\.)?(http\.)?HttpResponse\z
detection: python_shared_lang_import2
scope: cursor
filters:
- variable: MODULE1
values: [django]
- variable: MODULE2
values: [http]
- variable: NAME
values: [HttpResponse]
metadata:
description: "Python Django HTTP Response."
id: python_shared_django_http_response

0 comments on commit fd21b28

Please sign in to comment.