Skip to content

UID2-8363: append shared Rego helpers to .trivyignore.rego when it uses them - #268

Merged
swibi-ttd merged 4 commits into
mainfrom
swi-UID2-8363-rego-helpers
Nov 18, 2026
Merged

swibi-ttd merged 4 commits into
mainfrom
swi-UID2-8363-rego-helpers

Conversation

@swibi-ttd

@swibi-ttd swibi-ttd commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Trivy reads exactly one --ignore-policy file and can't import other Rego files, so every repo's .trivyignore.rego has had to be self-contained. This adds shared helpers that a repo's policy can call.

  • actions/vulnerability_scan/trivyignore-shared.rego (new): a fragment with no package or import lines. Every name is prefixed uid_shared_. It starts with uid_shared_availability_only: true when the finding has CVSS data and no v3 or v4.0 vector, from any source, shows confidentiality or integrity impact.
  • action.yaml: a new step picks the policy. If the repo's .trivyignore.rego mentions uid_shared_, the step writes .trivyignore.rego + the helpers to $RUNNER_TEMP and passes that file to Trivy. Otherwise it passes .trivyignore.rego unchanged, or nothing if there's no file. Repos that don't call a helper see no change.

The helpers are read from $GITHUB_ACTION_PATH, so they always match the version of the action being run.

A repo's policy then only needs its own rule:

package trivy

import rego.v1

default ignore := false

ignore if {
	input.Type == "vulnerability"
	input.PkgName == "aiohttp"
	startswith(input.PkgIdentifier.PURL, "pkg:pypi/")
	uid_shared_availability_only
}

The repo's file must import rego.v1 (all existing .trivyignore.rego files do). A policy that calls a helper without it being appended fails the scan with a Rego error, rather than passing.

Tested locally by running the new step's script, then Trivy v0.70.0 (the trivy-action default), on three repo layouts: a policy that calls the helper (combined file; only findings with confidentiality or integrity impact remain), a policy that doesn't (passed through unchanged, same results as today), and no policy.

Ticket: UID2-8363

🤖 Generated with Claude Code

…es them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Ticket: UID2-8363
Branch: swi-UID2-8363-rego-helpers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Ticket: UID2-8363
Branch: swi-UID2-8363-rego-helpers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Ticket: UID2-8363
Branch: swi-UID2-8363-rego-helpers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Ticket: UID2-8363
Branch: swi-UID2-8363-rego-helpers
@swibi-ttd
swibi-ttd merged commit ef99d87 into main Nov 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants