From 888779f81b160c338da80d8526025ec57953e78b Mon Sep 17 00:00:00 2001 From: erwanlr Date: Thu, 4 Apr 2019 15:40:21 +0100 Subject: [PATCH] Support of Ruby 2.3 removed as its life ended --- .rubocop.yml | 2 +- .travis.yml | 10 +--------- app/controllers/core.rb | 4 ++-- .../interesting_findings/emergency_pwd_reset_script.rb | 2 +- app/finders/users/author_posts.rb | 2 +- app/models/timthumb.rb | 2 +- lib/wpscan/target/platform/wordpress.rb | 2 +- .../target/platform/wordpress/custom_directories.rb | 4 ++-- wpscan.gemspec | 2 +- 9 files changed, 11 insertions(+), 19 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d4b34b0a..0cb4f8ca 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.4 Exclude: - '*.gemspec' - 'vendor/**/*' diff --git a/.travis.yml b/.travis.yml index 7401918e..9a111bf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,20 +2,12 @@ language: ruby sudo: false cache: bundler rvm: - - 2.3.0 - - 2.3.1 - - 2.3.2 - - 2.3.3 - - 2.3.4 - - 2.3.5 - - 2.3.6 - - 2.3.7 - - 2.3.8 - 2.4.1 - 2.4.2 - 2.4.3 - 2.4.4 - 2.4.5 + - 2.4.6 - 2.5.0 - 2.5.1 - 2.5.2 diff --git a/app/controllers/core.rb b/app/controllers/core.rb index 5c2f0d3a..5143da7a 100644 --- a/app/controllers/core.rb +++ b/app/controllers/core.rb @@ -39,7 +39,7 @@ module WPScan output('@notice', msg: 'It seems like you have not updated the database for some time.') print '[?] Do you want to update now? [Y]es [N]o, default: [N]' - Readline.readline =~ /^y/i ? true : false + /^y/i.match?(Readline.readline) ? true : false end def update_db @@ -69,7 +69,7 @@ module WPScan def check_wordpress_state raise Error::WordPressHosted if target.wordpress_hosted? - if Addressable::URI.parse(target.homepage_url).path =~ %r{/wp-admin/install.php$}i + if %r{/wp-admin/install.php$}i.match?(Addressable::URI.parse(target.homepage_url).path) output('not_fully_configured', url: target.homepage_url) diff --git a/app/finders/interesting_findings/emergency_pwd_reset_script.rb b/app/finders/interesting_findings/emergency_pwd_reset_script.rb index f4efa291..8186e348 100644 --- a/app/finders/interesting_findings/emergency_pwd_reset_script.rb +++ b/app/finders/interesting_findings/emergency_pwd_reset_script.rb @@ -14,7 +14,7 @@ module WPScan Model::EmergencyPwdResetScript.new( target.url(path), - confidence: res.body =~ /password/i ? 100 : 40, + confidence: /password/i.match?(res.body) ? 100 : 40, found_by: DIRECT_ACCESS, references: { url: 'https://codex.wordpress.org/Resetting_Your_Password#Using_the_Emergency_Password_Reset_Script' diff --git a/app/finders/users/author_posts.rb b/app/finders/users/author_posts.rb index 61968d9c..b873dd45 100644 --- a/app/finders/users/author_posts.rb +++ b/app/finders/users/author_posts.rb @@ -50,7 +50,7 @@ module WPScan if uri.path =~ %r{/author/([^/\b]+)/?\z}i usernames << [Regexp.last_match[1], 'Author Pattern', 100] - elsif uri.query =~ /author=[0-9]+/ + elsif /author=[0-9]+/.match?(uri.query) usernames << [node.text.to_s.strip, 'Display Name', 30] end end diff --git a/app/models/timthumb.rb b/app/models/timthumb.rb index a4973752..2da163c4 100644 --- a/app/models/timthumb.rb +++ b/app/models/timthumb.rb @@ -63,7 +63,7 @@ module WPScan def webshot_enabled? res = Browser.get(url, params: { webshot: 1, src: "http://#{default_allowed_domains.sample}" }) - res.body =~ /WEBSHOT_ENABLED == true/ ? false : true + /WEBSHOT_ENABLED == true/.match?(res.body) ? false : true end # @return [ Array ] The default allowed domains (between the 2.0 and 2.8.13) diff --git a/lib/wpscan/target/platform/wordpress.rb b/lib/wpscan/target/platform/wordpress.rb index 8bcb1515..849e3e02 100644 --- a/lib/wpscan/target/platform/wordpress.rb +++ b/lib/wpscan/target/platform/wordpress.rb @@ -79,7 +79,7 @@ module WPScan end def wordpress_hosted? - uri.host =~ /\.wordpress\.com$/i ? true : false + /\.wordpress\.com$/i.match?(uri.host) ? true : false end # @param [ String ] username diff --git a/lib/wpscan/target/platform/wordpress/custom_directories.rb b/lib/wpscan/target/platform/wordpress/custom_directories.rb index c653b609..1fbdbddc 100644 --- a/lib/wpscan/target/platform/wordpress/custom_directories.rb +++ b/lib/wpscan/target/platform/wordpress/custom_directories.rb @@ -112,9 +112,9 @@ module WPScan def url(path = nil) return @uri.to_s unless path - if path =~ %r{wp\-content/plugins}i + if %r{wp\-content/plugins}i.match?(path) path = +path.gsub('wp-content/plugins', plugins_dir) - elsif path =~ /wp\-content/i + elsif /wp\-content/i.match?(path) path = +path.gsub('wp-content', content_dir) elsif path[0] != '/' && sub_dir path = "#{sub_dir}/#{path}" diff --git a/wpscan.gemspec b/wpscan.gemspec index 1674b26e..4b7c13b4 100644 --- a/wpscan.gemspec +++ b/wpscan.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |s| s.name = 'wpscan' s.version = WPScan::VERSION s.platform = Gem::Platform::RUBY - s.required_ruby_version = '>= 2.3' + s.required_ruby_version = '>= 2.4' s.authors = ['WPScanTeam'] s.date = Time.now.utc.strftime('%Y-%m-%d') s.email = ['team@wpscan.org']