update
This commit is contained in:
parent
e8c3f7745a
commit
6cb79316e3
1 changed files with 25 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
require 'json'
|
||||
require 'rest-client'
|
||||
require 'nokogiri'
|
||||
|
||||
|
@ -62,7 +63,13 @@ class MozillaSecurityAdvisoryScraper
|
|||
advisory_doc.xpath('//section[@class="cve"]')
|
||||
end
|
||||
|
||||
def advisory_id_from_url(advisory_url)
|
||||
advisory_url.split("/").last
|
||||
end
|
||||
|
||||
def data_hash(advisory_doc)
|
||||
advisory_url = advisory_doc.xpath('/html/head/meta[7]').last.values.last
|
||||
advisory_id = advisory_id_from_url(advisory_url)
|
||||
title = advisory_doc.title
|
||||
header = advisory_doc.css('h2').text
|
||||
summary = parse_advisory_summary(advisory_doc)
|
||||
|
@ -74,6 +81,8 @@ class MozillaSecurityAdvisoryScraper
|
|||
cves = cve_nodes.map { | cve_node | cve_data_hash(cve_node) }
|
||||
|
||||
{
|
||||
:advisory_url => advisory_url,
|
||||
:advisory_id => advisory_id,
|
||||
:title => title,
|
||||
:header => header,
|
||||
:announced => announced,
|
||||
|
@ -107,4 +116,20 @@ class MozillaSecurityAdvisoryScraper
|
|||
|
||||
end
|
||||
|
||||
def get_all_advisories
|
||||
advisory_urls.map do | advisory_url |
|
||||
advisory_doc = get_and_parse_advisory(advisory_url)
|
||||
data_hash(advisory_doc)
|
||||
end
|
||||
end
|
||||
|
||||
def advisory_hash_to_json_file(advisory_hash)
|
||||
advisory_json = JSON.parse(advisory_hash.to_json)
|
||||
pretty_json = JSON.pretty_generate(advisory_json)
|
||||
File.write("./data/#{advisory_hash[:advisory_id]}.json", pretty_json)
|
||||
end
|
||||
|
||||
def product_name_version_to_cpe(product_name, product_version)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue