Skip to content

Commit

Permalink
Add interactive_ignore configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
magni- committed Jan 26, 2023
1 parent 3295ad0 commit 1edcb2e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,15 @@ brakeman:
ignore_file: '.brakeman'
```

(This is the equivalent of running `brakeman -i IGNOREFILE` on the command line.)
(This is the equivalent of running `brakeman -i IGNOREFILE` on the command line.)

## Interactive mode

Use this mode to [record any false positives](https://brakemanscanner.org/docs/ignoring_false_positives/) you wish to ignore.

```yaml
brakeman:
interactive_ignore: true
```

(This is the equivalent of running `brakeman --interactive-ignore` on the command line.)
7 changes: 6 additions & 1 deletion lib/pronto/brakeman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def run
output_formats: [:to_s],
only_files: files,
run_all_checks: run_all_checks?,
ignore_file: ignore_file)
ignore_file: ignore_file,
interactive_ignore: interactive_ignore?)
messages_for(patches, output).compact
rescue ::Brakeman::NoApplication
[]
Expand Down Expand Up @@ -66,6 +67,10 @@ def ignore_file
pronto_brakeman_config['ignore_file']
end

def interactive_ignore?
!!pronto_brakeman_config['interactive_ignore']
end

def pronto_brakeman_config
pronto_brakeman_config ||= Pronto::ConfigFile.new.to_h['brakeman'] || {}
end
Expand Down
12 changes: 12 additions & 0 deletions spec/pronto/brakeman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ module Pronto
it { should == [] }
end

context 'when interactive_ignore option is enabled' do
let(:repo) { Pronto::Git::Repository.new('.') }
let(:patches) { repo.diff('HEAD~1') }
let(:config_hash) { { 'brakeman' => { 'interactive_ignore' => true } } }

it "runs in interactive mode" do
expect(::Brakeman).to receive(:run).with(hash_including(interactive_ignore: true)).and_call_original

subject
end
end

context 'not a rails app' do
let(:repo) { Pronto::Git::Repository.new('.') }
let(:patches) { repo.diff('HEAD~1') }
Expand Down

0 comments on commit 1edcb2e

Please sign in to comment.