Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
ruby: ['3.0', 3.1, 3.2, 3.3, 3.4]
ruby: ['3.0', 3.1, 3.2, 3.3, 3.4, 4.0, 'ruby-head']

steps:
- name: Checkout code
Expand Down
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require: rubocop-performance
plugins: rubocop-performance
AllCops:
NewCops: enable
SuggestExtensions: false
TargetRubyVersion: 2.5
TargetRubyVersion: 3.0
Exclude:
- '*.gemspec'
- 'vendor/**/*'
Expand Down
2 changes: 1 addition & 1 deletion app/models/xml_rpc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def multi_call(methods_and_params = [], request_params = {})
method: :post,
body: ::XMLRPC::Create.new.methodCall(
'system.multicall',
methods_and_params.collect { |m| { methodName: m[0], params: m[1..-1] } }
methods_and_params.collect { |m| { methodName: m[0], params: m[1..] } }
)
)
)
Expand Down
4 changes: 2 additions & 2 deletions cms_scanner.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'rspec', '~> 3.13.0'
s.add_development_dependency 'rspec-its', '~> 2.0.0'
s.add_development_dependency 'rubocop', '~> 1.72.2'
s.add_development_dependency 'rubocop-performance', '~> 1.19.1'
s.add_development_dependency 'rubocop', '~> 1.82'
s.add_development_dependency 'rubocop-performance', '~> 1.26'
s.add_development_dependency 'simplecov', '~> 0.22.0'
s.add_development_dependency 'simplecov-lcov', '~> 0.8.0'
s.add_development_dependency 'webmock', '~> 3.25.0'
Expand Down
9 changes: 1 addition & 8 deletions lib/cms_scanner/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ def output(tpl, vars = {}, controller_name = nil)
puts render(tpl, vars, controller_name)
end

ERB_SUPPORTS_KVARGS = ::ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+

# @param [ String ] tpl
# @param [ Hash ] vars
# @param [ String ] controller_name
Expand All @@ -95,12 +93,7 @@ def render(tpl, vars = {}, controller_name = nil)

# '-' is used to disable new lines when -%> is used
# See http://www.ruby-doc.org/stdlib-2.1.1/libdoc/erb/rdoc/ERB.html
# Since ruby 2.6, KVARGS are supported and passing argument is deprecated in ruby 3+
if ERB_SUPPORTS_KVARGS
ERB.new(File.read(view_path(tpl)), trim_mode: '-').result(binding)
else
ERB.new(File.read(view_path(tpl)), nil, '-').result(binding)
end
ERB.new(File.read(view_path(tpl)), trim_mode: '-').result(binding)
end

# @param [ Hash ] vars
Expand Down
14 changes: 11 additions & 3 deletions lib/cms_scanner/public_suffix/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def ==(other)

# @return [ Boolean ]
#
def match(pattern)
def match?(pattern)
pattern = PublicSuffix.parse(pattern) unless pattern.is_a?(PublicSuffix::Domain)

return name == pattern.name unless pattern.trd
Expand All @@ -19,6 +19,14 @@ def match(pattern)
matching_pattern?(pattern)
end

# @deprecated Use {#match?} instead
# rubocop:disable Naming/PredicateMethod
def match(pattern)
warn 'DEPRECATION WARNING: PublicSuffix::Domain#match is deprecated, use #match? instead'
match?(pattern)
end
# rubocop:enable Naming/PredicateMethod

protected

# @rturn [ Boolean ]
Expand All @@ -28,9 +36,9 @@ def matching_pattern?(pattern)

case pattern_trds.first
when '*'
pattern_trds[1..-1] == domain_trds[1..-1]
pattern_trds[1..] == domain_trds[1..]
when '**'
pa = pattern_trds[1..-1]
pa = pattern_trds[1..]
pa_size = pa.size

domain_trds[domain_trds.size - pa_size, pa_size] == pa
Expand Down
8 changes: 4 additions & 4 deletions lib/cms_scanner/target/platform/php.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ module Platform
# Some PHP specific implementation
module PHP
DEBUG_LOG_PATTERN = /(?:\[\d{2}-[a-zA-Z]{3}-\d{4}\s\d{2}:\d{2}:\d{2}\s[A-Z]{3}\]|
PHP\s(?:Fatal|Warning|Strict|Error|Notice):)/x.freeze
FPD_PATTERN = /Fatal error:.+? in (.+?) on/.freeze
ERROR_LOG_PATTERN = /PHP Fatal error/i.freeze
PHP\s(?:Fatal|Warning|Strict|Error|Notice):)/x
FPD_PATTERN = /Fatal error:.+? in (.+?) on/
ERROR_LOG_PATTERN = /PHP Fatal error/i

