Skip to content

Commit

Permalink
Avoid copying Sexps that are too large
Browse files Browse the repository at this point in the history
Addresses #1816, #1546, ...
  • Loading branch information
presidentbeef committed Jan 25, 2024
1 parent 7c34984 commit 180e872
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/brakeman/processors/alias_processor.rb
Expand Up @@ -32,6 +32,7 @@ def initialize tracker = nil, current_file = nil
@or_depth_limit = (tracker && tracker.options[:branch_limit]) || 5 #arbitrary default
@meth_env = nil
@current_file = current_file
@mass_limit = (tracker && tracker.options[:mass_limit]) || 1000 # arbitrary default

Check warning on line 35 in lib/brakeman/processors/alias_processor.rb

View check run for this annotation

DryRunSecurity / AI-powered Sensitive Function Check

Possible Sensitive Function

Our AI-Powered Sensitive Function checker believes it has discovered a sensitive function being modified in this PR. The name of the function is `initialize`. Extra care must be taken when modifying a function that is potentially security-sensitive. The following reason was provided for why this function was flagged as sensitive: This function sets the mass limit for the tracker, which is an arbitrary default value. Although it is not directly related to authentication or authorization, it may impact the overall security of the application and should be reviewed as part of the pull request.
set_env_defaults
end

Expand Down Expand Up @@ -82,8 +83,12 @@ def process_default exp
def replace exp, int = 0
return exp if int > 3

if replacement = env[exp] and not duplicate? replacement
replace(replacement.deep_clone(exp.line), int + 1)
if replacement = env[exp]
if not duplicate? replacement and replacement.mass < @mass_limit
replace(replacement.deep_clone(exp.line), int + 1)
else
exp
end
elsif tracker and replacement = tracker.constant_lookup(exp) and not duplicate? replacement
replace(replacement.deep_clone(exp.line), int + 1)
else
Expand Down

0 comments on commit 180e872

Please sign in to comment.