New upstream version 0.5.2
Sophie Brun
4 years ago
16 | 16 | - 2.6.0 |
17 | 17 | - 2.6.1 |
18 | 18 | - 2.6.2 |
19 | - 2.6.3 | |
19 | 20 | - ruby-head |
20 | 21 | before_install: |
21 | 22 | - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" |
19 | 19 | s.require_paths = ['lib'] |
20 | 20 | |
21 | 21 | s.add_dependency 'nokogiri', '~> 1.10.0' |
22 | s.add_dependency 'opt_parse_validator', '~> 1.7.2' | |
23 | s.add_dependency 'public_suffix', '~> 3.0.0' | |
22 | s.add_dependency 'opt_parse_validator', '~> 1.7.3' | |
23 | s.add_dependency 'public_suffix', '>= 3.0', '< 3.2' | |
24 | 24 | s.add_dependency 'ruby-progressbar', '~> 1.10.0' |
25 | 25 | s.add_dependency 'typhoeus', '~> 1.3.0' |
26 | 26 | s.add_dependency 'xmlrpc', '~> 0.3' |
27 | 27 | s.add_dependency 'yajl-ruby', '~> 1.4.1' # Better JSON parser regarding memory usage |
28 | 28 | |
29 | s.add_development_dependency 'bundler', '>= 1.6' | |
30 | s.add_development_dependency 'coveralls', '~> 0.8.0' | |
31 | s.add_development_dependency 'rake', '~> 12.3' | |
32 | s.add_development_dependency 'rspec', '~> 3.8.0' | |
33 | s.add_development_dependency 'rspec-its', '~> 1.3.0' | |
34 | s.add_development_dependency 'rubocop', '~> 0.67.2' | |
35 | s.add_development_dependency 'simplecov', '~> 0.16.1' | |
36 | s.add_development_dependency 'webmock', '~> 3.5.1' | |
29 | s.add_development_dependency 'bundler', '>= 1.6' | |
30 | s.add_development_dependency 'coveralls', '~> 0.8.0' | |
31 | s.add_development_dependency 'rake', '~> 12.3' | |
32 | s.add_development_dependency 'rspec', '~> 3.8.0' | |
33 | s.add_development_dependency 'rspec-its', '~> 1.3.0' | |
34 | s.add_development_dependency 'rubocop', '~> 0.71.0' | |
35 | s.add_development_dependency 'rubocop-performance', '~> 1.3.0' | |
36 | s.add_development_dependency 'simplecov', '~> 0.16.1' | |
37 | s.add_development_dependency 'webmock', '~> 3.6.0' | |
37 | 38 | end |
42 | 42 | # |
43 | 43 | # @return [ Regexp ] The pattern related to the target url and in scope domains, |
44 | 44 | # it also matches escaped /, such as in JSON JS data: http:\/\/t.com\/ |
45 | # rubocop:disable Metrics/AbcSize | |
45 | 46 | def scope_url_pattern |
46 | 47 | return @scope_url_pattern if @scope_url_pattern |
47 | 48 | |
48 | domains = [uri.host + uri.path] + scope.domains[1..-1]&.map(&:to_s) + scope.invalid_domains | |
49 | domains = [uri.host + uri.path] | |
50 | ||
51 | domains += if scope.domains.empty? | |
52 | [*scope.invalid_domains[1..-1]] | |
53 | else | |
54 | [*scope.domains[1..-1]].map(&:to_s) + scope.invalid_domains | |
55 | end | |
49 | 56 | |
50 | 57 | domains.map! { |d| Regexp.escape(d.gsub(%r{/$}, '')).gsub('\*', '.*').gsub('/', '\\\\\?/') } |
51 | 58 | |
59 | domains[0].gsub!(Regexp.escape(uri.host), Regexp.escape(uri.host) + '(?::\\d+)?') if uri.port | |
60 | ||
52 | 61 | @scope_url_pattern = %r{https?:\\?/\\?/(?:#{domains.join('|')})\\?/?}i |
53 | 62 | end |
63 | # rubocop:enable Metrics/AbcSize | |
54 | 64 | |
55 | 65 | # Scope Implementation |
56 | 66 | class Scope |
50 | 50 | # |
51 | 51 | # @return [ Array<String> ] The first level of directories/files listed, |
52 | 52 | # or an empty array if none |
53 | def directory_listing_entries( | |
54 | path = nil, params = {}, | |
55 | selector = 'pre a', ignore = /parent directory/i | |
56 | ) | |
53 | def directory_listing_entries(path = nil, params = {}, selector = 'pre a', ignore = /parent directory/i) | |
57 | 54 | return [] unless directory_listing?(path, params) |
58 | 55 | |
59 | 56 | found = [] |
111 | 111 | describe '#scope_url_pattern' do |
112 | 112 | context 'when no scope given' do |
113 | 113 | its(:scope_url_pattern) { should eql %r{https?:\\?/\\?/(?:e\.org)\\?/?}i } |
114 | ||
115 | context 'when target is an invalid domain for PublicSuffix' do | |
116 | let(:url) { 'http://wp-lab/' } | |
117 | ||
118 | its(:scope_url_pattern) { should eql %r{https?:\\?/\\?/(?:wp\-lab)\\?/?}i } | |
119 | end | |
120 | ||
121 | context 'when a port is present in the target URL' do | |
122 | let(:url) { 'http://wp.lab:82/aa' } | |
123 | ||
124 | its(:scope_url_pattern) { should eql %r{https?:\\?/\\?/(?:wp\.lab(?::\d+)?\\?/aa)\\?/?}i } | |
125 | its(:scope_url_pattern) { should match 'https://wp.lab:82/aa' } | |
126 | end | |
114 | 127 | end |
115 | 128 | |
116 | 129 | context 'when scope given' do |
117 | let(:opts) { super().merge(scope: ['*.cdn.org', 'wp-lamp']) } | |
130 | let(:opts) { super().merge(scope: ['*.cdn.org', 'wp-lamp', '192.168.1.1']) } | |
118 | 131 | |
119 | its(:scope_url_pattern) { should eql %r{https?:\\?/\\?/(?:e\.org|.*\.cdn\.org|wp\-lamp)\\?/?}i } | |
132 | its(:scope_url_pattern) { should eql %r{https?:\\?/\\?/(?:e\.org|.*\.cdn\.org|192\.168\.1\.1|wp\-lamp)\\?/?}i } | |
120 | 133 | |
121 | 134 | context 'when target URL has a subdir' do |
122 | 135 | let(:url) { 'https://e.org/blog/test' } |
123 | 136 | |
124 | its(:scope_url_pattern) { should eql %r{https?:\\?/\\?/(?:e\.org\\?/blog\\?/test|.*\.cdn\.org|wp\-lamp)\\?/?}i } | |
137 | its(:scope_url_pattern) do | |
138 | should eql %r{https?:\\?/\\?/(?:e\.org\\?/blog\\?/test|.*\.cdn\.org|192\.168\.1\.1|wp\-lamp)\\?/?}i | |
139 | end | |
125 | 140 | end |
126 | 141 | end |
127 | 142 | end |