# @param [ String ] path
# @param [ Regexp ] pattern
Expand All @@ -20,7 +20,7 @@ def log_file?(path, pattern, params = {})
# which can be huge (~ 2Go)
res = head_and_get(path, [200], get: params.merge(headers: { 'Range' => 'bytes=0-700' }))

res.body&.match?(pattern) ? true : false
res.body&.match?(pattern) || false
end

# @param [ String ] path
Expand Down
6 changes: 3 additions & 3 deletions lib/cms_scanner/target/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def scope_url_pattern
domains = [uri.host + uri.path]

domains += if scope.domains.empty?
Array(scope.invalid_domains[1..-1])
Array(scope.invalid_domains[1..])
else
Array(scope.domains[1..-1]).map(&:to_s) + scope.invalid_domains
Array(scope.domains[1..]).map(&:to_s) + scope.invalid_domains
end

domains.map! { |d| Regexp.escape(d.delete_suffix('/')).gsub('\*', '.*').gsub('/', '\\\\\?/') }
Expand Down Expand Up @@ -91,7 +91,7 @@ def include?(host)
if PublicSuffix.valid?(host, ignore_private: true)
domain = PublicSuffix.parse(host, ignore_private: true)

domains.each { |d| return true if domain.match(d) }
domains.each { |d| return true if domain.match?(d) }
else
invalid_domains.each { |d| return true if host == d }
end
Expand Down
6 changes: 2 additions & 4 deletions spec/lib/finders/finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
context 'when opts[:show_progression] is true' do
let(:opts) { { show_progression: true } }

it 'uses the default progress-bar output' do
expected_bar_class = ENV['GITHUB_ACTION'] ? ProgressBar::Outputs::NonTty : ProgressBar::Outputs::Tty

expect(finder.progress_bar.send(:output)).to be_a expected_bar_class
it 'does not use null output' do
expect(finder.progress_bar.send(:output)).not_to be_a ProgressBar::Outputs::Null
end
end

Expand Down
24 changes: 12 additions & 12 deletions spec/lib/public_suffix/domain_spec.rb
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
# frozen_string_literal: true

describe PublicSuffix::Domain do
describe '#match' do
describe '#match?' do
it 'returns true' do
expect(PublicSuffix.parse('g.com').match('g.com')).to eql true
expect(PublicSuffix.parse('g.com').match?('g.com')).to eql true
end

it 'returns true' do
expect(PublicSuffix.parse('s.g.com').match('*.g.com')).to eql true
expect(PublicSuffix.parse('s.g.com').match?('*.g.com')).to eql true
end

it 'returns false' do
expect(PublicSuffix.parse('a.b.g.com').match('*.g.com')).to eql false
expect(PublicSuffix.parse('a.b.g.com').match?('*.g.com')).to eql false
end

it 'returns true' do
expect(PublicSuffix.parse('a.b.g.com').match('*.b.g.com')).to eql true
expect(PublicSuffix.parse('a.b.g.com').match?('*.b.g.com')).to eql true
end

it 'returns true' do
expect(PublicSuffix.parse('a.b.g.com').match('**.g.com')).to eql true
expect(PublicSuffix.parse('a.b.g.com').match?('**.g.com')).to eql true
end

it 'returns false' do
expect(PublicSuffix.parse('a.b.y.g.com').match('**.b.g.com')).to eql false
expect(PublicSuffix.parse('a.b.y.g.com').match?('**.b.g.com')).to eql false
end

it 'returns false' do
expect(PublicSuffix.parse('w.g.com').match('*.g2.com')).to eql false
expect(PublicSuffix.parse('w.g.com').match?('*.g2.com')).to eql false
end

it 'returns true' do
expect(PublicSuffix.parse('a.b.g.com').match('a.b.g.com')).to eql true
expect(PublicSuffix.parse('a.b.g.com').match?('a.b.g.com')).to eql true
end

it 'returns false' do
expect(PublicSuffix.parse('a.b.g.com').match('a.y.g.com')).to eql false
expect(PublicSuffix.parse('a.b.g.com').match?('a.y.g.com')).to eql false
end

it 'returns true' do
expect(PublicSuffix.parse('a.b.c.d.g.com').match('**.c.d.g.com')).to eql true
expect(PublicSuffix.parse('a.b.c.d.g.com').match?('**.c.d.g.com')).to eql true
end

it 'returns true' do
expect(PublicSuffix.parse('a.b.c.d.g.com').match('*.b.c.d.g.com')).to eql true
expect(PublicSuffix.parse('a.b.c.d.g.com').match?('*.b.c.d.g.com')).to eql true
end
end
end