cms_scanner 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/core.rb +4 -3
- data/app/views/cli/core/finished.erb +1 -0
- data/app/views/json/core/finished.erb +1 -0
- data/cms_scanner.gemspec +13 -3
- data/lib/cms_scanner.rb +14 -2
- data/lib/cms_scanner/finders/finder.rb +16 -7
- data/lib/cms_scanner/finders/finder/enumerator.rb +4 -28
- data/lib/cms_scanner/finders/finder/fingerprinter.rb +60 -0
- data/lib/cms_scanner/finders/finding.rb +1 -1
- data/lib/cms_scanner/target/scope.rb +4 -1
- data/lib/cms_scanner/target/server/generic.rb +1 -1
- data/lib/cms_scanner/typhoeus/hydra.rb +10 -0
- data/lib/cms_scanner/version.rb +1 -1
- metadata +5 -203
- data/.gitignore +0 -7
- data/.rspec +0 -2
- data/.rubocop.yml +0 -10
- data/.travis.yml +0 -17
- data/Gemfile +0 -6
- data/Rakefile +0 -9
- data/spec/app/controllers/core_spec.rb +0 -167
- data/spec/app/controllers/interesting_files_spec.rb +0 -70
- data/spec/app/finders/interesting_files/fantastico_fileslist_spec.rb +0 -66
- data/spec/app/finders/interesting_files/headers_spec.rb +0 -36
- data/spec/app/finders/interesting_files/robots_txt_spec.rb +0 -54
- data/spec/app/finders/interesting_files/search_replace_db_2_spec.rb +0 -53
- data/spec/app/finders/interesting_files/xml_rpc_spec.rb +0 -136
- data/spec/app/finders/interesting_files_spec.rb +0 -12
- data/spec/app/formatters/cli_no_colour_spec.rb +0 -14
- data/spec/app/formatters/cli_spec.rb +0 -30
- data/spec/app/formatters/json_spec.rb +0 -30
- data/spec/app/models/fantastico_fileslist_spec.rb +0 -31
- data/spec/app/models/headers_spec.rb +0 -51
- data/spec/app/models/interesting_file_spec.rb +0 -69
- data/spec/app/models/robots_txt_spec.rb +0 -27
- data/spec/app/models/version_spec.rb +0 -51
- data/spec/app/models/xml_rpc_spec.rb +0 -46
- data/spec/app/views_spec.rb +0 -35
- data/spec/cache/.gitignore +0 -4
- data/spec/dummy_finding.rb +0 -25
- data/spec/dummy_independent_finders.rb +0 -26
- data/spec/dummy_unique_finders.rb +0 -33
- data/spec/fixtures/finders/interesting_files/fantastico_fileslist/fantastico_fileslist.txt +0 -12
- data/spec/fixtures/finders/interesting_files/file.txt +0 -4
- data/spec/fixtures/finders/interesting_files/headers/interesting.txt +0 -16
- data/spec/fixtures/finders/interesting_files/headers/no_interesting.txt +0 -12
- data/spec/fixtures/finders/interesting_files/robots_txt/robots.txt +0 -10
- data/spec/fixtures/finders/interesting_files/search_replace_db_2/searchreplacedb2.php +0 -188
- data/spec/fixtures/finders/interesting_files/xml_rpc/homepage_in_scope_pingback.html +0 -7
- data/spec/fixtures/finders/interesting_files/xml_rpc/homepage_out_of_scope_pingback.html +0 -7
- data/spec/fixtures/finders/interesting_files/xml_rpc/xmlrpc.php +0 -1
- data/spec/fixtures/output.txt +0 -0
- data/spec/fixtures/target/comments.html +0 -29
- data/spec/fixtures/target/platform/php/debug_log/debug.log +0 -2
- data/spec/fixtures/target/platform/php/fpd/wp_rss_functions.php +0 -2
- data/spec/fixtures/target/scope/index.html +0 -23
- data/spec/fixtures/target/server/apache/directory_listing/2.2.16.html +0 -15
- data/spec/fixtures/target/server/generic/server/apache/basic.txt +0 -5
- data/spec/fixtures/target/server/generic/server/iis/basic.txt +0 -6
- data/spec/fixtures/target/server/generic/server/not_detected.txt +0 -3
- data/spec/fixtures/target/server/iis/directory_listing/no_parent.html +0 -3
- data/spec/fixtures/target/server/iis/directory_listing/with_parent.html +0 -3
- data/spec/fixtures/views/base/ctrl/local.erb +0 -1
- data/spec/fixtures/views/base/ctrl/test.erb +0 -3
- data/spec/fixtures/views/base/global.erb +0 -1
- data/spec/fixtures/views/base/test.erb +0 -2
- data/spec/fixtures/views/based_format/test.erb +0 -1
- data/spec/fixtures/views/json/render_me.erb +0 -4
- data/spec/lib/browser_spec.rb +0 -140
- data/spec/lib/cache/file_store_spec.rb +0 -100
- data/spec/lib/cache/typhoeus_spec.rb +0 -28
- data/spec/lib/cms_scanner_spec.rb +0 -49
- data/spec/lib/controller_spec.rb +0 -30
- data/spec/lib/controllers_spec.rb +0 -48
- data/spec/lib/finders/confidence_spec.rb +0 -39
- data/spec/lib/finders/finder/enumerator_spec.rb +0 -89
- data/spec/lib/finders/finder/smart_url_checker/findings_spec.rb +0 -39
- data/spec/lib/finders/finder/smart_url_checker_spec.rb +0 -50
- data/spec/lib/finders/finder_spec.rb +0 -11
- data/spec/lib/finders/findings_spec.rb +0 -36
- data/spec/lib/finders/independent_finders_spec.rb +0 -134
- data/spec/lib/finders/same_type_finder_spec.rb +0 -24
- data/spec/lib/finders/same_type_finders_spec.rb +0 -126
- data/spec/lib/finders/unique_finder_spec.rb +0 -24
- data/spec/lib/finders/unique_finders_spec.rb +0 -222
- data/spec/lib/formatter_spec.rb +0 -145
- data/spec/lib/public_suffix/domain_spec.rb +0 -49
- data/spec/lib/sub_scanner_spec.rb +0 -45
- data/spec/lib/target/hashes_spec.rb +0 -90
- data/spec/lib/target/platforms_spec.rb +0 -13
- data/spec/lib/target/scope_spec.rb +0 -103
- data/spec/lib/target/servers_spec.rb +0 -13
- data/spec/lib/target_spec.rb +0 -69
- data/spec/lib/vulnerability/references_spec.rb +0 -75
- data/spec/lib/vulnerability_spec.rb +0 -27
- data/spec/lib/web_site_spec.rb +0 -121
- data/spec/output/core/finished.cli_no_colour +0 -3
- data/spec/output/core/finished.json +0 -5
- data/spec/output/core/started.cli_no_colour +0 -3
- data/spec/output/core/started.json +0 -5
- data/spec/output/interesting_files/empty.cli_no_colour +0 -2
- data/spec/output/interesting_files/empty.json +0 -5
- data/spec/output/interesting_files/findings.cli_no_colour +0 -30
- data/spec/output/interesting_files/findings.json +0 -75
- data/spec/shared_examples.rb +0 -11
- data/spec/shared_examples/browser_actions.rb +0 -30
- data/spec/shared_examples/finding.rb +0 -54
- data/spec/shared_examples/formatter_buffer.rb +0 -6
- data/spec/shared_examples/formatter_class_methods.rb +0 -26
- data/spec/shared_examples/independent_finder.rb +0 -31
- data/spec/shared_examples/target/platform/php.rb +0 -56
- data/spec/shared_examples/target/server/apache.rb +0 -32
- data/spec/shared_examples/target/server/generic.rb +0 -33
- data/spec/shared_examples/target/server/iis.rb +0 -37
- data/spec/shared_examples/views/core.rb +0 -26
- data/spec/shared_examples/views/interesting_files.rb +0 -36
- data/spec/spec_helper.rb +0 -43
@@ -1,7 +0,0 @@
|
|
1
|
-
<head>
|
2
|
-
<meta charset="UTF-8">
|
3
|
-
<meta name="viewport" content="width=device-width">
|
4
|
-
<title>WordPress 4.0 | Just another WordPress site</title>
|
5
|
-
<link rel="profile" href="http://gmpg.org/xfn/11">
|
6
|
-
<link rel="pingback" href="http://wp.lab/wordpress-4.0/xmlrpc.php">
|
7
|
-
</head>
|
@@ -1 +0,0 @@
|
|
1
|
-
XML-RPC server accepts POST requests only.
|
data/spec/fixtures/output.txt
DELETED
File without changes
|
@@ -1,29 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en-US" class="no-js">
|
3
|
-
<head>
|
4
|
-
<meta charset="UTF-8">
|
5
|
-
<meta name="viewport" content="width=device-width">
|
6
|
-
<link rel="profile" href="http://gmpg.org/xfn/11">
|
7
|
-
<link rel="pingback" href="http://wp.lab/wordpress-4.1.1/xmlrpc.php">
|
8
|
-
<!--[if lt IE 9]>
|
9
|
-
<script src="http://wp.lab/wordpress-4.1.1/wp-content/themes/twentyfifteen/js/html5.js"></script>
|
10
|
-
<![endif]-->
|
11
|
-
<script>(function(){document.documentElement.className='js'})();</script>
|
12
|
-
<title>WP 4.1.1 | Just another WordPress site</title>
|
13
|
-
<meta name='robots' content='noindex,follow' />
|
14
|
-
|
15
|
-
<!-- All in One SEO Pack 2.2.5.1 by Michael Torbert of Semper Fi Web Design -->
|
16
|
-
<link rel="canonical" href="http://wp.lab/wordpress-4.1.1/" />
|
17
|
-
<!-- /all in one seo pack -->
|
18
|
-
<!--[if lt IE 9]>
|
19
|
-
<link rel='stylesheet' id='twentyfifteen-ie-css' href='http://wp.lab/wordpress-4.1.1/wp-content/themes/twentyfifteen/css/ie.css?ver=20141010' type='text/css' media='all' />
|
20
|
-
<![endif]-->
|
21
|
-
<!--[if lt IE 8]>
|
22
|
-
<link rel='stylesheet' id='twentyfifteen-ie7-css' href='http://wp.lab/wordpress-4.1.1/wp-content/themes/twentyfifteen/css/ie7.css?ver=20141010' type='text/css' media='all' />
|
23
|
-
<![endif]-->
|
24
|
-
|
25
|
-
<!-- .site-branding -->
|
26
|
-
<!-- .site-header -->
|
27
|
-
|
28
|
-
</body>
|
29
|
-
</html>
|
@@ -1,23 +0,0 @@
|
|
1
|
-
<a href="http://e.org/f.txt">Link</a>
|
2
|
-
<a href="http://e.org/f.txt">Link</a> <!-- Duplicates should be ignored -->
|
3
|
-
|
4
|
-
<a href="mailto:mail@g.com">eMail me!</a>
|
5
|
-
<a href="jaVaScript:alert(2)">Click me Fool !</a>
|
6
|
-
|
7
|
-
<script src=" https://cdn.e.org/f2.js "></script> <!-- head & tail spaces should be removed -->
|
8
|
-
|
9
|
-
<script src="/script/s.js"></script>
|
10
|
-
|
11
|
-
<link rel="alternate" type="application/rss+xml" title="Spec" href="http://wp-lamp/robots.txt" />
|
12
|
-
|
13
|
-
<link rel="canonical" href="https://duckduckgo.com/">
|
14
|
-
|
15
|
-
<img src="http://out.of.scope.com/img.jpg" width="1000" height="288" alt="" />
|
16
|
-
|
17
|
-
<a href="">Empty Link</a>
|
18
|
-
|
19
|
-
<link rel="alternate" type="application/rss+xml" title="WordPress 4.1 » Feed" href="http://e.org/feed" />
|
20
|
-
|
21
|
-
<img src="//img.jpg" width="" height="" alt="" /> <!-- currently this should not be detected -->
|
22
|
-
|
23
|
-
<img src="//out.of.scope.com/img.jpg" width="" height="" alt="" />
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Index of /wordpress-4.0/wp-content/plugins/wp-dbmanager</title>
|
5
|
-
</head>
|
6
|
-
<body>
|
7
|
-
<h1>Index of /wordpress-4.0/wp-content/plugins/wp-dbmanager</h1>
|
8
|
-
<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr>
|
9
|
-
<tr><td valign="top"><img src="/icons/back.gif" alt="[DIR]"></td><td><a href="/wordpress-4.0/wp-content/plugins/">Parent Directory</a></td><td> </td><td align="right"> - </td><td> </td></tr>
|
10
|
-
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td><a href="backup.php">backup.php</a></td><td align="right">07-Oct-2014 18:43 </td><td align="right"> 10K</td><td> </td></tr>
|
11
|
-
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td><a href="database-empty.php">database-empty.php</a></td><td align="right">07-Oct-2014 18:43 </td><td align="right">3.9K</td><td> </td></tr>
|
12
|
-
<tr><th colspan="5"><hr></th></tr>
|
13
|
-
</table>
|
14
|
-
<address>Apache/2.2.16 (Debian) Server at wp.lab Port 80</address>
|
15
|
-
</body></html>
|
@@ -1,3 +0,0 @@
|
|
1
|
-
<html><head><title>e.org - /dir/</title></head><body><H1>e.org - /dir/</H1><hr>
|
2
|
-
|
3
|
-
<pre><A HREF="/">[To Parent Directory]</A><br><br> 10/8/2014 11:00 PM <dir> <A HREF="/sub-dir/">sub-dir</A>10/10/2014 10:00 PM 168 <A HREF="/web.config">web.config</A><br></pre><hr></body></html>
|
@@ -1 +0,0 @@
|
|
1
|
-
Local View
|
@@ -1 +0,0 @@
|
|
1
|
-
Global View
|
@@ -1 +0,0 @@
|
|
1
|
-
Override the base/test.erb
|
data/spec/lib/browser_spec.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe CMSScanner::Browser do
|
4
|
-
it_behaves_like described_class::Actions
|
5
|
-
|
6
|
-
subject(:browser) { described_class.instance(options) }
|
7
|
-
before { described_class.reset }
|
8
|
-
let(:options) { {} }
|
9
|
-
let(:default) do
|
10
|
-
{
|
11
|
-
ssl_verifypeer: false, ssl_verifyhost: 2,
|
12
|
-
headers: { 'User-Agent' => "CMSScanner v#{CMSScanner::VERSION}" }
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#forge_request' do
|
17
|
-
it 'returns a Typhoeus::Request' do
|
18
|
-
expect(browser.forge_request('http://example.com')).to be_a Typhoeus::Request
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#default_request_params' do
|
23
|
-
its(:default_request_params) { should eq default }
|
24
|
-
|
25
|
-
context 'when some attributes are set' do
|
26
|
-
let(:options) do
|
27
|
-
{
|
28
|
-
cache_ttl: 200, connect_timeout: 10,
|
29
|
-
http_auth: { username: 'log', password: 'pwd' },
|
30
|
-
cookie_jar: '/tmp/cookie_jar.txt'
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
let(:expected) do
|
35
|
-
default.merge(
|
36
|
-
cache_ttl: 200, connecttimeout: 10, userpwd: 'log:pwd',
|
37
|
-
cookiejar: options[:cookie_jar], cookiefile: options[:cookie_jar]
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
its(:default_request_params) { should eq expected }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#request_params' do
|
46
|
-
context 'when no param is given' do
|
47
|
-
its(:request_params) { should eq default }
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'when params are supplied' do
|
51
|
-
let(:params) { { another_param: true, headers: { 'Accept' => 'None' } } }
|
52
|
-
|
53
|
-
it 'merges them (headers should be correctly merged)' do
|
54
|
-
expect(browser.request_params(params)).to eq default
|
55
|
-
.merge(params) { |key, oldval, newval| key == :headers ? oldval.merge(newval) : newval }
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'when browser options' do
|
59
|
-
let(:options) { { proxy: 'http://127.0.0.1:8080' } }
|
60
|
-
|
61
|
-
it 'returns the correct hash' do
|
62
|
-
expect(browser.request_params(params)).to eq default
|
63
|
-
.merge(options)
|
64
|
-
.merge(params) { |key, oldval, newval| key == :headers ? oldval.merge(newval) : newval }
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#load_options' do
|
71
|
-
context 'when no options' do
|
72
|
-
it 'does not load anything' do
|
73
|
-
described_class::OPTIONS.each do |sym|
|
74
|
-
expected = sym == :user_agent ? "CMSScanner v#{CMSScanner::VERSION}" : nil
|
75
|
-
|
76
|
-
expect(browser.send(sym)).to eq expected
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context 'when options are supplied' do
|
82
|
-
module CMSScanner
|
83
|
-
# Test accessor
|
84
|
-
class Browser
|
85
|
-
attr_accessor :test
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
let(:options) do
|
90
|
-
{ cache_ttl: 200, max_threads: 10, test: 'should not be set',
|
91
|
-
user_agent: 'UA', proxy: false }
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'merges the browser options only' do
|
95
|
-
described_class::OPTIONS.each do |sym|
|
96
|
-
expected = options.key?(sym) ? options[sym] : nil
|
97
|
-
|
98
|
-
expect(browser.send(sym)).to eq expected
|
99
|
-
end
|
100
|
-
|
101
|
-
expect(browser.test).to be nil
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe '#hydra' do
|
107
|
-
context 'when #max_threads is nil' do
|
108
|
-
its('hydra.max_concurrency') { should eq 1 }
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'when #max_threads' do
|
112
|
-
let(:options) { { max_threads: 20 } }
|
113
|
-
|
114
|
-
its('hydra.max_concurrency') { should eq options[:max_threads] }
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe '#max_threads=' do
|
119
|
-
after do
|
120
|
-
browser.max_threads = @threads
|
121
|
-
|
122
|
-
expect(browser.max_threads).to eq @expected
|
123
|
-
expect(browser.hydra.max_concurrency).to eq @expected
|
124
|
-
end
|
125
|
-
|
126
|
-
context 'when <= 0' do
|
127
|
-
it 'sets the @threads to 1' do
|
128
|
-
@threads = -2
|
129
|
-
@expected = 1
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'when > 0' do
|
134
|
-
it 'sets the @threads' do
|
135
|
-
@threads = 20
|
136
|
-
@expected = @threads
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe CMSScanner::Cache::FileStore do
|
4
|
-
let(:cache_dir) { File.join(CACHE, 'cache_file_store') }
|
5
|
-
subject(:cache) { described_class.new(cache_dir) }
|
6
|
-
|
7
|
-
before { FileUtils.rm_r(cache_dir, secure: true) if Dir.exist?(cache_dir) }
|
8
|
-
after { cache.clean }
|
9
|
-
|
10
|
-
describe '#new, #storage_path, #serializer' do
|
11
|
-
its(:serializer) { should be Marshal }
|
12
|
-
its(:storage_path) { should eq cache_dir }
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#clean' do
|
16
|
-
it 'removes all files from the cache dir' do
|
17
|
-
# let's create some files into the directory first
|
18
|
-
(0..5).each do |i|
|
19
|
-
File.new(File.join(cache.storage_path, "file_#{i}.txt"), File::CREAT)
|
20
|
-
end
|
21
|
-
|
22
|
-
expect(count_files_in_dir(cache.storage_path, 'file_*.txt')).to eq 6
|
23
|
-
cache.clean
|
24
|
-
expect(count_files_in_dir(cache.storage_path)).to eq 0
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#read_entry?' do
|
29
|
-
let(:key) { 'key1' }
|
30
|
-
|
31
|
-
after do
|
32
|
-
File.write(cache.entry_expiration_path(key), @expiration) if @expiration
|
33
|
-
|
34
|
-
expect(cache.read_entry(key)).to eq @expected
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'when the entry does not exists' do
|
38
|
-
it 'returns nil' do
|
39
|
-
@expected = nil
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'when the file is empty (marshal data too short error)' do
|
44
|
-
it 'returns nil' do
|
45
|
-
File.new(cache.entry_path(key), File::CREAT)
|
46
|
-
|
47
|
-
@expiration = Time.now.to_i + 200
|
48
|
-
@expected = nil
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'when the entry has expired' do
|
53
|
-
it 'returns nil' do
|
54
|
-
@expiration = Time.now.to_i - 200
|
55
|
-
@expected = nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'when the entry has not expired' do
|
60
|
-
it 'returns the entry' do
|
61
|
-
File.write(cache.entry_path(key), cache.serializer.dump('testing data'))
|
62
|
-
|
63
|
-
@expiration = Time.now.to_i + 600
|
64
|
-
@expected = 'testing data'
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '#write_entry' do
|
70
|
-
after do
|
71
|
-
cache.write_entry(@key, @data, @ttl)
|
72
|
-
expect(cache.read_entry(@key)).to eq @expected
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'should get the correct entry (string)' do
|
76
|
-
@ttl = 10
|
77
|
-
@key = 'some_key'
|
78
|
-
@data = 'Hello World !'
|
79
|
-
@expected = @data
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'when cache_ttl <= 0' do
|
83
|
-
it 'does not write the entry' do
|
84
|
-
@ttl = 0
|
85
|
-
@key = 'another_key'
|
86
|
-
@data = 'Another Hello World !'
|
87
|
-
@expected = nil
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'when cache_ttl is nil' do
|
92
|
-
it 'does not write the entry' do
|
93
|
-
@ttl = nil
|
94
|
-
@key = 'test'
|
95
|
-
@data = 'test'
|
96
|
-
@expected = nil
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe CMSScanner::Cache::Typhoeus do
|
4
|
-
subject(:cache) { described_class.new(cache_dir) }
|
5
|
-
|
6
|
-
let(:cache_dir) { File.join(CACHE, 'typhoeus_cache') }
|
7
|
-
let(:url) { 'http://example.com' }
|
8
|
-
let(:request) { Typhoeus::Request.new(url, cache_ttl: 20) }
|
9
|
-
let(:key) { request.hash.to_s }
|
10
|
-
|
11
|
-
describe '#get' do
|
12
|
-
it 'calls #read_entry' do
|
13
|
-
expect(cache).to receive(:read_entry).with(key)
|
14
|
-
|
15
|
-
cache.get(request)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#set' do
|
20
|
-
let(:response) { Typhoeus::Response.new }
|
21
|
-
|
22
|
-
it 'calls #write_entry' do
|
23
|
-
expect(cache).to receive(:write_entry).with(key, response, request.cache_ttl)
|
24
|
-
|
25
|
-
cache.set(request, response)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CMSScanner
|
4
|
-
module Controller
|
5
|
-
# Failure class for testing
|
6
|
-
class SpecFailure < Base
|
7
|
-
def before_scan
|
8
|
-
fail 'error spotted'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe CMSScanner::Scan do
|
15
|
-
subject(:scanner) { described_class.new }
|
16
|
-
let(:controller) { CMSScanner::Controller }
|
17
|
-
|
18
|
-
describe '#new, #controllers' do
|
19
|
-
its(:controllers) { should eq([controller::Core.new]) }
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#run' do
|
23
|
-
it 'runs the controlllers and calls the formatter#beautify' do
|
24
|
-
hydra = CMSScanner::Browser.instance.hydra
|
25
|
-
|
26
|
-
expect(scanner.controllers).to receive(:run).ordered
|
27
|
-
expect(hydra).to receive(:abort).ordered
|
28
|
-
expect(hydra).to receive(:run).ordered
|
29
|
-
expect(scanner.formatter).to receive(:beautify).ordered
|
30
|
-
|
31
|
-
scanner.run
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when an error is raised during the #run' do
|
35
|
-
it 'aborts the scan with the associated output' do
|
36
|
-
scanner.controllers[0] = controller::SpecFailure.new
|
37
|
-
|
38
|
-
expect(scanner.formatter).to receive(:output)
|
39
|
-
.with('@scan_aborted', hash_including(:reason, :trace, :verbose))
|
40
|
-
|
41
|
-
scanner.run
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#datastore' do
|
47
|
-
its(:datastore) { should eq({}) }
|
48
|
-
end
|
49
|
-
end
|