Sha256: 99107d21cad805a46113c396160c101b581c0ba4e8af2a221dbc8084014178d4

Contents?: true

Size: 1023 Bytes

Versions: 4

Compression:

Stored size: 1023 Bytes

Contents

require 'bundler/audit/database'

module RubyAudit
  class Database < Bundler::Audit::Database
    def advisories_for(name, type)
      return enum_for(__method__, name, type) unless block_given?

      each_advisory_path_for(name, type) do |path|
        yield Bundler::Audit::Advisory.load(path)
      end
    end

    def check_ruby(ruby, &block)
      check(ruby, 'rubies', &block)
    end

    def check_library(library, &block)
      check(library, 'libraries', &block)
    end

    def check(object, type = 'gems')
      return enum_for(__method__, object, type) unless block_given?

      advisories_for(object.name, type) do |advisory|
        yield advisory if advisory.vulnerable?(object.version)
      end
    end

    protected

    def each_advisory_path(&block)
      Dir.glob(File.join(@path, '{gems,libraries,rubies}', '*', '*.yml'),
               &block)
    end

    def each_advisory_path_for(name, type = 'gems', &block)
      Dir.glob(File.join(@path, type, name, '*.yml'), &block)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby_audit-2.3.0 lib/ruby_audit/database.rb
ruby_audit-2.2.0 lib/ruby_audit/database.rb
ruby_audit-2.1.0 lib/ruby_audit/database.rb
ruby_audit-2.0.0 lib/ruby_audit/database.rb