Sha256: 26e8c5c9c0032690a603307f3b497be76f32bb54d3a0cc923968658e330cdd3b

Contents?: true

Size: 989 Bytes

Versions: 4

Compression:

Stored size: 989 Bytes

Contents

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-1.3.0 lib/ruby_audit/database.rb
ruby_audit-1.2.0 lib/ruby_audit/database.rb
ruby_audit-1.1.0 lib/ruby_audit/database.rb
ruby_audit-1.0.1 lib/ruby_audit/database.rb