Container cve validator

From RHEcosystemAppEng/agentic-plugins · View interactive version

Container cve validator is an AI agent skill from the GitHub repository RHEcosystemAppEng/agentic-plugins. Validate a CVE against a Red Hat container image using official SBOM attestations, Red Hat VEX data, and CVE metadata from MITRE/OSV.dev.

How to use this skill

Skill file

Red Hat Container Security Validator

When to Use This Skill

Use this skill when the user asks you to check, validate, or analyze one or more CVEs against Red Hat container images. Input may be a single CVE ID + image reference, or a CSV file path containing multiple pairs.

Optional Output Flags

The user may specify these optional flags. Parse them before extracting the required inputs.

Record the resolved values as OUTPUT_FORMAT (default: markdown), OUTPUT_MODE (default: full), and INPUT_FILE (default: empty). Strip all flag tokens before extracting remaining positional arguments.

Input Validation

Use the validate_input.py script for all input validation — both single scan and batch mode.

Single scan:

python $SCRIPTS_DIR/validate_input.py --cve [CVE-ID] --image [IMAGE_REFERENCE]

Batch mode (when --file was provided):

python $SCRIPTS_DIR/validate_input.py --file [PATH]

The script returns JSON with valid (boolean), mode ("single" or "batch"), entries (array of validated CVE/image pairs with registry classification), and errors (array of error messages with line numbers for batch mode).

```bash

python $SCRIPTS_DIR/fetch_rhsa_advisory.py [RHSA-ID]

```

Run the full validation pipeline for each CVE in the returned cve_ids[] list against the same image.

Batch output aggregation:

Image Inspection

Use the inspect_image.py script to fetch image metadata:

python $SCRIPTS_DIR/inspect_image.py [IMAGE_REFERENCE]

The script returns JSON with labels (cpe, name, com.redhat.component, vendor, maintainer, org.opencontainers.image.created), digest, architecture, and errors.

If the script fails with an authentication error, log in first:

regctl registry login registry.redhat.io

Then re-run. If login fails, stop and inform the user.

From the output, record:

Registry ownership check: The validate_input.py output already classifies the registry (is_redhat, type). For non-Red Hat registries:

Input format classification: The validate_input.py output provides ref_format ("tag" or "digest"). For digest-based references, the human-readable tag will be extracted from the SBOM in Step 2.

Do NOT use version or release labels to reconstruct the image tag.

Prerequisites

Step 0 — Resolve scripts directory. Before anything else, locate the helper scripts. They are inside the skill's scripts/ subfolder. Run:

SCRIPTS_DIR="scripts"
test -f "$SCRIPTS_DIR/validate_input.py" || { echo "Error: Scripts directory not found at $SCRIPTS_DIR"; exit 1; }

Use $SCRIPTS_DIR in all subsequent script calls. The scripts handle tool checks internally (regctl, cosign, syft) and return clear errors if tools are missing.

Workflow

MANDATORY EXECUTION CONTRACT — read before starting:

This skill requires completing ALL of the following steps in order. No step may be skipped, condensed, or replaced with an alternative approach — regardless of which model is executing.

| # | Step | Required | May skip only when |

|---|---|---|---|

| 0 | Prerequisites check | Always | Never |

| 0 | Input validation + image inspection | Always | Never |

| 1 | CVE Reconnaissance (MITRE → OSV.dev → Go vuln DB) | Always | Never |

| 2 | SBOM Extraction + package verification | Always | Never |

| 3 | Red Hat VEX Validation | Always | Package NOT found in SBOM (Step 2) |

| 4 | Newer Image Availability Scan | Conditional | Trigger conditions not met (see Step 4 header) |

| 5 | Final Report | Always | Never |

Strict rules:

  1. Execute each step using the helper scripts below. After each step, print: ✓ Step N complete — [key finding]
  2. FORBIDDEN COMMANDS — never use these, even inside loops or pipelines:
  1. The ONLY allowed bash commands are: running the helper scripts (python $SCRIPTS_DIR/...), SCRIPTS_DIR=... resolution, test -f, and cat to read a file.
  2. How to handle large VEX/SBOM data: Read the raw JSON output directly in your context window. Analyze it in your reasoning, not with shell tools. Do NOT attempt to filter it with grep/jq.
  3. Do not combine, reorder, or parallelise steps. Each step depends on outputs from previous steps.
  4. If a step produces unexpected results, report them and continue — do not stop unless explicitly instructed.
  5. Every field in the final report must come from actual script outputs. Use N/A — [reason] for undetermined fields. Never fabricate values.
  6. The fetch_redhat_vex.py script takes ONLY a CVE-ID argument — no flags. It returns the full raw VEX document.

Step 1: CVE Reconnaissance

Run the fetch_cve_metadata.py script to query all CVE data sources in a single call:

python $SCRIPTS_DIR/fetch_cve_metadata.py [CVE-ID]

