-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle identifiers in subscript
- Loading branch information
Showing
5 changed files
with
202 additions
and
2 deletions.
There are no files selected for viewing
142 changes: 142 additions & 0 deletions
142
internal/languages/python/.snapshots/TestSubscript--subscript.yml
This file contains 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,142 @@ | ||
high: | ||
- rule: | ||
cwe_ids: | ||
- "42" | ||
id: subscript_test | ||
title: Test detection filter subscript statements | ||
description: Test detection filter subscript statements | ||
documentation_url: "" | ||
line_number: 1 | ||
full_filename: subscript.py | ||
filename: subscript.py | ||
source: | ||
location: | ||
start: 1 | ||
end: 1 | ||
column: | ||
start: 1 | ||
end: 13 | ||
sink: | ||
location: | ||
start: 1 | ||
end: 1 | ||
column: | ||
start: 1 | ||
end: 13 | ||
content: "" | ||
parent_line_number: 1 | ||
fingerprint: dbeafee632db3831065048aabd949c8b_0 | ||
old_fingerprint: dbeafee632db3831065048aabd949c8b_0 | ||
- rule: | ||
cwe_ids: | ||
- "42" | ||
id: subscript_test | ||
title: Test detection filter subscript statements | ||
description: Test detection filter subscript statements | ||
documentation_url: "" | ||
line_number: 3 | ||
full_filename: subscript.py | ||
filename: subscript.py | ||
source: | ||
location: | ||
start: 3 | ||
end: 3 | ||
column: | ||
start: 1 | ||
end: 19 | ||
sink: | ||
location: | ||
start: 3 | ||
end: 3 | ||
column: | ||
start: 1 | ||
end: 19 | ||
content: "" | ||
parent_line_number: 3 | ||
fingerprint: dbeafee632db3831065048aabd949c8b_1 | ||
old_fingerprint: dbeafee632db3831065048aabd949c8b_1 | ||
- rule: | ||
cwe_ids: | ||
- "42" | ||
id: subscript_test | ||
title: Test detection filter subscript statements | ||
description: Test detection filter subscript statements | ||
documentation_url: "" | ||
line_number: 7 | ||
full_filename: subscript.py | ||
filename: subscript.py | ||
source: | ||
location: | ||
start: 7 | ||
end: 7 | ||
column: | ||
start: 1 | ||
end: 7 | ||
sink: | ||
location: | ||
start: 7 | ||
end: 7 | ||
column: | ||
start: 1 | ||
end: 7 | ||
content: "" | ||
parent_line_number: 7 | ||
fingerprint: dbeafee632db3831065048aabd949c8b_2 | ||
old_fingerprint: dbeafee632db3831065048aabd949c8b_2 | ||
- rule: | ||
cwe_ids: | ||
- "42" | ||
id: subscript_test | ||
title: Test detection filter subscript statements | ||
description: Test detection filter subscript statements | ||
documentation_url: "" | ||
line_number: 9 | ||
full_filename: subscript.py | ||
filename: subscript.py | ||
source: | ||
location: | ||
start: 9 | ||
end: 9 | ||
column: | ||
start: 1 | ||
end: 13 | ||
sink: | ||
location: | ||
start: 9 | ||
end: 9 | ||
column: | ||
start: 1 | ||
end: 13 | ||
content: "" | ||
parent_line_number: 9 | ||
fingerprint: dbeafee632db3831065048aabd949c8b_3 | ||
old_fingerprint: dbeafee632db3831065048aabd949c8b_3 | ||
- rule: | ||
cwe_ids: | ||
- "42" | ||
id: subscript_test | ||
title: Test detection filter subscript statements | ||
description: Test detection filter subscript statements | ||
documentation_url: "" | ||
line_number: 10 | ||
full_filename: subscript.py | ||
filename: subscript.py | ||
source: | ||
location: | ||
start: 10 | ||
end: 10 | ||
column: | ||
start: 1 | ||
end: 13 | ||
sink: | ||
location: | ||
start: 10 | ||
end: 10 | ||
column: | ||
start: 1 | ||
end: 13 | ||
content: "" | ||
parent_line_number: 10 | ||
fingerprint: dbeafee632db3831065048aabd949c8b_4 | ||
old_fingerprint: dbeafee632db3831065048aabd949c8b_4 | ||
|
This file contains 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
This file contains 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
This file contains 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,17 @@ | ||
foo[input()] | ||
|
||
globals()[input()] | ||
|
||
x = input() | ||
|
||
foo[x] | ||
|
||
globals()[x] | ||
globals()[x]("something") | ||
|
||
# don't match the below | ||
|
||
foo[y] | ||
foo["world"] | ||
globals()[y] | ||
globals()["world"] |
This file contains 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 @@ | ||
languages: | ||
- python | ||
patterns: | ||
- pattern: foo[$<USER_INPUT>] | ||
filters: | ||
- variable: USER_INPUT | ||
detection: subscript_test_user_input | ||
scope: result | ||
- pattern: globals()[$<USER_INPUT>]$<...> | ||
filters: | ||
- variable: USER_INPUT | ||
detection: subscript_test_user_input | ||
scope: result | ||
auxiliary: | ||
- id: subscript_test_user_input | ||
patterns: | ||
- input() | ||
severity: high | ||
metadata: | ||
description: Test detection filter subscript statements | ||
remediation_message: Test detection filter subscript statements | ||
cwe_id: | ||
- 42 | ||
id: subscript_test |