lib/polariscope/scanner/ruby_scanner.rb in polariscope-0.3.0 vs lib/polariscope/scanner/ruby_scanner.rb in polariscope-0.4.0
- old
+ new
@@ -1,29 +1,27 @@
# frozen_string_literal: true
-require 'bundler'
require 'bundler/audit/database'
module Polariscope
module Scanner
class RubyScanner
- def initialize(lockfile_parser)
- @lockfile_parser = lockfile_parser
+ def initialize(bundler_ruby_version)
+ @bundler_ruby_version = bundler_ruby_version
end
def version
- lockfile_ruby_version&.gem_version
+ bundler_ruby_version&.gem_version
end
def vulnerable_advisories
version ? advisories.select { |a| a.vulnerable?(version) } : []
end
private
- attr_reader :lockfile_parser
- attr_reader :bundler_audit_database
+ attr_reader :bundler_ruby_version
def advisories
cve_paths.map { |path| Bundler::Audit::Advisory.load(path) }
end
@@ -32,14 +30,10 @@
def cve_paths
Dir.glob(File.join(Bundler::Audit::Database.path, 'rubies', engine, '*.yml'))
end
def engine
- lockfile_ruby_version.engine
- end
-
- def lockfile_ruby_version
- @lockfile_ruby_version ||= Bundler::RubyVersion.from_string(@lockfile_parser.ruby_version)
+ bundler_ruby_version.engine
end
end
end
end