Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions resources/scripts/rb_ingest_vuln_cve_pg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ def set_cve_files
end
end

# def fetch_sha256_from_meta(year)
# meta_url = "https://nvd.nist.gov/feeds/json/cve/2.0/nvdcve-2.0-#{year}.meta"
# meta_file = "nvdcve-2.0-#{year}.meta"

# uri = URI(meta_url)
# File.write(meta_file, Net::HTTP.get(uri))

# sha256 = File.readlines(meta_file).reverse_each.find do |line|
# line.start_with?('sha256:')
# end&.split(':', 2)&.last&.strip

# puts sha256
# sha256
# end

def import_cve_files
complete_download = true
@cve_url_files.each do |url|
Expand All @@ -73,14 +58,13 @@ def import_cve_files
# TODO: Before downloading we should check if the file is already downloaded and valid, to avoid unnecessary downloads and processing
# https://nvd.nist.gov/feeds/json/cve/2.0/nvdcve-2.0-#{year}.meta
# sha256sum = `curl -s #{url.sub('.json.gz', '.meta')} | grep 'sha256' | awk '{print $2}'`.strip

unless download_gz_file_with_retries(url, filename)
filepath = @download_path + filename
unless download_gz_file_with_retries(url, filepath)
puts "ERROR: Could not download #{filename} after multiple attempts."
complete_download = false
break
end

filepath = @download_path + filename
`gzip -dkf #{filepath}`
file_json = filename.sub(/\.gz$/, '')

Expand Down
Loading