Skip to content

Commit

Permalink
fix: extract globals() to aux pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
elsapet committed May 20, 2024
1 parent 218f303 commit 58b87db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rules/python/lang/reflection_using_user_input.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ patterns:
- variable: USER_INPUT
detection: python_shared_common_user_input
scope: result
- pattern: globals()[$<USER_INPUT>]$<...>
- pattern: $<GLOBALS>[$<USER_INPUT>]$<...>
filters:
- variable: GLOBALS
detection: python_lang_reflection_using_user_input_globals
scope: result
- variable: USER_INPUT
detection: python_shared_common_user_input
scope: result
Expand All @@ -30,6 +33,10 @@ patterns:
- variable: USER_INPUT
detection: python_shared_common_user_input
scope: result
auxiliary:
- id: python_lang_reflection_using_user_input_globals
patterns:
- globals()
languages:
- python
severity: high
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ def bad(num1, num2):

# bearer:expected python_lang_reflection_using_user_input
result = globals()[operation](num1, num2)

my_globals = globals()
# bearer:expected python_lang_reflection_using_user_input
my_globals[operation](num1, num2)

def bad2():
user_action = input("what hack today? get_username or get_password")
Expand Down

0 comments on commit 58b87db

Please sign in to comment.