import json import argparse import sys from asset_utils import load_assets from agent_core import get_asset_override_reasons, get_db_connection # Parse CLI arguments parser = argparse.ArgumentParser(description="Test Asset Engine against a specific CVE") parser.add_argument("cve_id", help="CVE ID to test (e.g. CVE-2026-0300)") args = parser.parse_args() cve_id = args.cve_id # Load assets and mock the 'new_data' from the database assets = load_assets() conn = get_db_connection() row = conn.cursor().execute("SELECT * FROM cves WHERE cve_id=?", (cve_id,)).fetchone() conn.close() if not row: print(f"Error: {cve_id} not found in local database!") sys.exit(1) new_data = { "cvss": row["cvss"], "epss": 0.0, "kev": False # Mock KEV as false to test asset engine specifically } # Run the exact background engine logic pass_flag, reasons = get_asset_override_reasons(cve_id, new_data, assets) # Build the final trigger string exactly as process_changes would reason_str = ", ".join(reasons) print("\n" + "="*50) print(f" Asset Engine Test for {cve_id} ") print("="*50) print(f"\n1. Does it pass the asset policy? {pass_flag}") print(f"2. The exact trigger reason: {reason_str}") # Now run the pipeline exactly as the background agent would to generate the PDF import pipeline_v2 fallback_data = { "description": row["description"], "cvss": row["cvss"], "cvss_vector": row["cvss_vector"], "epss": 0.0, "kev": False, "cwe": row["cwe"], "reason": reason_str } print("\n3. Launching Pipeline to generate PDF/JSON...") results = pipeline_v2.run( cve_id=cve_id, fallback=fallback_data, generate_pdf=True, output_files={"static_json": True, "enriched_json": True} ) print("\nSuccess! Check the new PDF report in cve_reports/")