Created
August 10, 2020 14:50
-
-
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.
This file contains hidden or 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
| #!/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