added methods to download the modified metadata file
This commit is contained in:
parent
e6c8b0c0b2
commit
4736d84e7d
1 changed files with 11 additions and 4 deletions
|
@ -5,18 +5,18 @@ require 'json'
|
|||
|
||||
module NvdTools
|
||||
class NvdDownloader
|
||||
attr_accessor :version, :base_url, :base_filename, :years, :filenames_json, :client
|
||||
attr_accessor :version, :base_url, :base_filename, :years, :filenames_json, :filenames_meta, :client
|
||||
|
||||
MIN_YEAR = '2002'
|
||||
MAX_YEAR = '2019'
|
||||
AVAILABLE_YEARS = (MIN_YEAR..MAX_YEAR).to_a
|
||||
GZIPPED_JSON_EXTENSION = 'json.gz'
|
||||
|
||||
def initialize(client: NvdClient.new)
|
||||
|
||||
@base_filename = "nvdcve-#{client.version}-"
|
||||
@years = self.years
|
||||
@filenames_json = self.filenames(GZIPPED_JSON_EXTENSION)
|
||||
@filenames_json = self.filenames('json.gz')
|
||||
@filenames_meta = self.filenames('meta')
|
||||
@client = client
|
||||
end
|
||||
|
||||
|
@ -75,12 +75,19 @@ module NvdTools
|
|||
# of all of the json.gz from each year + recent + modified json feeds
|
||||
end
|
||||
|
||||
def modified_meta
|
||||
def modified_meta(filename)
|
||||
file = filenames('meta').select do |name|
|
||||
name == filename
|
||||
end.first
|
||||
|
||||
r = client.get(file)
|
||||
r.body.split("\r\n")
|
||||
# this should be a method that builds
|
||||
# the modified filename with the meta file extension included
|
||||
end
|
||||
|
||||
def check_metafile(metafile)
|
||||
|
||||
# open the metafile, build a hash of k/v pairs of the data inside of the file
|
||||
# check each k/v pair against the file on disk
|
||||
# return a new hash with the same k as before, but the value being a boolean true or false if the value from the k/v pair
|
||||
|
|
Loading…
Add table
Reference in a new issue