class RubyAudit::Scanner
Public Class Methods
Public Instance Methods
Source
# File lib/ruby_audit/scanner.rb, line 19 def scan(options = {}, &block) return enum_for(__method__, options) unless block scan_ruby(options, &block) scan_rubygems(options, &block) self end
Source
# File lib/ruby_audit/scanner.rb, line 28 def scan_ruby(options = {}, &) version = if RUBY_PATCHLEVEL < 0 ruby_version else "#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}" end specs = [Version.new(RUBY_ENGINE, version)] scan_inner(specs, 'ruby', options, &) end
Source
# File lib/ruby_audit/scanner.rb, line 38 def scan_rubygems(options = {}, &) specs = [Version.new('rubygems-update', rubygems_version)] scan_inner(specs, 'rubygems', options, &) end
Private Instance Methods
Source
# File lib/ruby_audit/scanner.rb, line 45 def ruby_version # .gsub to separate strings (e.g., 2.1.0dev -> 2.1.0.dev, # 2.2.0preview1 -> 2.2.0.preview.1). `ruby --version`.split[1] .gsub(/(\d)([a-z]+)/, '\1.\2') .gsub(/([a-z]+)(\d)/, '\1.\2') end
Source
# File lib/ruby_audit/scanner.rb, line 53 def rubygems_version `gem --version`.strip end
Source
# File lib/ruby_audit/scanner.rb, line 57 def scan_inner(specs, type, options = {}) return enum_for(__method__, specs, type, options) unless block_given? ignore = Set[] ignore += options[:ignore] if options[:ignore] specs.each do |spec| @database.send(:"check_#{type}", spec) do |advisory| unless ignore.intersect?(advisory.identifiers.to_set) yield Bundler::Audit::Results::UnpatchedGem.new(spec, advisory) end end end end