Skip to content

Instantly share code, notes, and snippets.

@carlosparadis
Created March 12, 2017 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosparadis/f7e12b9f206e3da4829957da3c8f45a8 to your computer and use it in GitHub Desktop.
Save carlosparadis/f7e12b9f206e3da4829957da3c8f45a8 to your computer and use it in GitHub Desktop.
sanjna
#remove namespace
#http://effbot.org/zone/element-namespaces.htm
def normalize(name):
if name[0] == "{":
uri, tag = name[1:].split("}")
return tag
else:
return name
#Find root node
CVE_tree = ET.parse("mitre_cvrf_2014.xml")
root= CVE_tree.getroot()
vulnerability_table = root[5:]
for vulnerability in vulnerability_table:
#travels through column
for vulnerability_column in vulnerability:
#checks if that column exists or not
if normalize(vulnerability_column.tag) == 'CVE':
print(vulnerability_column.text+ '\n',end='')
#print (normalize(vulnerability_column.tag))
if normalize(vulnerability_column.tag) == 'References':
reference_table = vulnerability_column
for reference in reference_table:
url = reference[0].text
tag = reference[1].text
print ('\t'+url+' '+tag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment