AGENT SKILL

csv-reporting

Output vulnerability reports as a formatted CSV file.

使用场景电子表格
License 许可
MIT
最近更新
2026-10-02
Stars
★ 93
Forks
8

01 前言 Front Matter

name
csv-reporting
description
Output vulnerability reports as a formatted CSV file.

03 SKILL.md 正文

Vulnerability CSV Reporting

After parsing a vulnerability JSON report from a tool like Trivy, it is common to output the extracted findings to a CSV file for security audits or compliance checks.

Usage

This Python code snippet demonstrates how to export vulnerabilities to a CSV file according to a defined schema, such as: Package,Version,CVE_ID,Severity,CVSS_Score,Fixed_Version,Title,Url.

import csv
import json

def generate_csv(json_path, csv_path):
    with open(json_path, 'r', encoding='utf-8') as f:
        trivy_report = json.load(f)

    # Required CSV fields
    fieldnames = ['Package', 'Version', 'CVE_ID', 'Severity', 'CVSS_Score', 'Fixed_Version', 'Title', 'Url']

    with open(csv_path, 'w', newline='', encoding='utf-8') as f:
        writer = csv.DictWriter(f, fieldnames=fieldnames)
        writer.writeheader()

        for result in trivy_report.get('Results', []):
            for vuln in result.get('Vulnerabilities', []):
                # Only include HIGH and CRITICAL severities
                severity = vuln.get('Severity', '')
                if severity not in ['HIGH', 'CRITICAL']:
                    continue

                # Prepare the row
                row = {
                    'Package': vuln.get('PkgName', ''),
                    'Version': vuln.get('InstalledVersion', ''),
                    'CVE_ID': vuln.get('VulnerabilityID', ''),
                    'Severity': severity,
                    'CVSS_Score': extract_cvss(vuln),
                    'Fixed_Version': vuln.get('FixedVersion', 'N/A'),
                    'Title': vuln.get('Title', vuln.get('Description', '')).replace('\n', ' ').strip()[:100],
                    'Url': vuln.get('PrimaryURL', '')
                }
                writer.writerow(row)

# The extract_cvss function would be defined elsewhere or imported

This ensures properly-formatted tabular reports. Note how it limits the output strictly to HIGH and CRITICAL vulnerabilities.

04 同仓库更多 Skills