class CVEList::RangeDir
Constants
- GLOB
`Dir.glob` pattern for all
CVE
`.json` files.
Attributes
path[R]
@return [String]
range[R]
@return [String]
Public Class Methods
new(path)
click to toggle source
Initializes the range directory.
@param [String] path
The path to the range directory.
Calls superclass method
CVEList::Directory::new
# File lib/cvelist/range_dir.rb, line 25 def initialize(path) super(path) @range = File.basename(@path) end
Public Instance Methods
[](cve_id)
click to toggle source
Loads a CVE
.
@param [String] cve_id
The CVE ID.
@return [CVE, nil]
The loaded CVE of `nil` if the CVE could not be found within the range directory.
# File lib/cvelist/range_dir.rb, line 53 def [](cve_id) cve_file = "#{cve_id}.json" cve_path = join(cve_file) if File.file?(cve_path) CVE.load(cve_path) end end
each() { |load| ... }
click to toggle source
Enumerates over the CVEs in the range directory.
@yield [cve]
The given block will be passed each CVE in the range directory.
@yieldparam [CVE] cve
A CVE within the range directory.
@return [Enumerator]
If no block is given, an Enumerator object will be returned.
# File lib/cvelist/range_dir.rb, line 86 def each return enum_for(__method__) unless block_given? files.each do |cve_path| begin yield CVE.load(cve_path) rescue InvalidJSON end end end
each_malformed() { |malformed_cve| ... }
click to toggle source
Enumerates over the malformed CVEs within the range directory.
@yield [malformed]
The given block will be passed each malformed
@yieldparam [MalformedCVE] malformed
@return [Enumerator]
If no block is given, an Enumerator object will be returned.
# File lib/cvelist/range_dir.rb, line 108 def each_malformed return enum_for(__method__) unless block_given? files.each do |cve_path| begin CVE.load(cve_path) rescue InvalidJSON => error yield MalformedCVE.new(cve_path,error) end end end
files()
click to toggle source
The JSON files within the range directory.
@return [Array<String>]
# File lib/cvelist/range_dir.rb, line 70 def files glob(GLOB).sort end
has_cve?(cve_id)
click to toggle source
Determines whether the range directory contains the given CVE
ID.
@param [String] cve_id
The given CVE ID.
@return [Boolean]
# File lib/cvelist/range_dir.rb, line 39 def has_cve?(cve_id) file?("#{cve_id}.json") end