-
Notifications
You must be signed in to change notification settings - Fork 6
Add YAML security rules and tests for hard-coded secret detection #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ganeshpatro321
merged 33 commits into
coderabbitai:main
from
ESS-ENN:python_requests_hardcoded-secret
Mar 26, 2025
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
bb7b8e1
removed missing-secure-java
308e947
Merge branch 'coderabbitai:main' into main
ESS-ENN 46efd55
Merge branch 'coderabbitai:main' into main
ESS-ENN 3ac0204
Merge branch 'coderabbitai:main' into main
ESS-ENN 7caba92
Merge branch 'coderabbitai:main' into main
ESS-ENN d3a2776
Merge branch 'coderabbitai:main' into main
ESS-ENN 2e86380
Merge branch 'coderabbitai:main' into main
ESS-ENN b072db7
Merge branch 'coderabbitai:main' into main
ESS-ENN 65dce29
Merge branch 'coderabbitai:main' into main
ESS-ENN 12bb3aa
httponly-false-csharp
ESS-ENN 2c5ea88
use-of-md5-digest-utils-java
ESS-ENN d3067f1
removing use-of-md5-digest-utils and httponly-false-csharp
ESS-ENN 56d4011
Merge branch 'coderabbitai:main' into main
ESS-ENN f7f1d72
Merge branch 'coderabbitai:main' into main
ESS-ENN 0d53f8e
Merge branch 'coderabbitai:main' into main
ESS-ENN b622bca
Merge branch 'coderabbitai:main' into main
ESS-ENN 67459bf
Merge branch 'coderabbitai:main' into main
ESS-ENN b8b2adb
Merge branch 'coderabbitai:main' into main
ESS-ENN 9b29d0a
Merge branch 'coderabbitai:main' into main
ESS-ENN 24510d4
Merge branch 'coderabbitai:main' into main
ESS-ENN 6c6d229
Merge remote-tracking branch 'upstream/main' into main
ESS-ENN c5f0d85
Merge branch 'main' of https://github.com/ESS-ENN/ast-grep-essentials…
ESS-ENN 4104e61
Merge branch 'coderabbitai:main' into main
ESS-ENN 36b1114
Merge remote-tracking branch 'upstream/main' into main
ESS-ENN befc6b0
Merge branch 'main' of https://github.com/ESS-ENN/ast-grep-essentials…
ESS-ENN 7bc886d
Merge branch 'coderabbitai:main' into main
ESS-ENN fc13546
Merge remote-tracking branch 'upstream/main' into main
ESS-ENN e4a1853
Merge branch 'main' of https://github.com/ESS-ENN/ast-grep-essentials…
ESS-ENN b6203b0
Merge branch 'coderabbitai:main' into main
ESS-ENN 5327545
Merge remote-tracking branch 'upstream/main' into main
ESS-ENN f59e083
Merge remote-tracking branch 'upstream/main' into main
ESS-ENN 7a29108
python-requests-hardcoded-secret-python
ESS-ENN a890bd0
python-requests-oauth-hardcoded-secret-python
ESS-ENN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
155 changes: 155 additions & 0 deletions
155
rules/python/security/python-requests-hardcoded-secret-python.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
id: python-requests-hardcoded-secret-python | ||
severity: warning | ||
language: python | ||
message: >- | ||
A secret is hard-coded in the application. Secrets stored in source | ||
code, such as credentials, identifiers, and other types of sensitive data, | ||
can be leaked and used by internal or external malicious actors. Use | ||
environment variables to securely provide credentials and other secrets or | ||
retrieve them from a secure vault or Hardware Security Module (HSM). | ||
note: >- | ||
[CWE-798] Use of Hard-coded Credentials. | ||
[REFERENCES] | ||
- https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html | ||
|
||
ast-grep-essentials: true | ||
|
||
utils: | ||
requests.auth.HTTPBasicAuth($USER,"",...): | ||
kind: call | ||
all: | ||
- has: | ||
stopBy: neighbor | ||
kind: attribute | ||
regex: ^requests.auth.HTTPBasicAuth$|^requests.auth.HTTPDigestAuth$|^requests.auth.HTTPProxyAuth$ | ||
- has: | ||
stopBy: neighbor | ||
kind: argument_list | ||
not: | ||
has: | ||
nthChild: 3 | ||
has: | ||
stopBy: neighbor | ||
kind: string | ||
nthChild: 2 | ||
has: | ||
stopBy: end | ||
kind: string_content | ||
|
||
HTTPBasicAuth($USER,"",...): | ||
kind: call | ||
all: | ||
- has: | ||
stopBy: neighbor | ||
kind: identifier | ||
regex: ^(HTTPBasicAuth)$ | ||
- has: | ||
stopBy: neighbor | ||
kind: argument_list | ||
not: | ||
has: | ||
nthChild: 3 | ||
has: | ||
stopBy: neighbor | ||
kind: string | ||
nthChild: 2 | ||
has: | ||
stopBy: end | ||
kind: string_content | ||
- any: | ||
- follows: | ||
stopBy: end | ||
kind: import_from_statement | ||
any: | ||
- pattern: from requests.auth import HTTPBasicAuth | ||
- inside: | ||
stopBy: end | ||
follows: | ||
stopBy: end | ||
kind: import_from_statement | ||
any: | ||
- pattern: from requests.auth import HTTPBasicAuth | ||
|
||
HTTPProxyAuth($USER,"",...): | ||
kind: call | ||
all: | ||
- has: | ||
stopBy: neighbor | ||
kind: identifier | ||
regex: ^(HTTPProxyAuth)$ | ||
- has: | ||
stopBy: neighbor | ||
kind: argument_list | ||
not: | ||
has: | ||
nthChild: 3 | ||
has: | ||
stopBy: neighbor | ||
kind: string | ||
nthChild: 2 | ||
has: | ||
stopBy: end | ||
kind: string_content | ||
- any: | ||
- follows: | ||
stopBy: end | ||
kind: import_from_statement | ||
any: | ||
- pattern: from requests.auth import HTTPProxyAuth | ||
- inside: | ||
stopBy: end | ||
follows: | ||
stopBy: end | ||
kind: import_from_statement | ||
any: | ||
- pattern: from requests.auth import HTTPProxyAuth | ||
|
||
HTTPDigestAuth($USER,"",...): | ||
kind: call | ||
all: | ||
- has: | ||
stopBy: neighbor | ||
kind: identifier | ||
regex: ^(HTTPDigestAuth)$ | ||
- has: | ||
stopBy: neighbor | ||
kind: argument_list | ||
not: | ||
has: | ||
nthChild: 3 | ||
has: | ||
stopBy: neighbor | ||
kind: string | ||
nthChild: 2 | ||
has: | ||
stopBy: end | ||
kind: string_content | ||
- any: | ||
- follows: | ||
stopBy: end | ||
kind: import_from_statement | ||
any: | ||
- pattern: from requests.auth import HTTPProxyAuth | ||
- inside: | ||
stopBy: end | ||
follows: | ||
stopBy: end | ||
kind: import_from_statement | ||
any: | ||
- pattern: from requests.auth import HTTPDigestAuth | ||
|
||
rule: | ||
kind: call | ||
any: | ||
- matches: HTTPProxyAuth($USER,"",...) | ||
- matches: HTTPDigestAuth($USER,"",...) | ||
- matches: HTTPBasicAuth($USER,"",...) | ||
- matches: requests.auth.HTTPBasicAuth($USER,"",...) | ||
not: | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: ERROR | ||
- inside: | ||
stopBy: end | ||
kind: ERROR |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.