Skip to content

Instantly share code, notes, and snippets.

@dustinbutterworth
Created August 10, 2020 14:50
Show Gist options
  • Save dustinbutterworth/783cd59220636b31dcc659287fbe4f3d to your computer and use it in GitHub Desktop.
Save dustinbutterworth/783cd59220636b31dcc659287fbe4f3d to your computer and use it in GitHub Desktop.
Take a CSV with CVE number in a row, print out CVE using regex.
#!/usr/bin/env python3
# Take a CSV with CVE number in a row, print out CVE using regex.
import csv
import re
reg = 'CVE-\d{4}-\d{4,7}'
csvfile = '/Users/dbutterworth/test/VulnerabilityListingExport.csv'
with open(csvfile, mode='r') as infile:
csvreader = csv.reader(infile)
next(csvreader)
my_data_list = [row for row in csvreader if 'CVE' in row[0]]
for row in my_data_list:
title = row[0]
cve = re.search(reg,title)
print(cve.group(0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment