site-inspector 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +34 -0
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/Guardfile +1 -1
- data/README.md +6 -1
- data/Rakefile +2 -2
- data/bin/site-inspector +15 -15
- data/lib/cliver/dependency_ext.rb +21 -0
- data/lib/site-inspector.rb +13 -11
- data/lib/site-inspector/checks/accessibility.rb +27 -17
- data/lib/site-inspector/checks/check.rb +1 -3
- data/lib/site-inspector/checks/content.rb +6 -6
- data/lib/site-inspector/checks/cookies.rb +6 -8
- data/lib/site-inspector/checks/dns.rb +21 -20
- data/lib/site-inspector/checks/headers.rb +12 -13
- data/lib/site-inspector/checks/hsts.rb +8 -9
- data/lib/site-inspector/checks/https.rb +3 -5
- data/lib/site-inspector/checks/sniffer.rb +8 -9
- data/lib/site-inspector/domain.rb +28 -32
- data/lib/site-inspector/endpoint.rb +31 -32
- data/lib/site-inspector/version.rb +1 -1
- data/script/cibuild +3 -1
- data/script/pa11y-version +9 -0
- data/site-inspector.gemspec +25 -25
- data/spec/checks/site_inspector_endpoint_accessibility_spec.rb +31 -30
- data/spec/checks/site_inspector_endpoint_check_spec.rb +10 -11
- data/spec/checks/site_inspector_endpoint_content_spec.rb +43 -44
- data/spec/checks/site_inspector_endpoint_cookies_spec.rb +30 -31
- data/spec/checks/site_inspector_endpoint_dns_spec.rb +72 -77
- data/spec/checks/site_inspector_endpoint_headers_spec.rb +26 -27
- data/spec/checks/site_inspector_endpoint_hsts_spec.rb +26 -27
- data/spec/checks/site_inspector_endpoint_https_spec.rb +11 -12
- data/spec/checks/site_inspector_endpoint_sniffer_spec.rb +56 -57
- data/spec/site_inspector_cache_spec.rb +6 -6
- data/spec/site_inspector_disk_cache_spec.rb +9 -9
- data/spec/site_inspector_domain_spec.rb +132 -136
- data/spec/site_inspector_endpoint_spec.rb +108 -108
- data/spec/site_inspector_spec.rb +17 -18
- data/spec/spec_helper.rb +3 -3
- metadata +21 -3
data/script/cibuild
CHANGED
data/site-inspector.gemspec
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
require File.expand_path
|
1
|
+
require File.expand_path './lib/site-inspector/version', File.dirname(__FILE__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
|
5
|
-
s.name = "site-inspector"
|
4
|
+
s.name = 'site-inspector'
|
6
5
|
s.version = SiteInspector::VERSION
|
7
|
-
s.summary =
|
6
|
+
s.summary = 'A Ruby port and v2 of Site Inspector (https://github.com/benbalter/site-inspector)'
|
8
7
|
s.description = "Returns information about a domain's technology and capabilities"
|
9
|
-
s.authors =
|
10
|
-
s.email =
|
11
|
-
s.homepage =
|
12
|
-
s.license =
|
8
|
+
s.authors = 'Ben Balter'
|
9
|
+
s.email = 'ben@balter.com'
|
10
|
+
s.homepage = 'https://github.com/benbalter/site-inspector'
|
11
|
+
s.license = 'MIT'
|
13
12
|
|
14
13
|
s.files = `git ls-files -z`.split("\x0")
|
15
14
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
15
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
-
s.require_paths = [
|
16
|
+
s.require_paths = ['lib']
|
18
17
|
|
19
|
-
s.add_dependency(
|
20
|
-
s.add_dependency(
|
21
|
-
s.add_dependency(
|
22
|
-
s.add_dependency(
|
23
|
-
s.add_dependency(
|
24
|
-
s.add_dependency(
|
25
|
-
s.add_dependency(
|
26
|
-
s.add_dependency(
|
27
|
-
s.add_dependency(
|
28
|
-
s.add_dependency(
|
29
|
-
s.add_dependency(
|
30
|
-
s.add_development_dependency(
|
31
|
-
s.add_development_dependency(
|
32
|
-
s.add_development_dependency(
|
33
|
-
s.add_development_dependency(
|
34
|
-
s.add_development_dependency(
|
18
|
+
s.add_dependency('nokogiri', '~> 1.6')
|
19
|
+
s.add_dependency('public_suffix', '~> 1.4')
|
20
|
+
s.add_dependency('gman', '~> 4.1')
|
21
|
+
s.add_dependency('dnsruby', '~> 1.56')
|
22
|
+
s.add_dependency('sniffles', '~> 0.2')
|
23
|
+
s.add_dependency('typhoeus', '~> 0.7')
|
24
|
+
s.add_dependency('oj', '~> 2.11')
|
25
|
+
s.add_dependency('mercenary', '~> 0.3')
|
26
|
+
s.add_dependency('colorator', '~> 0.1')
|
27
|
+
s.add_dependency('cliver', '~> 0.3')
|
28
|
+
s.add_dependency('parallel', '~> 1.6')
|
29
|
+
s.add_development_dependency('pry', '~> 0.10')
|
30
|
+
s.add_development_dependency('rake', '~> 10.4')
|
31
|
+
s.add_development_dependency('rspec', '~> 3.2')
|
32
|
+
s.add_development_dependency('bundler', '~> 1.6')
|
33
|
+
s.add_development_dependency('webmock', '~> 1.2')
|
34
|
+
s.add_development_dependency('rubocop', '~> 0.35')
|
35
35
|
end
|
@@ -1,81 +1,82 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SiteInspector::Endpoint::Accessibility do
|
4
|
-
|
5
4
|
subject do
|
6
|
-
endpoint = SiteInspector::Endpoint.new(
|
5
|
+
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
7
6
|
SiteInspector::Endpoint::Accessibility.new(endpoint)
|
8
7
|
end
|
9
8
|
|
10
9
|
it "retrieve's pa11y's version" do
|
10
|
+
pending('Pa11y not installed') unless SiteInspector::Endpoint::Accessibility.pa11y?
|
11
11
|
expect(subject.class.pa11y_version).to match(/\d\.\d\.\d/)
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'responds to valid standards' do
|
15
15
|
expect(subject.respond_to?(:section508)).to eql(true)
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'knows the level' do
|
19
19
|
expect(subject.level).to eql(:error)
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
22
|
+
it 'allows the user to set the level' do
|
23
23
|
subject.level = :warning
|
24
24
|
expect(subject.level).to eql(:warning)
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
expect{subject.level=
|
27
|
+
it 'errors on invalid levels' do
|
28
|
+
expect { subject.level = 'foo' }.to raise_error(ArgumentError)
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
31
|
+
it 'knows the standard' do
|
32
32
|
expect(subject.standard).to eql(:section508)
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it 'allows the user to set the standard' do
|
36
36
|
subject.standard = :wcag2a
|
37
37
|
expect(subject.standard).to eql(:wcag2a)
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
41
|
-
expect{subject.standard
|
40
|
+
it 'errors on invalid standards' do
|
41
|
+
expect { subject.standard = :foo }.to raise_error(ArgumentError)
|
42
42
|
end
|
43
43
|
|
44
|
-
context
|
45
|
-
|
44
|
+
context 'with pa11y installed' do
|
46
45
|
before do
|
47
|
-
stub_request(:head,
|
46
|
+
stub_request(:head, 'http://example.com/').to_return(status: 200)
|
48
47
|
end
|
49
|
-
|
50
48
|
end
|
51
49
|
|
52
50
|
context "with pa11y stub'd" do
|
53
|
-
|
54
51
|
before do
|
55
52
|
output = '[{"code":"Section508.L.NoContentAnchor","context":"<a href=\"foo\"></a>","message":"Anchor element found with a valid href attribute, but no link content has been supplied.","selector":"html > body > a","type":"error","typeCode":1}]'
|
56
53
|
allow(subject).to receive(:run_command) { [output, 2] }
|
57
54
|
end
|
58
55
|
|
59
|
-
it
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
it "knows if a site is valid" do
|
64
|
-
expect(subject.valid?).to eql(false)
|
56
|
+
it 'knows if a site is valid' do
|
57
|
+
with_env 'SKIP_PA11Y_CHECK', 'true' do
|
58
|
+
expect(subject.valid?).to eql(false)
|
59
|
+
end
|
65
60
|
end
|
66
61
|
|
67
|
-
it
|
68
|
-
|
62
|
+
it 'counts the errors' do
|
63
|
+
with_env 'SKIP_PA11Y_CHECK', 'true' do
|
64
|
+
expect(subject.errors).to eql(1)
|
65
|
+
end
|
69
66
|
end
|
70
67
|
|
71
|
-
it
|
72
|
-
|
73
|
-
|
68
|
+
it 'runs the check' do
|
69
|
+
with_env 'SKIP_PA11Y_CHECK', 'true' do
|
70
|
+
expect(subject.check[:valid]).to eql(false)
|
71
|
+
expect(subject.check[:results].first['code']).to eql('Section508.L.NoContentAnchor')
|
72
|
+
end
|
74
73
|
end
|
75
74
|
|
76
|
-
it
|
77
|
-
|
78
|
-
|
75
|
+
it 'runs a named check' do
|
76
|
+
with_env 'SKIP_PA11Y_CHECK', 'true' do
|
77
|
+
expect(subject.check[:valid]).to eql(false)
|
78
|
+
expect(subject.check[:results].first['code']).to eql('Section508.L.NoContentAnchor')
|
79
|
+
end
|
79
80
|
end
|
80
81
|
end
|
81
82
|
end
|
@@ -1,38 +1,37 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SiteInspector::Endpoint::Check do
|
4
|
-
|
5
4
|
subject do
|
6
|
-
stub_request(:head,
|
7
|
-
endpoint = SiteInspector::Endpoint.new(
|
5
|
+
stub_request(:head, 'http://example.com/').to_return(status: 200)
|
6
|
+
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
8
7
|
SiteInspector::Endpoint::Check.new(endpoint)
|
9
8
|
end
|
10
9
|
|
11
|
-
it
|
10
|
+
it 'returns the endpoint' do
|
12
11
|
expect(subject.endpoint.class).to eql(SiteInspector::Endpoint)
|
13
12
|
end
|
14
13
|
|
15
|
-
it
|
14
|
+
it 'returns the response' do
|
16
15
|
expect(subject.response.class).to eql(Typhoeus::Response)
|
17
16
|
end
|
18
17
|
|
19
|
-
it
|
18
|
+
it 'returns the request' do
|
20
19
|
expect(subject.request.class).to eql(Typhoeus::Request)
|
21
20
|
end
|
22
21
|
|
23
|
-
it
|
24
|
-
expect(subject.host).to eql(
|
22
|
+
it 'returns the host' do
|
23
|
+
expect(subject.host).to eql('example.com')
|
25
24
|
end
|
26
25
|
|
27
|
-
it
|
26
|
+
it 'returns its name' do
|
28
27
|
expect(subject.name).to eql(:check)
|
29
28
|
end
|
30
29
|
|
31
|
-
it
|
30
|
+
it 'returns the instance name' do
|
32
31
|
expect(SiteInspector::Endpoint::Check.name).to eql(:check)
|
33
32
|
end
|
34
33
|
|
35
|
-
it
|
34
|
+
it 'enables and disables the check' do
|
36
35
|
expect(SiteInspector::Endpoint::Check.enabled?).to eql(true)
|
37
36
|
SiteInspector::Endpoint::Check.enabled = false
|
38
37
|
expect(SiteInspector::Endpoint::Check.enabled?).to eql(false)
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SiteInspector::Endpoint::Content do
|
4
|
-
|
5
4
|
subject do
|
6
5
|
body = <<-eos
|
7
6
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
@@ -12,97 +11,97 @@ describe SiteInspector::Endpoint::Content do
|
|
12
11
|
</html>
|
13
12
|
eos
|
14
13
|
|
15
|
-
stub_request(:get,
|
16
|
-
to_return(:
|
17
|
-
|
18
|
-
|
19
|
-
endpoint = SiteInspector::Endpoint.new(
|
14
|
+
stub_request(:get, 'http://example.com/')
|
15
|
+
.to_return(status: 200, body: body)
|
16
|
+
stub_request(:head, 'http://example.com/')
|
17
|
+
.to_return(status: 200)
|
18
|
+
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
20
19
|
SiteInspector::Endpoint::Content.new(endpoint)
|
21
20
|
end
|
22
21
|
|
23
|
-
it
|
22
|
+
it 'returns the doc' do
|
24
23
|
expect(subject.document.class).to eql(Nokogiri::HTML::Document)
|
25
|
-
expect(subject.document.css(
|
24
|
+
expect(subject.document.css('h1').text).to eql('Some page')
|
26
25
|
end
|
27
26
|
|
28
|
-
it
|
29
|
-
expect(subject.body).to match(
|
27
|
+
it 'returns the body' do
|
28
|
+
expect(subject.body).to match('<h1>Some page</h1>')
|
30
29
|
end
|
31
30
|
|
32
|
-
it
|
33
|
-
expect(subject.doctype).to eql(
|
31
|
+
it 'returns the doctype' do
|
32
|
+
expect(subject.doctype).to eql('-//W3C//DTD XHTML 1.0 Transitional//EN')
|
34
33
|
end
|
35
34
|
|
36
|
-
it
|
37
|
-
stub_request(:head,
|
35
|
+
it 'knows when robots.txt exists' do
|
36
|
+
stub_request(:head, %r{http\://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
38
37
|
|
39
|
-
stub_request(:head,
|
40
|
-
to_return(:
|
38
|
+
stub_request(:head, 'http://example.com/robots.txt')
|
39
|
+
.to_return(status: 200)
|
41
40
|
expect(subject.robots_txt?).to eql(true)
|
42
41
|
end
|
43
42
|
|
44
43
|
it "knows when robots.txt doesn't exist" do
|
45
|
-
stub_request(:head,
|
44
|
+
stub_request(:head, %r{http\://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
46
45
|
|
47
|
-
stub_request(:head,
|
48
|
-
to_return(:
|
46
|
+
stub_request(:head, 'http://example.com/robots.txt')
|
47
|
+
.to_return(status: 404)
|
49
48
|
expect(subject.robots_txt?).to eql(false)
|
50
49
|
end
|
51
50
|
|
52
|
-
it
|
53
|
-
stub_request(:head,
|
51
|
+
it 'knows when sitemap.xml exists' do
|
52
|
+
stub_request(:head, %r{http\://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
54
53
|
|
55
|
-
stub_request(:head,
|
56
|
-
to_return(:
|
54
|
+
stub_request(:head, 'http://example.com/sitemap.xml')
|
55
|
+
.to_return(status: 200)
|
57
56
|
expect(subject.sitemap_xml?).to eql(true)
|
58
57
|
end
|
59
58
|
|
60
|
-
it
|
61
|
-
stub_request(:head,
|
59
|
+
it 'knows when sitemap.xml exists' do
|
60
|
+
stub_request(:head, %r{http\://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
62
61
|
|
63
|
-
stub_request(:head,
|
64
|
-
to_return(:
|
62
|
+
stub_request(:head, 'http://example.com/sitemap.xml')
|
63
|
+
.to_return(status: 404)
|
65
64
|
expect(subject.sitemap_xml?).to eql(false)
|
66
65
|
end
|
67
66
|
|
68
|
-
it
|
69
|
-
stub_request(:head,
|
67
|
+
it 'knows when humans.txt exists' do
|
68
|
+
stub_request(:head, %r{http\://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
70
69
|
|
71
|
-
stub_request(:head,
|
72
|
-
to_return(:
|
70
|
+
stub_request(:head, 'http://example.com/humans.txt')
|
71
|
+
.to_return(status: 200)
|
73
72
|
expect(subject.humans_txt?).to eql(true)
|
74
73
|
end
|
75
74
|
|
76
75
|
it "knows when humans.txt doesn't exist" do
|
77
|
-
stub_request(:head,
|
76
|
+
stub_request(:head, %r{http\://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
78
77
|
|
79
|
-
stub_request(:head,
|
80
|
-
to_return(:
|
78
|
+
stub_request(:head, 'http://example.com/humans.txt')
|
79
|
+
.to_return(status: 200)
|
81
80
|
expect(subject.humans_txt?).to eql(true)
|
82
81
|
end
|
83
82
|
|
84
|
-
context
|
85
|
-
it
|
86
|
-
stub_request(:head,
|
87
|
-
to_return(:
|
83
|
+
context '404s' do
|
84
|
+
it 'knows when an endpoint returns a proper 404' do
|
85
|
+
stub_request(:head, %r{http\://example.com/.*})
|
86
|
+
.to_return(status: 404)
|
88
87
|
expect(subject.proper_404s?).to eql(true)
|
89
88
|
end
|
90
89
|
|
91
90
|
it "knows when an endpoint doesn't return a proper 404" do
|
92
|
-
stub_request(:head,
|
93
|
-
to_return(:
|
91
|
+
stub_request(:head, %r{http\://example.com/[a-z0-9]{32}}i)
|
92
|
+
.to_return(status: 200)
|
94
93
|
expect(subject.proper_404s?).to eql(false)
|
95
94
|
end
|
96
95
|
|
97
|
-
it
|
96
|
+
it 'generates a random path' do
|
98
97
|
path = subject.send(:random_path)
|
99
|
-
expect(path).to match
|
98
|
+
expect(path).to match(/[a-z0-9]{32}/i)
|
100
99
|
expect(subject.send(:random_path)).to eql(path)
|
101
100
|
end
|
102
101
|
|
103
102
|
it "doesn't say something exists when there are no 404s" do
|
104
|
-
stub_request(:head,
|
105
|
-
stub_request(:head,
|
103
|
+
stub_request(:head, %r{http\://example.com/[a-z0-9]{32}}i).to_return(status: 200)
|
104
|
+
stub_request(:head, 'http://example.com/humans.txt').to_return(status: 200)
|
106
105
|
expect(subject.humans_txt?).to eql(nil)
|
107
106
|
end
|
108
107
|
end
|
@@ -1,51 +1,50 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SiteInspector::Endpoint::Cookies do
|
4
|
-
|
5
|
-
context "without cookies" do
|
4
|
+
context 'without cookies' do
|
6
5
|
subject do
|
7
|
-
stub_request(:head,
|
8
|
-
to_return(:
|
9
|
-
endpoint = SiteInspector::Endpoint.new(
|
6
|
+
stub_request(:head, 'http://example.com/')
|
7
|
+
.to_return(status: 200, body: '')
|
8
|
+
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
10
9
|
SiteInspector::Endpoint::Cookies.new(endpoint)
|
11
10
|
end
|
12
11
|
|
13
|
-
it
|
12
|
+
it 'knows when there are no cookies' do
|
14
13
|
expect(subject.cookies?).to eql(false)
|
15
14
|
expect(subject.all).to eql(nil)
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
context
|
18
|
+
context 'with cookies' do
|
20
19
|
subject do
|
21
20
|
cookies = [
|
22
|
-
CGI::Cookie
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
CGI::Cookie.new(
|
22
|
+
'name' => 'foo',
|
23
|
+
'value' => 'bar',
|
24
|
+
'domain' => 'example.com',
|
25
|
+
'path' => '/'
|
27
26
|
),
|
28
|
-
CGI::Cookie
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
CGI::Cookie.new(
|
28
|
+
'name' => 'foo2',
|
29
|
+
'value' => 'bar2',
|
30
|
+
'domain' => 'example.com',
|
31
|
+
'path' => '/'
|
33
32
|
)
|
34
|
-
].map
|
33
|
+
].map(&:to_s)
|
35
34
|
|
36
|
-
stub_request(:head,
|
37
|
-
to_return(:
|
38
|
-
endpoint = SiteInspector::Endpoint.new(
|
35
|
+
stub_request(:head, 'http://example.com/')
|
36
|
+
.to_return(status: 200, body: '', headers: { 'set-cookie' => cookies })
|
37
|
+
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
39
38
|
SiteInspector::Endpoint::Cookies.new(endpoint)
|
40
39
|
end
|
41
40
|
|
42
|
-
it
|
41
|
+
it 'knows when there are cookies' do
|
43
42
|
expect(subject.cookies?).to eql(true)
|
44
43
|
expect(subject.all.count).to eql(2)
|
45
44
|
end
|
46
45
|
|
47
|
-
it
|
48
|
-
expect(subject[
|
46
|
+
it 'returns a cookie by name' do
|
47
|
+
expect(subject['foo'].to_s).to match(/foo=bar/)
|
49
48
|
end
|
50
49
|
|
51
50
|
it "knows cookies aren't secure" do
|
@@ -53,19 +52,19 @@ describe SiteInspector::Endpoint::Cookies do
|
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
56
|
-
context
|
55
|
+
context 'with secure cookies' do
|
57
56
|
subject do
|
58
57
|
cookies = [
|
59
|
-
|
60
|
-
|
58
|
+
'foo=bar; domain=example.com; path=/; secure; HttpOnly',
|
59
|
+
'foo2=bar2; domain=example.com; path=/'
|
61
60
|
]
|
62
|
-
stub_request(:head,
|
63
|
-
to_return(:
|
64
|
-
endpoint = SiteInspector::Endpoint.new(
|
61
|
+
stub_request(:head, 'http://example.com/')
|
62
|
+
.to_return(status: 200, body: '', headers: { 'set-cookie' => cookies })
|
63
|
+
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
65
64
|
SiteInspector::Endpoint::Cookies.new(endpoint)
|
66
65
|
end
|
67
66
|
|
68
|
-
it
|
67
|
+
it 'knows cookies are secure' do
|
69
68
|
expect(subject.secure?).to eql(true)
|
70
69
|
end
|
71
70
|
end
|