added a class that will pull CNA organizationName and securityAdvisories
This commit is contained in:
parent
4f09b9d4ce
commit
722d5b8762
2 changed files with 1331 additions and 0 deletions
43
tools/cve_cna_security_advisories/cna_security_advisories.rb
Executable file
43
tools/cve_cna_security_advisories/cna_security_advisories.rb
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env ruby
|
||||
# outputs the list of CNA organizationNames and the securityAdvisory urls from the json file here:
|
||||
# https://raw.githubusercontent.com/CVEProject/cve-website/dev/src/assets/data/CNAsList.json
|
||||
|
||||
require 'json'
|
||||
require 'rest-client'
|
||||
|
||||
class CnaSecurityAdvisories
|
||||
attr_accessor :url
|
||||
def initialize
|
||||
@url = 'https://raw.githubusercontent.com/CVEProject/cve-website/dev/src/assets/data/CNAsList.json'
|
||||
end
|
||||
|
||||
def send_request_rest
|
||||
RestClient::Request.execute(
|
||||
method: :get,
|
||||
url: url
|
||||
)
|
||||
end
|
||||
|
||||
def parse_res(response)
|
||||
JSON.parse(response.body)
|
||||
end
|
||||
|
||||
def get_json
|
||||
res = send_request_rest
|
||||
if res.code == 200
|
||||
parse_res(res)
|
||||
else
|
||||
"HTTP Status: #{res.code}"
|
||||
end
|
||||
end
|
||||
|
||||
def perform
|
||||
json = get_json
|
||||
json.map do |d|
|
||||
org_name = d.dig('organizationName')
|
||||
security_advisories = d.dig('securityAdvisories')
|
||||
security_advisory_urls = security_advisories.dig('advisories').map { |adv| adv.dig('url') }
|
||||
{ orgName: org_name, security_advisories_urls: security_advisory_urls }
|
||||
end
|
||||
end
|
||||
end
|
1288
tools/cve_cna_security_advisories/cna_security_advisory_urls.json
Normal file
1288
tools/cve_cna_security_advisories/cna_security_advisory_urls.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue