Update upstream source from tag 'upstream/0.13.1'
Update to upstream version '0.13.1'
with Debian dir ede8c4ab9d1f11bf8e68f3727e61a7fba279ca1c
Sophie Brun
3 years ago
0 | 0 | require: rubocop-performance |
1 | 1 | AllCops: |
2 | 2 | NewCops: enable |
3 | SuggestExtensions: false | |
3 | 4 | TargetRubyVersion: 2.5 |
4 | 5 | Exclude: |
5 | 6 | - '*.gemspec' |
33 | 33 | s.add_development_dependency 'rake', '~> 13.0' |
34 | 34 | s.add_development_dependency 'rspec', '~> 3.10.0' |
35 | 35 | s.add_development_dependency 'rspec-its', '~> 1.3.0' |
36 | s.add_development_dependency 'rubocop', '~> 1.8.0' | |
36 | s.add_development_dependency 'rubocop', '~> 1.9.1' | |
37 | 37 | s.add_development_dependency 'rubocop-performance', '~> 1.9.0' |
38 | 38 | s.add_development_dependency 'simplecov', '~> 0.21.0' |
39 | 39 | s.add_development_dependency 'simplecov-lcov', '~> 0.8.0' |
28 | 28 | rescue NoMemoryError, ScriptError, SecurityError, SignalException, StandardError, SystemStackError => e |
29 | 29 | @run_error = e |
30 | 30 | |
31 | formatter.output('@scan_aborted', | |
32 | url: controllers.first.target.url, | |
33 | reason: e.is_a?(Interrupt) ? 'Canceled by User' : e.message, | |
34 | trace: e.backtrace, | |
35 | verbose: NS::ParsedCli.verbose || | |
36 | run_error_exit_code == NS::ExitCode::EXCEPTION) | |
31 | output_params = { | |
32 | reason: e.is_a?(Interrupt) ? 'Canceled by User' : e.message, | |
33 | trace: e.backtrace, | |
34 | verbose: NS::ParsedCli.verbose || run_error_exit_code == NS::ExitCode::EXCEPTION | |
35 | } | |
36 | ||
37 | output_params[:url] = controllers.first.target.url if NS::ParsedCli.url | |
38 | ||
39 | formatter.output('@scan_aborted', output_params) | |
37 | 40 | ensure |
38 | 41 | formatter.beautify |
39 | 42 | end |
40 | 40 | def directory_listing?(path = nil, params = {}) |
41 | 41 | res = NS::Browser.get(url(path), params) |
42 | 42 | |
43 | res.code == 200 && res.body.include?('<h1>Index of') ? true : false | |
43 | res.code == 200 && res.body.include?('<h1>Index of') | |
44 | 44 | end |
45 | 45 | |
46 | 46 | # @param [ String ] path |
43 | 43 | end |
44 | 44 | end |
45 | 45 | |
46 | context 'when an error is raised by OptParseValidator' do | |
47 | it 'aborts the scan with the correct output (ie w/o the url key)' do | |
48 | expect(scanner.controllers.option_parser).to receive(:results).and_return({}) | |
49 | ||
50 | expect(scanner.controllers.first).to receive(:before_scan).and_raise(OptParseValidator::Error, 'cli option') | |
51 | ||
52 | expect(scanner.formatter).to receive(:output).with( | |
53 | '@scan_aborted', | |
54 | reason: 'cli option', trace: anything, verbose: false | |
55 | ) | |
56 | end | |
57 | end | |
58 | ||
46 | 59 | context 'when an Interrupt is raised during the scan' do |
47 | 60 | it 'aborts the scan with the correct output' do |
48 | expect(scanner.controllers.option_parser).to receive(:results).and_return({}) | |
61 | expect(scanner.controllers.option_parser).to receive(:results).and_return({ url: target_url }) | |
49 | 62 | |
50 | 63 | expect(scanner.controllers.first).to receive(:before_scan).and_raise(Interrupt) |
51 | 64 | |
52 | 65 | expect(scanner.formatter).to receive(:output).with( |
53 | 66 | '@scan_aborted', |
54 | hash_including(reason: 'Canceled by User', trace: anything, verbose: false, url: target_url) | |
67 | reason: 'Canceled by User', trace: anything, verbose: false, url: target_url | |
55 | 68 | ) |
56 | 69 | end |
57 | 70 | end |
71 | 84 | let(:run_error) { error } |
72 | 85 | |
73 | 86 | it 'aborts the scan with the associated output' do |
74 | expect(scanner.controllers.option_parser).to receive(:results).and_return({}) | |
87 | expect(scanner.controllers.option_parser).to receive(:results).and_return({ url: target_url }) | |
75 | 88 | |
76 | 89 | expect(scanner.controllers.first) |
77 | 90 | .to receive(:before_scan) |
79 | 92 | |
80 | 93 | expect(scanner.formatter).to receive(:output).with( |
81 | 94 | '@scan_aborted', |
82 | hash_including(reason: run_error.message, trace: anything, verbose: expected_verbose, url: target_url) | |
95 | reason: run_error.message, trace: anything, verbose: expected_verbose, url: target_url | |
83 | 96 | ) |
84 | 97 | end |
85 | 98 | end |