Skip to content

Commit

Permalink
Merge pull request #1820 from presidentbeef/limit_mass_of_copied_values
Browse files Browse the repository at this point in the history
Avoid copying Sexps that are too large
  • Loading branch information
presidentbeef committed Jan 26, 2024
2 parents 7c34984 + 180e872 commit f07829d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/brakeman/processors/alias_processor.rb
Original file line number Diff line number Diff line change
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
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 f07829d

Please sign in to comment.