Codebase list ruby-cms-scanner / 359a46f
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
6 changed file(s) with 30 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
00 require: rubocop-performance
11 AllCops:
22 NewCops: enable
3 SuggestExtensions: false
34 TargetRubyVersion: 2.5
45 Exclude:
56 - '*.gemspec'
3333 s.add_development_dependency 'rake', '~> 13.0'
3434 s.add_development_dependency 'rspec', '~> 3.10.0'
3535 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'
3737 s.add_development_dependency 'rubocop-performance', '~> 1.9.0'
3838 s.add_development_dependency 'simplecov', '~> 0.21.0'
3939 s.add_development_dependency 'simplecov-lcov', '~> 0.8.0'
2828 rescue NoMemoryError, ScriptError, SecurityError, SignalException, StandardError, SystemStackError => e
2929 @run_error = e
3030
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)
3740 ensure
3841 formatter.beautify
3942 end
4040 def directory_listing?(path = nil, params = {})
4141 res = NS::Browser.get(url(path), params)
4242
43 res.code == 200 && res.body.include?('<h1>Index of') ? true : false
43 res.code == 200 && res.body.include?('<h1>Index of')
4444 end
4545
4646 # @param [ String ] path
11
22 # Version
33 module CMSScanner
4 VERSION = '0.13.0'
4 VERSION = '0.13.1'
55 end
4343 end
4444 end
4545
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
4659 context 'when an Interrupt is raised during the scan' do
4760 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 })
4962
5063 expect(scanner.controllers.first).to receive(:before_scan).and_raise(Interrupt)
5164
5265 expect(scanner.formatter).to receive(:output).with(
5366 '@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
5568 )
5669 end
5770 end
7184 let(:run_error) { error }
7285
7386 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 })
7588
7689 expect(scanner.controllers.first)
7790 .to receive(:before_scan)
7992
8093 expect(scanner.formatter).to receive(:output).with(
8194 '@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
8396 )
8497 end
8598 end