Created
May 21, 2020 20:15
-
-
Save dreamnite/c97daf8deee9fdd78b6ff5016d9438a9 to your computer and use it in GitHub Desktop.
Build a CSV off an inspector report for ubuntu 16.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ruby | |
require 'net/http' | |
usec='https://people.canonical.com/~ubuntu-security/cve/' | |
cvelist=File.read('./cvelist') | |
# setup header | |
csvcontent='CVE,severity,ubuntu severity,Ubuntu link,Description,notes' | |
# main loop | |
cvelist.split("\n").each do |line| | |
info = line.split("\t") | |
# Start the details hash | |
c={ 'cve' => info[0], | |
'url' => usec + info[0].split('-')[1] + '/' + info[0] + '.html', | |
'severity' => info[1] | |
} | |
x=Net::HTTP.get(URI(c['url'])) | |
c['useverity'] = x[/Priority.*\n/][/html.*\/>/][/>.*</].delete('<>') | |
c['desc' = x[/Description.*\n/][/<.*/].gsub(/<[^>]*>/ui,'') | |
csvcontent += "\n#{c['cve']},#{c['severity']},#{c['useverity']},#{c['url'],c['desc']}," | |
end | |
f = File.open('cvelist.csv','w') | |
f.write(csvcontent) | |
f.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment