Skip to content

test(security): delete the Trivy ignore tests that read the clock - #6390

Merged
dan-petty merged 4 commits into
mainfrom
test/6381-delete-clock-trivyignore-tests
Nov 19, 2026
Merged

dan-petty merged 4 commits into
mainfrom
test/6381-delete-clock-trivyignore-tests

Conversation

@dan-petty

@dan-petty dan-petty commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Three tests read the wall clock and the exp: dates of .trivyignore, .trivyignore-tofu and .trivyignore-mcp-server. They made the required Tests & Coverage check fail on each pull request from the first exp: date, also when the pull request changes no image. Trivy drops an ignore entry from 00:00 UTC of its exp: date. Each image scan step joins the files of its trivyignores input into one ignore file, and Trivy hides a finding while one entry of the same ID is valid. Thus the image scan reports a finding again from the last exp: date of that ID in the joined files. The change deletes the three tests, lowers the config read counts to match, and removes the mcp-server-image requirement whose scenario names the deleted test.

Closes #6381

Change: openspec/changes/archive/2026-11-19-6381-delete-clock-trivyignore-tests/

Trivy drops an ignore entry after its exp: date, so the image scan
already fails after the date. The three tests that read the wall clock
only made Tests & Coverage fail on each pull request.
@dan-petty dan-petty added type/test Type test: a new or changed test scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault labels Nov 19, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test record

The change has no src/ code, so it has no fail-to-pass test. Commands prove it (AGENTS.md rule 4). Fail-to-Pass does not run for the test title type.

Tests of the changed modules (2026-11-19):

$ uv run devops ci test tests/invariants/test_mcp_server_image.py tests/invariants/test_runner_image.py tests/invariants/test_service_image.py
20 passed in 6.49s

No test of the three modules reads the clock:

$ git grep -n 'datetime.now' -- tests/invariants/test_mcp_server_image.py tests/invariants/test_runner_image.py tests/invariants/test_service_image.py
(no output, exit 1)

The same tests with the clock moved forward (a local pytest plugin that starts time_machine.travel, not committed):

clock 2026-11-21T12:00:00Z: 20 passed
clock 2026-11-23T12:00:00Z: 20 passed

The deleted test of origin/main, with the clock at 2026-11-20T12:00:00Z:

FAILED test_every_mcp_server_trivyignore_entry_has_a_reason_and_an_exp_date_that_is_not_past
AssertionError: ... 'line 6: CVE-2026-56851 expired on 2026-11-20'

Static rows:

$ uv run devops ci --check --only lint,format,docs,constructs,openspec,test-settings,test-tree,startup-imports,swallowed-failures
lint pass, format pass, docs pass, constructs pass, openspec pass, test-settings pass, test-tree pass, startup-imports pass, swallowed-failures pass

test-tree holds the lowered counts of tests/gate/tree_checks/config_reads.toml.

Trivy enforces the exp: date itself

Source, Trivy v0.76.2, pkg/result/ignore.go: Prune (lines 131-141) skips a finding when !finding.ExpiredAt.IsZero() && finding.ExpiredAt.Before(clock.Now(ctx)). ParseIgnoreFile calls Prune on each list (lines 249-252).

Command output, Trivy 0.76.2 with the local vulnerability database, on 2026-11-19. The input is a requirements.txt with requests==2.19.0. The ignore file holds the other four findings of that file with a future date, and the entry under test with the date shown:

$ trivy fs --skip-db-update --scanners vuln --exit-code 1 --ignorefile <file> src
CVE-2018-18074 exp:2026-11-18 -> exit 1, reports CVE-2018-18074
CVE-2018-18074 exp:2026-11-20 -> exit 0, reports nothing

An expired entry stops hiding its finding, and the scan fails. The ignore code of Trivy is the same for trivy fs and trivy image. No local MCP Server image was available for a trivy image --ignorefile .trivyignore-mcp-server run.

Fail-to-pass

Not run: the change has no src/ code, and the test title type skips Fail-to-Pass.

Live steps

None.

The MCP Server Image step joins three ignore files, and Trivy hides a finding while one entry of the same ID is valid. Thus the added requirement was false for CVE-2026-78661 and CVE-2026-78669. The delta now only removes the requirement whose scenario names a deleted test.
@dan-petty
dan-petty force-pushed the test/6381-delete-clock-trivyignore-tests branch from 26ba943 to 29bdeb6 Compare November 19, 2026 07:27
@dan-petty

Copy link
Copy Markdown
Owner Author

Test record (head 29bdeb6)

This record replaces the earlier one. The review found that the added requirement "An expired MCP ignore entry stops hiding its finding" was false: the MCP Server Image step joins three ignore files, and Trivy hides a finding while one entry of the same ID is valid. The plan now only removes the requirement whose scenario names the deleted test, and adds no requirement.

The change has no src/ code, so it has no fail-to-pass test. Commands prove it (AGENTS.md rule 4). Fail-to-Pass does not run for the test title type.

Tests of the changed modules (2026-11-19):

$ uv run devops ci test tests/invariants/test_mcp_server_image.py tests/invariants/test_runner_image.py tests/invariants/test_service_image.py
20 passed in 0.91s

No test of the three modules reads the clock:

$ git grep -n 'datetime.now' -- tests/invariants/test_mcp_server_image.py tests/invariants/test_runner_image.py tests/invariants/test_service_image.py
(no output, exit 1)

Static rows:

$ uv run devops ci --check --only lint,format,docs,constructs,openspec,test-settings,test-tree,startup-imports,swallowed-failures
lint pass, format pass, docs pass, constructs pass, openspec pass, test-settings pass, test-tree pass, startup-imports pass, swallowed-failures pass

test-tree holds the lowered counts of tests/gate/tree_checks/config_reads.toml. openspec validates the archived change and the mcp-server-image spec.

How Trivy uses the exp: date

Source, Trivy v0.76.2, pkg/result/ignore.go: Prune (lines 131-141) skips an entry when ExpiredAt.Before(clock.Now(ctx)). Match returns the first remaining entry with the same ID.

.github/workflows/ci.yml:758 gives trivyignores: .trivyignore,.trivyignore-mcp-server,.trivyignore-tofu to the MCP Server Image step. The entrypoint.sh of aquasecurity/trivy-action v0.36.0 appends each file to one ignore file and sets TRIVY_IGNOREFILE to it.

Command output, Trivy 0.76.2 with the local vulnerability database, at 2026-11-19T07:28Z. The input is a requirements.txt with requests==2.19.0. Each ignore file holds the other four findings of that file with exp:2026-12-31, and the entries under test:

$ trivy fs --skip-db-update --offline-scan --scanners vuln --exit-code 1 --ignorefile <file> src
CVE-2018-18074 exp:2026-11-18                                -> exit 1, reports CVE-2018-18074
CVE-2018-18074 exp:2026-11-19                                -> exit 1, reports CVE-2018-18074
CVE-2018-18074 exp:2026-11-20                                -> exit 0, reports nothing
CVE-2018-18074 exp:2026-11-18, then exp:2026-11-21 (joined)  -> exit 0, reports nothing

Thus an entry stops hiding its finding from 00:00 UTC of its exp: date, and a scan with joined ignore files reports a finding from the last exp: date of that ID. CVE-2026-78661 and CVE-2026-78669 have exp:2026-11-20 in .trivyignore-mcp-server and exp:2026-11-21 in .trivyignore-tofu, so the MCP Server Image scan reports them from 2026-11-21.

Fail-to-pass

Not run: the change has no src/ code, and the test title type skips Fail-to-Pass.

Live steps

None.

@dan-petty
dan-petty marked this pull request as ready for review November 19, 2026 11:17
@dan-petty
dan-petty merged commit 8279216 into main Nov 19, 2026
27 checks passed
@dan-petty
dan-petty deleted the test/6381-delete-clock-trivyignore-tests branch November 19, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/test Type test: a new or changed test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(security): delete the Trivy ignore tests that read the clock

1 participant