diff --git a/classes/nvd_downloader.rb b/classes/nvd_downloader.rb index b7d6e3b..26d0e32 100644 --- a/classes/nvd_downloader.rb +++ b/classes/nvd_downloader.rb @@ -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