-
Notifications
You must be signed in to change notification settings - Fork 7
Two python rules 16Oct2024 #31
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
petrisorcoderabbit
merged 4 commits into
coderabbitai:main
from
ESS-ENN:two-python-rules-16Oct2024
Oct 21, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9ee1cb5
python-ldap3-empty-password-python
ESS-ENN 6cf05f7
openai-hardcoded-secret-password-python
ESS-ENN 336a91d
Merge branch 'main' into two-python-rules-16Oct2024
ESS-ENN 0a82e33
Merge branch 'main' into two-python-rules-16Oct2024
petrisorcoderabbit 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
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,24 @@ | ||
id: openai-hardcoded-secret-password-python | ||
language: python | ||
severity: warning | ||
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 | ||
[OWASP A07:2021]: Identification and Authentication Failures | ||
[REFERENCES] | ||
https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html | ||
utils: | ||
match_api_key: | ||
kind: string_content | ||
pattern: $R | ||
rule: | ||
all: | ||
- matches: match_api_key | ||
constraints: | ||
R: | ||
regex: \b(sk-[[:alnum:]]{20}T3BlbkFJ[[:alnum:]]{20})\b | ||
43 changes: 43 additions & 0 deletions
43
rules/python/security/python-ldap3-empty-password-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,43 @@ | ||
id: python-ldap3-empty-password-python | ||
language: python | ||
severity: warning | ||
message: >- | ||
The application creates a database connection with an empty password. | ||
This can lead to unauthorized access by either an internal or external | ||
malicious actor. To prevent this vulnerability, enforce authentication | ||
when connecting to a database by using environment variables to securely | ||
provide credentials or retrieving them from a secure vault or HSM | ||
(Hardware Security Module). | ||
note: >- | ||
[OWASP A07:2021]: Identification and Authentication Failures | ||
[REFERENCES] | ||
https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html | ||
utils: | ||
match_empty_password: | ||
kind: expression_statement | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: attribute | ||
- has: | ||
stopBy: end | ||
kind: argument_list | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: keyword_argument | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: identifier | ||
regex: "^password$" | ||
- has: | ||
stopBy: neighbor | ||
kind: string | ||
not: | ||
has: | ||
stopBy: neighbor | ||
kind: string_content | ||
rule: | ||
any: | ||
- matches: match_empty_password |
10 changes: 10 additions & 0 deletions
10
tests/__snapshots__/openai-hardcoded-secret-password-python-snapshot.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,10 @@ | ||
id: openai-hardcoded-secret-password-python | ||
snapshots: | ||
? | | ||
api_key="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" | ||
f = "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" | ||
: labels: | ||
- source: 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 | ||
style: primary | ||
start: 9 | ||
end: 60 |
29 changes: 29 additions & 0 deletions
29
tests/__snapshots__/python-ldap3-empty-password-python-snapshot.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,29 @@ | ||
id: python-ldap3-empty-password-python | ||
snapshots: | ||
? | | ||
ldap3.Connection(password="") | ||
: labels: | ||
- source: ldap3.Connection(password="") | ||
style: primary | ||
start: 0 | ||
end: 29 | ||
- source: ldap3.Connection | ||
style: secondary | ||
start: 0 | ||
end: 16 | ||
- source: password | ||
style: secondary | ||
start: 17 | ||
end: 25 | ||
- source: '""' | ||
style: secondary | ||
start: 26 | ||
end: 28 | ||
- source: password="" | ||
style: secondary | ||
start: 17 | ||
end: 28 | ||
- source: (password="") | ||
style: secondary | ||
start: 16 | ||
end: 29 |
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,8 @@ | ||
id: openai-hardcoded-secret-password-python | ||
valid: | ||
- | | ||
openai.api_key="sk-ExamplexT3BlbkFJp6xpvsfpkEsmAJawIm0V" | ||
invalid: | ||
- | | ||
api_key="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" | ||
f = "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" | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
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,9 @@ | ||
id: python-ldap3-empty-password-python | ||
valid: | ||
- | | ||
ldap3.Connection(password=a) | ||
ldap3.Connection(password=os.env['SECRET']) | ||
ldap3.Connection(password=os.getenv('SECRET')) | ||
invalid: | ||
- | | ||
ldap3.Connection(password="") |
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.