Cyber Monday: 2XCYBER doubles your top-up, up to $2,000.Double my top-up

nc://trivy

v0.1.0Pinned
Backnodecode-ai
ThomSharksecurity cells: harden scope, Nuclei containment, ffuf authority and scrub (#183)245fa9c· 2 Dec2 commits
test1 filecell.lisp5.3 KBcli.lisp8.0 KBreport.lisp8.8 KBtools.lisp13.0 KB

nodecode-trivy

Trivy scans as tools the model calls: vulnerable dependencies, hard-coded secrets, IaC misconfigurations and licenses in a project, a container image, a git repository or an SBOM, read down to one line per finding. Written for Nodecode from Trivy's documented command line and JSON report.

Get it

Tell the agent "add the trivy cell", or run nodecode add nc://trivy.

Set it up

The cell runs the Trivy CLI, which is yours; nothing here vendors it. Install it once (install guide), for example:

brew install trivy        # or your distribution's package, or the release binary

No account is needed. The first vulnerability scan downloads Trivy's database (some hundreds of MB) into its cache; /trivy update does that ahead of time.

The section is optional; every key has a default. See config.example.jsonc:

Key Default What it does
command ["trivy"] The argv prefix that runs Trivy: on PATH, or its absolute path.
timeout_seconds 900 One run's ceiling; Trivy's whole process tree is killed past it.
max_output_chars 20000 How much one tool answer carries.
max_findings 200 How many finding lines one answer lists; the summary counts every one.
severity "unknown" The floor a scan reports when its call names none; unknown is everything.
cache_dir "" An absolute folder for Trivy's databases instead of ~/.cache/trivy.
offline false Scan with the cached databases only (--skip-db-update --skip-java-db-update --offline-scan).

Every run sets TRIVY_DISABLE_TELEMETRY, TRIVY_SKIP_VERSION_CHECK and TRIVY_NO_PROGRESS.

Use it

Tool Runs For
trivy_fs trivy fs A project directory or file: dependencies from its lockfiles, and secrets; misconfig and license on request.
trivy_image trivy image A container image by reference, or an image tarball (input).
trivy_repo trivy repo A git repository by https URL (Trivy clones it) or a local checkout, at a branch, tag or commit.
trivy_config trivy config IaC misconfigurations: Dockerfile, Kubernetes, Helm, Terraform, CloudFormation, ARM. Offline.
trivy_sbom trivy fs/image/repo --format cyclonedx|spdx-json --output Writes an SBOM to a file and answers how many components it lists.
trivy_sbom_scan trivy sbom Known vulnerabilities in an existing CycloneDX or SPDX SBOM.

The scan tools take severity (a floor), scanners, ignore_unfixed, skip_dirs, skip_files and skip_db_update where Trivy supports them. Every local path is absolute.

An answer is the command it ran, how it ended, a summary line, then each target with its findings worst first:

/srv/app (filesystem): 3 findings in 4 targets - 1 vulnerability, 1 misconfiguration, 1 secret, 0 license findings; CRITICAL 1, HIGH 2
== package-lock.json (npm)
  HIGH CVE-2021-23337 lodash 4.17.20 -> fixed in 4.17.21 - lodash: command injection via template https://avd.aquasec.com/nvd/cve-2021-23337
== Dockerfile (dockerfile)
  HIGH misconfig AVD-DS-0002 (line 1) - Image user should not be 'root' - Specify at least 1 USER command in Dockerfile with non-root user as argument Fix: Add 'USER <non root user name>' line to the Dockerfile
== config/.env (text)
  CRITICAL secret github-pat (GitHub Personal Access Token) at line 2

/trivy answers Trivy's version and database; /trivy update downloads the newest database.

What it never does

  • Show a secret. A secret finding is its rule, title and line; Trivy's Match and Code fields, which hold the matched text, are never read.
  • Let the model write a flag. Every value rides its flag as one argument (--flag=value), and any value that opens with a dash is refused.
  • Read a relative path. Trivy would resolve it against its own working directory; the cell asks for an absolute one.
  • Overwrite a file. trivy_sbom refuses an existing output unless the call passes overwrite.

Test

.github/test-cell.sh tools/nodecode-trivy

Seventeen tests, offline: every Trivy run goes through one stubbed seam, so the command line each tool builds and the report it reads from Trivy's JSON are asserted with no CLI, no database and no network.

License

MIT. See LICENSE. Trivy is Apache-2.0 and is not included.

Add nc://trivy

  1. 1

    Install Nodecode

    Once per machine.

    $ curl -fsSL https://nodecode.ai/install.sh | sh
  2. 2

    Add the cell

    Pinned at 245fa9c.

    $ nodecode add nc://trivy

    Or tell the agent add the trivy cell.