Skip to content

Commit

Permalink
Merge pull request #23357 from Fryguy/add_interactive_ignore_brakeman
Browse files Browse the repository at this point in the history
Add interactive-ignore support through test:security:brakeman
  • Loading branch information
jrafanie authored Mar 3, 2025
2 parents 9798604 + 0e62e8d commit bbcf047
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 0 additions & 2 deletions lib/extensions/brakeman_fingerprint_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ def fingerprint
def to_hash(absolute_paths: true)
super.tap do |h|
h[:file] = (absolute_paths ? self.file.absolute : file_string)
h[:file_rel] = self.file.relative
h[:file_abs] = self.file.absolute
end
end
end
12 changes: 11 additions & 1 deletion lib/tasks/test_security_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ class TestSecurityHelper
class SecurityTestFailed < StandardError; end

def self.brakeman(format: "human")
args = ARGV.drop_while { |arg| arg != "--" }.drop(1)
interactive_ignore = (args & %w[-I --interactive-ignore]).any?

require "vmdb/plugins"
require "brakeman"

Expand Down Expand Up @@ -43,11 +46,18 @@ def self.brakeman(format: "human")
:report_progress => $stderr.tty?,
:use_prism => true,
}
if format == "json"
case format
when "json"
raise ArgumentError, "cannot pass --interactive-ignore with json output" if interactive_ignore

options[:output_files] = [
Rails.root.join("log/brakeman.json").to_s,
Rails.root.join("log/brakeman.log").to_s
]
when "human"
options[:interactive_ignore] = true if interactive_ignore
else
raise ArgumentError, "Unknown format #{format.inspect}"
end

tracker = Brakeman.run(options)
Expand Down

0 comments on commit bbcf047

Please sign in to comment.