AGENT SKILL

vulnerability-csv-reporting

暂无简介

License 许可
Apache-2.0
最近更新
2026-11-14
Stars
★ 0
Forks
1

03 SKILL.md 正文

vulnerability-csv-reporting

Purpose

Generate a verifier-visible CSV security audit report from vulnerability scan data by discovering inputs in the live environment, applying an explicit filter and field mapping, writing the CSV to the task-required path, and validating the produced artifact by reloading it and asserting schema/shape before claiming completion.

When to Use

Use this skill when a task requires producing a CSV report from vulnerability findings (often JSON from a scanner) and the environment expects an actual file on disk at a specific path. Do not use for narrative security summaries or when the required output is not a CSV artifact.

Procedure

  • Step 1: Discover requirements and paths before doing work
  • Identify the required output CSV path from the task/verifier; if none is specified, ask or discover a conventional location and confirm it.
  • Discover the available inputs by listing the working directory and locating candidate vulnerability data files (for example, *.json, scanner output directories).
  • Checkpoint: confirm the input file you will parse exists and is readable (size > 0), and confirm you have write permission to the output directory.
  • Step 2: Ground tool availability and choose the minimal working route
  • Prefer Python for parsing and CSV writing (standard library). Verify availability: run python3 --version or python --version via the terminal tool.
  • If python3 is missing but python exists, use python. If neither exists, stop and request an environment-supported alternative rather than emitting unexecuted code.
  • Optional: if you intend to run a scanner first, verify the scanner binary exists and that required flags are supported; otherwise, proceed with converting existing scan output only.
  • Step 3: Convert findings to CSV records (mapping + filtering)
  • Inspect the top-level structure of the input JSON (print keys and a small sample) to avoid hard-coded assumptions.
  • Define the CSV header (fieldnames) explicitly and keep it stable.
  • Implement a mapping function that:
  • Produces exactly one flat dict per vulnerability row.
  • Uses safe defaults (for example, N/A) when fields are missing or null.
  • Applies the requested severity filter only if the task asks for it; otherwise include all severities.
  • Decision point: if the expected vulnerabilities list is missing (for example, no "Vulnerabilities" key or it is empty), still write a CSV with the header row and zero data rows unless the task requires otherwise.
  • Step 4: Write the CSV to the required path using an actual terminal tool call
  • Write via Python csv.DictWriter with newline="" and UTF-8 encoding.
  • Do not paste a "tool call" blob into chat. Execute the write using the platform terminal tool so the file is created on disk.
  • Checkpoint: the command must exit successfully (return code 0) before proceeding.
  • Step 5: Post-write verification (must pass before finalizing) [EXECUTION ANCHOR]
  • In the terminal tool, verify the artifact is present at the exact required path:
  • ls -l <csv_path> (or equivalent) shows the file exists and is non-empty if rows were expected.
  • Reload and validate the CSV schema/shape using Python:
  • Assert the first row header equals the expected fieldnames exactly (same names and order).
  • Assert every subsequent row has exactly the same number of columns as the header.
  • If severity filtering is requested, assert all output Severity values are within the requested set.
  • If any assertion fails: do not claim success; fix mapping/header/paths and re-run only the minimal failing step, then re-run this verification.

Constraints / Pitfalls

  • Never claim the report is generated unless the CSV exists and is readable at the task-specified output path and the post-write reload validation passes. Do not silently write to a different directory if permission/path issues occur; instead, diagnose and resolve or ask.
  • Avoid brittle assumptions about scanner JSON structure (fixed keys, nested shapes, or CVSS locations). Always inspect the input structure first and implement a single bounded fallback for missing keys (write header-only CSV or map alternate key paths) rather than expanding into an unbounded troubleshooting guide.

04 同仓库更多 Skills