The script automatically queries MITRE CVE API, OSV.dev, and (if a GO-* alias is found) the Go vulnerability database. It returns merged JSON with:

From the output, identify:

Print: ✓ Step 1 complete — [package name], ecosystem: [ecosystem], sources: [list from affected[].source]


Step 2: SBOM Extraction

Run the download_sbom.py script to handle all SBOM extraction logic in a single call:

python $SCRIPTS_DIR/download_sbom.py [IMAGE_REFERENCE]

The script handles attestation/build-time fallback and image index detection automatically. It returns JSON with:

Read and interpret the full raw SPDX document from the spdx field. Analyze the SPDX data directly — packages (with externalRefs PURLs and versionInfo), relationships (for parent RPM linkage), checksums. Do NOT use grep or jq to search the SBOM.

If spdx is null (no SBOM found), fall back to syft:

python $SCRIPTS_DIR/generate_sbom_syft.py [IMAGE_REFERENCE]

This generates an analyzed SBOM using syft. The output has the same JSON schema but sbom_source will be "syft_analyzed" — note this in the report as a generated SBOM, not an official one.

If neither method produces an SBOM: stop and report "Unable to extract SBOM. Cannot determine package presence."

Package presence check and version confirmation:

Red Hat container image SBOMs contain both RPM packages and non-RPM content (Go modules, Python packages, Node.js packages, etc.), each identified by ecosystem-specific PURLs. A non-RPM package may exist as a standalone SBOM entry AND be linked via an SPDX relationship to the RPM package that delivers it. Use the following matching logic:

  1. Identify the target package name and ecosystem from Step 1. For Go, use the module path from the Go vuln DB as the authoritative name.
  1. Search SBOM packages by PURL and name:
  1. If the package is NOT found by any method: skip Step 3 and go to Step 4 (Early Exit — package not in image).
  1. If the package IS found: record the installed version from the SPDX versionInfo field and proceed to version range confirmation.
  1. Confirm the installed version falls within the vulnerable range:

Print: ✓ Step 2 complete — package [found|not found], version: [version], verdict: [vulnerable|patched|inconclusive], SBOM method: [attestation|build-time]


Step 3: Red Hat VEX Validation

Run the fetch_redhat_vex.py script to fetch the full raw VEX document:

python $SCRIPTS_DIR/fetch_redhat_vex.py [CVE-ID]

The script returns JSON with:

Read and interpret the full VEX document from the vex field. The LLM should analyze the product_tree (branches, relationships, CPEs, PURLs), vulnerabilities (product_status, remediations, flags, threats) directly to perform matching against the image CPE and component name from Step 0. This gives the LLM full context to:

Interpret the results:

Read references/01-vex-validation-procedure.md for the complete VEX matching procedure (sub-steps 3–9: generic blanket detection, product_tree matching, status determination, remediation/flags/severity extraction, and parent RPM patch check).

Print: ✓ Step 3 complete — VEX status: [status], severity: [severity], gap condition: [A|B|C|none]


Step 4: Newer Image Availability Scan

Trigger — perform this step only when ALL of the following are true:

If trigger conditions are NOT met, print ✓ Step 4 skipped — trigger conditions not met ([reason]) and proceed to Step 5.

Procedure:

  1. Extract the image repository from the scanned image reference — strip tag or digest, keeping only registry + namespace + image name (e.g., registry.redhat.io/multicluster-engine/cluster-proxy-addon-rhel9).
  1. Run the scan_newer_images.py script:

```bash

python $SCRIPTS_DIR/scan_newer_images.py [IMAGE_REPOSITORY] --since [SCANNED_IMAGE_CREATED_LABEL]

```

The script returns JSON with newer_images[] — each entry has tag, created, digest, and cpe. Images are sorted by date (newest first), deduplicated by digest, capped at 10 results.

If newer_images is empty: no newer images exist yet. Record this and proceed to Step 5.

  1. For each newer image candidate, download its SBOM and search for the vulnerable RPM:

```bash

python $SCRIPTS_DIR/download_sbom.py [IMAGE_REPOSITORY]:[TAG]

```

  1. For each image found to contain the fix, compare its CPE against the scanned image's CPE:
  1. If no newer image contains the fixed RPM: record "No patched container image released yet. The RPM fix exists but the container has not yet been rebuilt with the updated RPM."

Print: ✓ Step 4 complete — [patched image found: REPO:TAG | no patched image found | skipped]


Step 5: Final Report

Read references/02-report-template.md for VEX data gap condition evaluation (Conditions A/B/C), executive summary rules, upstream patch note logic, RHSA advisory assessment, the full report template (markdown/JSON/CSV), and field semantics.

Print: ✓ Step 5 complete — report generated

Dependencies

Required MCP Servers

Required Helper Scripts

Related Skills

Reference Documentation

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.