Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interactive_ignore configuration option #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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