From fd21b2841ff287333b788c6bb0e1c3fc4e7ed0f3 Mon Sep 17 00:00:00 2001 From: elsapet Date: Wed, 15 May 2024 15:32:52 +0200 Subject: [PATCH] fix: use shared import rule --- rules/python/lang/insecure_cookie.yml | 27 ++++++++++---------- rules/python/shared/django/http_response.yml | 15 ++++++++--- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/rules/python/lang/insecure_cookie.yml b/rules/python/lang/insecure_cookie.yml index c1ff33d5..18a40a97 100644 --- a/rules/python/lang/insecure_cookie.yml +++ b/rules/python/lang/insecure_cookie.yml @@ -1,3 +1,5 @@ +imports: + - python_shared_lang_import2 patterns: - pattern: | $['secure'] = $ @@ -31,20 +33,17 @@ auxiliary: - pattern: $ filters: - variable: COOKIE_CLASS - regex: \A(http\.)?(cookies\.)?(Simple|Base)Cookie\z - - pattern: from http.cookies import $ - filters: - - variable: COOKIE_CLASS - values: - - SimpleCookie - - BaseCookie - - pattern: from http.cookies import $ 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 diff --git a/rules/python/shared/django/http_response.yml b/rules/python/shared/django/http_response.yml index ebd7be9f..e96373ff 100644 --- a/rules/python/shared/django/http_response.yml +++ b/rules/python/shared/django/http_response.yml @@ -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: $ 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