New upstream version 0.8.1
Sophie Brun
4 years ago
|
0 |
name: Ruby Gem
|
|
1 |
|
|
2 |
on:
|
|
3 |
release:
|
|
4 |
types: [published]
|
|
5 |
|
|
6 |
jobs:
|
|
7 |
build:
|
|
8 |
name: Build + Publish
|
|
9 |
runs-on: ubuntu-latest
|
|
10 |
|
|
11 |
steps:
|
|
12 |
- uses: actions/checkout@master
|
|
13 |
- name: Set up Ruby 2.6
|
|
14 |
uses: actions/setup-ruby@v1
|
|
15 |
with:
|
|
16 |
ruby-version: 2.6.x
|
|
17 |
|
|
18 |
#- name: Publish to GPR
|
|
19 |
# run: |
|
|
20 |
# mkdir -p $HOME/.gem
|
|
21 |
# touch $HOME/.gem/credentials
|
|
22 |
# chmod 0600 $HOME/.gem/credentials
|
|
23 |
# printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
|
24 |
# gem build *.gemspec
|
|
25 |
# gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
|
26 |
# env:
|
|
27 |
# GEM_HOST_API_KEY: ${{secrets.GITHUB_TOKEN}}
|
|
28 |
# OWNER: wpscanteam
|
|
29 |
|
|
30 |
- name: Publish to RubyGems
|
|
31 |
run: |
|
|
32 |
mkdir -p $HOME/.gem
|
|
33 |
touch $HOME/.gem/credentials
|
|
34 |
chmod 0600 $HOME/.gem/credentials
|
|
35 |
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
|
36 |
gem build *.gemspec
|
|
37 |
gem push *.gem
|
|
38 |
env:
|
|
39 |
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|
4 | 4 |
- '*.gemspec'
|
5 | 5 |
- 'vendor/**/*'
|
6 | 6 |
- 'example/**/*'
|
|
7 |
Layout/LineLength:
|
|
8 |
Max: 120
|
7 | 9 |
Lint/UriEscapeUnescape:
|
8 | 10 |
Enabled: false
|
9 | 11 |
Metrics/AbcSize:
|
|
13 | 15 |
- 'spec/**/*'
|
14 | 16 |
Metrics/CyclomaticComplexity:
|
15 | 17 |
Max: 10
|
16 | |
Metrics/LineLength:
|
17 | |
Max: 120
|
18 | 18 |
Metrics/MethodLength:
|
19 | 19 |
Max: 18
|
20 | 20 |
Exclude:
|
24 | 24 |
- 2.6.3
|
25 | 25 |
- 2.6.4
|
26 | 26 |
- 2.6.5
|
27 | |
before_install:
|
28 | |
- "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
|
29 | |
- gem update --system
|
|
27 |
- 2.7.0
|
30 | 28 |
script:
|
31 | 29 |
- bundle exec rubocop
|
32 | 30 |
- bundle exec rspec
|
34 | 34 |
s.add_development_dependency 'rake', '~> 13.0'
|
35 | 35 |
s.add_development_dependency 'rspec', '~> 3.9.0'
|
36 | 36 |
s.add_development_dependency 'rspec-its', '~> 1.3.0'
|
37 | |
s.add_development_dependency 'rubocop', '~> 0.76.0'
|
|
37 |
s.add_development_dependency 'rubocop', '~> 0.78.0'
|
38 | 38 |
s.add_development_dependency 'rubocop-performance', '~> 1.5.0'
|
39 | 39 |
s.add_development_dependency 'simplecov', '~> 0.16.1'
|
40 | 40 |
s.add_development_dependency 'webmock', '~> 3.7.0'
|
1 | 1 |
|
2 | 2 |
# Version
|
3 | 3 |
module CMSScanner
|
4 | |
VERSION = '0.7.1'
|
|
4 |
VERSION = '0.8.1'
|
5 | 5 |
end
|
22 | 22 |
@uri = Addressable::URI.parse(site_url).normalize
|
23 | 23 |
end
|
24 | 24 |
|
25 | |
# Used for convenience
|
26 | |
#
|
27 | |
# URI.encode is preferered over Addressable::URI.encode as it will encode
|
28 | |
# leading # character:
|
29 | |
# URI.encode('#t#') => %23t%23
|
30 | |
# Addressable::URI.encode('#t#') => #t%23
|
31 | |
#
|
32 | 25 |
# @param [ String ] path Optional path to merge with the uri
|
33 | 26 |
#
|
34 | 27 |
# @return [ String ]
|
35 | 28 |
def url(path = nil)
|
36 | 29 |
return @uri.to_s unless path
|
37 | 30 |
|
38 | |
@uri.join(URI.encode(path)).to_s
|
|
31 |
@uri.join(Addressable::URI.encode(path).gsub('#', '%23')).to_s
|
39 | 32 |
end
|
40 | 33 |
|
41 | 34 |
attr_writer :homepage_res
|
|
61 | 54 |
|
62 | 55 |
# @return [ String ] The URL of an unlikely existant page
|
63 | 56 |
def error_404_url
|
64 | |
@error_404_url ||= non_existant_page_url
|
65 | |
end
|
66 | |
|
67 | |
# @return [ String ] The URL of an unlikely existant page
|
68 | |
# TODO: This will be removed in the next major version (0.7)
|
69 | |
def non_existant_page_url
|
70 | |
uri.join(Digest::MD5.hexdigest(rand(999_999).to_s)[0..6] + '.html').to_s
|
|
57 |
@error_404_url ||= uri.join(Digest::MD5.hexdigest(rand(999_999).to_s)[0..6] + '.html').to_s
|
71 | 58 |
end
|
72 | 59 |
|
73 | 60 |
# Checks if the remote website is up.
|
|
111 | 98 |
|
112 | 99 |
return unless [301, 302].include?(NS::Browser.get(url).code)
|
113 | 100 |
|
114 | |
res = NS::Browser.get(url, followlocation: true)
|
|
101 |
res = NS::Browser.get(url, followlocation: true, maxredirs: 10)
|
115 | 102 |
|
116 | 103 |
res.effective_url == url ? nil : res.effective_url
|
117 | 104 |
end
|
171 | 171 |
stub_request(:get, target_urls.key(2)).to_return(status: 200, body: 'rspec')
|
172 | 172 |
end
|
173 | 173 |
|
174 | |
it 'yield the expected items' do
|
|
174 |
it 'yield the expected item' do
|
175 | 175 |
expect { |b| finder.enumerate(target_urls, opts, &b) }.to yield_with_args(Typhoeus::Response, 2)
|
176 | 176 |
end
|
177 | 177 |
end
|
|
204 | 204 |
expect { |b| finder.enumerate(target_urls, opts, &b) }.to yield_successive_args(
|
205 | 205 |
[Typhoeus::Response, 1], [Typhoeus::Response, 2]
|
206 | 206 |
)
|
|
207 |
end
|
|
208 |
end
|
|
209 |
|
|
210 |
context 'when one header matches but the other not, using negative look-arounds' do
|
|
211 |
let(:opts) { super().merge(exclude_content: /\A((?!x\-cacheable)[\s\S])*\z/i) }
|
|
212 |
|
|
213 |
before do
|
|
214 |
stub_request(:head, target_urls.keys.last).and_return(status: 200, headers: { 'x-cacheable' => 'YES' })
|
|
215 |
end
|
|
216 |
|
|
217 |
it 'yield the expected item' do
|
|
218 |
expect { |b| finder.enumerate(target_urls, opts, &b) }.to yield_with_args(Typhoeus::Response, 2)
|
207 | 219 |
end
|
208 | 220 |
end
|
209 | 221 |
end
|