Background
Identify corresponding CVE / Vulnerabilities in given python libraries and JavaScript package.json
Tool Scan
Python Pip SCA
Get the
requirements.txt
readyRun
cat requirements.txt | safety check --stdin --detailed-output json >test.json
Run
import json import csv with open('test.json', 'r') as file: data = json.load(file) with open('python-report.csv', 'w', newline='') as csvfile: csv_writer = csv.writer(csvfile) csv_writer.writerow(['Component Name', 'Component Version', 'Vulnerability Description', 'CVE ID']) for data in data["vulnerabilities"]: csv_writer.writerow([data["package_name"],data["analyzed_version"],data["advisory"],data["CVE"]])
JavaScript npm SCA
The easy way:
npm audit
If you want to have CVE version you can use snyk
tool
Run
npm install -g snyk
Get your github account ready and run
snyk auth
Scan
snyk test --json-file-output=snyk.json
Run
import csv import json import csv with open('snyk.json", 'r',encoding='utf-8') as file: data = json.load(file) with open('snyk.csv', 'w', newline='') as csvfile: csv_writer = csv.writer(csvfile) csv_writer.writerow(['Component Name', 'Component Version', 'Vulnerability Description', 'CVE ID']) for data in data['vulnerabilities']: cve = None if 'identifiers' in data: if 'CVE' in data['identifiers']: if data['identifiers']['CVE']: cve = data['identifiers']['CVE'][0] csv_writer.writerow([data["packageName"],data["version"],data["description"],cve])