Sha256: fb82ca78882a3247cc86433e19bd698eaa6f254380be78a54f366345dbc4b828

Contents?: true

Size: 956 Bytes

Versions: 1

Compression:

Stored size: 956 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, &)
      check(ruby, 'rubies', &)
    end

    def check_rubygems(rubygems, &)
      check(rubygems, 'gems', &)
    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(&)
      Dir.glob(File.join(@path, '{gems,rubies}', '*', '*.yml'), &)
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_audit-3.0.0 lib/ruby_audit/database.rb