Skip to content

Commit

Permalink
Patch to avoid issue with nil method call in alias_processor join_item
Browse files Browse the repository at this point in the history
  • Loading branch information
Capncavedan committed Feb 23, 2022
1 parent a167c31 commit ccde22b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/brakeman/processors/alias_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def process_array_join array, join_str
end

def join_item item, join_value
if item.is_a? String
if item.nil? || item.is_a?(String)
"#{item}#{join_value}"
elsif string? item or symbol? item or number? item
s(:str, "#{item.value}#{join_value}").line(item.line)
Expand Down
6 changes: 6 additions & 0 deletions test/tests/alias_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,12 @@ def test_bang_bang
INPUT
end

def test_join_item_works_with_nil_item
assert_nothing_raised do
Brakeman::AliasProcessor.new.join_item(nil, "something")
end
end

def test_alias_processor_failure
assert_raises do
Brakeman::AliasProcessor.new.process s(:block, s(:attrasgn, s(:call, nil, :x), :"[]!", s(:lit, 1), s(:lit, 2)))
Expand Down

0 comments on commit ccde22b

Please sign in to comment.