From 57c6c2d4714bc1ab1421b1f20765c9b211ab5421 Mon Sep 17 00:00:00 2001 From: erwanlr Date: Sun, 12 Apr 2020 18:21:23 +0200 Subject: [PATCH] Removes support for Ruby 2.4 as EOL --- .github/workflows/build.yml | 2 +- .rubocop.yml | 2 +- app/finders/plugin_version/readme.rb | 8 +++--- lib/wpscan/db/updater.rb | 26 +++++++++---------- .../dynamic_finder/version/config_parser.rb | 10 +++---- wpscan.gemspec | 4 +-- 6 files changed, 23 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e487aa449..32149a8da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - ruby: [2.4, 2.5, 2.6, 2.7] + ruby: [2.5, 2.6, 2.7] steps: - name: Checkout code diff --git a/.rubocop.yml b/.rubocop.yml index f7e386e4c..1b409334c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,6 @@ require: rubocop-performance AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.5 Exclude: - '*.gemspec' - 'vendor/**/*' diff --git a/app/finders/plugin_version/readme.rb b/app/finders/plugin_version/readme.rb index 58807ee42..82477dfbf 100644 --- a/app/finders/plugin_version/readme.rb +++ b/app/finders/plugin_version/readme.rb @@ -68,11 +68,9 @@ def from_changelog_section(body) extracted_versions = extracted_versions.select { |x| x =~ /[0-9]+/ } sorted = extracted_versions.sort do |x, y| - begin - Gem::Version.new(x) <=> Gem::Version.new(y) - rescue StandardError - 0 - end + Gem::Version.new(x) <=> Gem::Version.new(y) + rescue StandardError + 0 end sorted.last diff --git a/lib/wpscan/db/updater.rb b/lib/wpscan/db/updater.rb index c1514d4cb..de055313e 100644 --- a/lib/wpscan/db/updater.rb +++ b/lib/wpscan/db/updater.rb @@ -139,24 +139,22 @@ def update updated = [] FILES.each do |filename| - begin - db_checksum = remote_file_checksum(filename) + db_checksum = remote_file_checksum(filename) - # Checking if the file needs to be updated - next if File.exist?(local_file_path(filename)) && db_checksum == local_file_checksum(filename) + # Checking if the file needs to be updated + next if File.exist?(local_file_path(filename)) && db_checksum == local_file_checksum(filename) - create_backup(filename) - dl_checksum = download(filename) + create_backup(filename) + dl_checksum = download(filename) - raise Error::ChecksumsMismatch, filename unless dl_checksum == db_checksum + raise Error::ChecksumsMismatch, filename unless dl_checksum == db_checksum - updated << filename - rescue StandardError => e - restore_backup(filename) - raise e - ensure - delete_backup(filename) if File.exist?(backup_file_path(filename)) - end + updated << filename + rescue StandardError => e + restore_backup(filename) + raise e + ensure + delete_backup(filename) if File.exist?(backup_file_path(filename)) end File.write(last_update_file, Time.now) diff --git a/lib/wpscan/finders/dynamic_finder/version/config_parser.rb b/lib/wpscan/finders/dynamic_finder/version/config_parser.rb index 0d44ea72a..29e52daa7 100644 --- a/lib/wpscan/finders/dynamic_finder/version/config_parser.rb +++ b/lib/wpscan/finders/dynamic_finder/version/config_parser.rb @@ -21,13 +21,11 @@ def parse(body) parsers = ALLOWED_PARSERS.include?(self.class::PARSER) ? [self.class::PARSER] : ALLOWED_PARSERS parsers.each do |parser| - begin - parsed = parser.respond_to?(:safe_load) ? parser.safe_load(body) : parser.load(body) + parsed = parser.respond_to?(:safe_load) ? parser.safe_load(body) : parser.load(body) - return parsed if parsed.is_a?(Hash) || parsed.is_a?(Array) - rescue StandardError - next - end + return parsed if parsed.is_a?(Hash) || parsed.is_a?(Array) + rescue StandardError + next end nil # Make sure nil is returned in case none of the parsers managed to parse the body correctly diff --git a/wpscan.gemspec b/wpscan.gemspec index f0a27b7ae..d5d039342 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.4' + s.required_ruby_version = '>= 2.5' s.authors = ['WPScanTeam'] s.date = Time.now.utc.strftime('%Y-%m-%d') s.email = ['team@wpscan.org'] @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.executables = ['wpscan'] s.require_paths = ['lib'] - s.add_dependency 'cms_scanner', '~> 0.8.6' + s.add_dependency 'cms_scanner', '~> 0.9.0' s.add_development_dependency 'bundler', '>= 1.6' s.add_development_dependency 'memory_profiler', '~> 0.9.13'