Skip to content

Commit

Permalink
fix: sanitize datatype detections
Browse files Browse the repository at this point in the history
  • Loading branch information
didroe committed Oct 17, 2023
1 parent 00a3779 commit 242a970
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 54 deletions.
4 changes: 3 additions & 1 deletion rules/php/lang/cookies.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
imports:
- php_shared_lang_datatype
patterns:
- pattern: |
$<FUNCTION>($<_>, $<DATA_TYPE>$<...>)
Expand All @@ -7,7 +9,7 @@ patterns:
- setcookie
- setrawcookie
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
languages:
- php
Expand Down
6 changes: 4 additions & 2 deletions rules/php/lang/exception.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
imports:
- php_shared_lang_datatype
patterns:
- pattern: |
throw $<DATA_TYPE>;
filters:
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<FUNCTION>($<DATA_TYPE>)
filters:
Expand All @@ -12,7 +14,7 @@ patterns:
- die
- exit
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
languages:
- php
Expand Down
4 changes: 3 additions & 1 deletion rules/php/lang/file_generation.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
imports:
- php_shared_lang_datatype
languages:
- php
patterns:
Expand All @@ -10,7 +12,7 @@ patterns:
- fwrite
- file_put_contents
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
metadata:
description: "Sensitive data detected as part of a dynamic file generation."
Expand Down
49 changes: 25 additions & 24 deletions rules/php/lang/http_url_using_sensitive_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ languages:
imports:
- php_shared_lang_instance
- php_shared_lang_http_url
- php_shared_lang_datatype
patterns:
- pattern: $<HTTP_URL>;
filters:
Expand All @@ -11,7 +12,7 @@ patterns:
scope: cursor_strict
filters:
- variable: URL
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<GUZZLE>->$<METHOD>($<_>, $<_>, $<OPTIONS>)
filters:
Expand Down Expand Up @@ -62,7 +63,7 @@ patterns:
- variable: CLASS
regex: \A(Http\\Message\\Authentication\\)?QueryParam\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<CLIENT>->setParameterGet($<DATA_TYPE>)
filters:
Expand All @@ -73,7 +74,7 @@ patterns:
- variable: CLASS
regex: \A((Laminas|Zend)\\Http\\)?Client\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<QUERY>->$<METHOD>($<...>$<DATA_TYPE>$<...>)
filters:
Expand All @@ -85,15 +86,15 @@ patterns:
- set
- offsetSet
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<QUERY>->$<_> = $<DATA_TYPE>
filters:
- variable: QUERY
detection: php_lang_http_url_using_sensitive_data_laminas_query
scope: cursor
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<CLASS>::$<METHOD>($<_>, $<DATA_TYPE>)
filters:
Expand All @@ -104,7 +105,7 @@ patterns:
- head
- get
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<HTTP>->$<METHOD>($<_>, $<DATA_TYPE>)
filters:
Expand All @@ -116,22 +117,22 @@ patterns:
- head
- get
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<CLASS>::withQueryParameters($<DATA_TYPE>)
filters:
- variable: CLASS
regex: \A(Illuminate\\Support\\Facades\\)?Http\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<HTTP>->withQueryParameters($<DATA_TYPE>)
filters:
- variable: HTTP
detection: php_lang_http_url_using_sensitive_data_laravel_http
scope: cursor
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<CLASS>::send($<_>, $<_>, $<OPTIONS>)
filters:
Expand Down Expand Up @@ -162,21 +163,21 @@ patterns:
- addQuery
- setQuery
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<CLASS>::request($<_>, $<_>, $<DATA_TYPE>)
filters:
- variable: CLASS
regex: \A(WpOrg\\Requests\\)?Requests\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<CLASS>::request($<_>, $<_>, $<DATA_TYPE>, $<TYPE>$<...>)
filters:
- variable: CLASS
regex: \A(WpOrg\\Requests\\)?Requests\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- variable: TYPE
detection: php_lang_http_url_using_sensitive_data_requests_type
Expand Down Expand Up @@ -206,7 +207,7 @@ patterns:
- variable: CLASS
regex: \A(WpOrg\\Requests\\)?Session\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<SESSION>->request($<_>, $<_>, $<DATA_TYPE>)
filters:
Expand All @@ -217,7 +218,7 @@ patterns:
- variable: CLASS
regex: \A(WpOrg\\Requests\\)?Session\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<SESSION>->request($<_>, $<_>, $<DATA_TYPE>, $<TYPE>$<...>)
filters:
Expand All @@ -228,7 +229,7 @@ patterns:
- variable: CLASS
regex: \A(WpOrg\\Requests\\)?Session\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- variable: TYPE
detection: php_lang_http_url_using_sensitive_data_requests_type
Expand Down Expand Up @@ -273,7 +274,7 @@ patterns:
- put
- delete
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
# symfony
- pattern: $<_>->request($<_>, $<_>, $<OPTIONS>$<...>)
Expand All @@ -286,15 +287,15 @@ patterns:
- variable: CLASS
regex: \A(Unirest\\)?Request\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: |
$<CLASS>::get(parameters: $<DATA_TYPE>)
filters:
- variable: CLASS
regex: \A(Unirest\\)?Request\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<CLASS>::send($<TYPE>, $<_>, $<_>, $<DATA_TYPE>$<...>)
filters:
Expand All @@ -303,7 +304,7 @@ patterns:
- variable: CLASS
regex: \A(Unirest\\)?Request\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: $<SEND>;
filters:
Expand All @@ -319,7 +320,7 @@ auxiliary:
- pattern: array('query' => $<DATA_TYPE>)
filters:
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- id: php_lang_http_url_using_sensitive_data_laminas_query
patterns:
Expand Down Expand Up @@ -373,7 +374,7 @@ auxiliary:
- pattern: array('data' => $<DATA_TYPE>)
filters:
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- id: php_lang_http_url_using_sensitive_data_requests_options_type
patterns:
Expand All @@ -393,7 +394,7 @@ auxiliary:
- variable: CLASS
regex: \A(WpOrg\\Requests\\)?Requests\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- id: php_lang_http_url_using_sensitive_data_requests_request_type
patterns:
Expand All @@ -419,7 +420,7 @@ auxiliary:
- variable: CLASS
regex: \A(WpOrg\\Requests\\)?Session\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- id: php_lang_http_url_using_sensitive_data_requests_session_request_type
patterns:
Expand All @@ -441,7 +442,7 @@ auxiliary:
- variable: CLASS
regex: \A(Unirest\\)?Request\z
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- id: php_lang_http_url_using_sensitive_data_unirest_send_type
patterns:
Expand Down
4 changes: 3 additions & 1 deletion rules/php/lang/jwt.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
imports:
- php_shared_lang_datatype
patterns:
- pattern: |
JWT::encode($<DATA_TYPE>$<...>)
filters:
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
languages:
- php
Expand Down
4 changes: 3 additions & 1 deletion rules/php/lang/logger.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
imports:
- php_shared_lang_datatype
patterns:
- pattern: |
error_log($<...>$<DATA_TYPE>$<...>)
filters:
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
languages:
- php
Expand Down
6 changes: 4 additions & 2 deletions rules/php/lang/weak_hash_md5.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
imports:
- php_shared_lang_datatype
patterns:
- pattern: |
md5($<DATA_TYPE>$<...>)
filters:
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: |
hash($<ALGORITHM>, $<DATA_TYPE>$<...>)
filters:
- variable: ALGORITHM
detection: php_lang_weak_hash_md5_algo
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
auxiliary:
- id: php_lang_weak_hash_md5_algo
Expand Down
6 changes: 4 additions & 2 deletions rules/php/lang/weak_hash_sha1.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
imports:
- php_shared_lang_datatype
patterns:
- pattern: |
sha1($<DATA_TYPE>$<...>)
filters:
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: |
hash($<ALGORITHM>, $<DATA_TYPE>$<...>)
filters:
- variable: ALGORITHM
detection: php_lang_weak_hash_sha1_algo
- variable: DATA_TYPE
detection: datatype
detection: php_shared_lang_datatype
scope: result
auxiliary:
- id: php_lang_weak_hash_sha1_algo
Expand Down
6 changes: 4 additions & 2 deletions rules/php/lang/weak_password_hash_md5.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
imports:
- php_shared_lang_datatype
patterns:
- pattern: |
md5($<PASSWORD>$<...>)
filters:
- variable: PASSWORD
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: |
hash($<ALGORITHM>, $<PASSWORD>$<...>)
filters:
- variable: ALGORITHM
detection: php_lang_weak_password_hash_md5_algo
- variable: PASSWORD
detection: datatype
detection: php_shared_lang_datatype
scope: result
auxiliary:
- id: php_lang_weak_password_hash_md5_algo
Expand Down
6 changes: 4 additions & 2 deletions rules/php/lang/weak_password_hash_sha1.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
imports:
- php_shared_lang_datatype
patterns:
- pattern: |
sha1($<PASSWORD>$<...>)
filters:
- variable: PASSWORD
detection: datatype
detection: php_shared_lang_datatype
scope: result
- pattern: |
hash($<ALGO>, $<PASSWORD>$<...>)
filters:
- variable: ALGO
detection: php_lang_weak_password_hash_sha1_algo
- variable: PASSWORD
detection: datatype
detection: php_shared_lang_datatype
scope: result
auxiliary:
- id: php_lang_weak_password_hash_sha1_algo
Expand Down
Loading

0 comments on commit 242a970

Please sign in to comment.