Skip to content

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

Closed

Description

@dan-petty

Problem

Delete the 3 tests that call trivyignore_problems(text, datetime.now(UTC).date()): tests/invariants/test_mcp_server_image.py:88-91, test_runner_image.py:116-120 and test_service_image.py:182-190. Lower the counts in tests/gate/tree_checks/config_reads.toml:37-39 to match. tests/support/trivyignore.py stays while the stale-entry test (test_service_image.py:130) and its unit tests (144-180) still use it. Issue 8 deletes those. Why: Trivy already removes an expired entry itself (pkg/result/ignore.go:131-141 and 249-252 at v0.76.2), so the scan already enforces the date, and SECURITY.md:76 names the failing scan as the reminder. The owner rule of 2026-11-16 forbids config-value tests. Urgency: Tests & Coverage is a required check. test_mcp_server_image fails on every PR from 2026-11-20 (.trivyignore-mcp-server:6,9,12 have exp:2026-11-20), and test_runner_image fails from 2026-11-21. Treat this as P0.

Expected

  • The three wall-clock tests are gone, and tests/gate/tree_checks/config_reads.toml counts match.
  • git grep -n 'datetime.now' -- tests/invariants/test_*_image.py gives nothing. uv run pytest tests/invariants/test_mcp_server_image.py tests/invariants/test_runner_image.py tests/invariants/test_service_image.py passes on 2026-11-20. In the PR, run trivy image --ignorefile .trivyignore-mcp-server with an entry set to a past date: the finding comes back, which shows that the scan enforces the date.

The assertions on the trivy-action inputs (severity, ignore-unfixed, exit-code) stay: they wait for an owner answer (#6060).

Proposed design

Problem statement

The image invariant tests read the wall clock and fail when a Trivy ignore entry expires, which blocks the required Tests & Coverage check. Delete the three wall-clock tests and lower the config-read counts to match. Keep the Trivy ignore helper for the stale-entry test and its unit tests until Issue 8 removes them.

Acceptance criteria

Requirement: Wall-clock tests removed

The three image invariant test modules SHALL contain no test that calls trivyignore_problems with datetime.now.

Scenario: No wall-clock test remains

  • WHEN git grep -n 'datetime.now' -- tests/invariants/test_mcp_server_image.py tests/invariants/test_runner_image.py tests/invariants/test_service_image.py runs
  • THEN the command returns no match.

Requirement: Image invariant suites pass

The three image invariant test modules SHALL pass after the wall-clock tests are deleted.

Scenario: Remaining tests pass on the expiry date

  • WHEN uv run pytest tests/invariants/test_mcp_server_image.py tests/invariants/test_runner_image.py tests/invariants/test_service_image.py runs on 2026-11-20
  • THEN the command passes.

Requirement: Config-read counts match

tests/gate/tree_checks/config_reads.toml SHALL list four config reads for each of the three image invariant test modules.

Scenario: Tree-check config counts pass

  • WHEN uv run pytest tests/gate/tree_checks runs
  • THEN the command passes with a count of four for each of the three files.

Requirement: Trivy ignore helper stays

tests/support/trivyignore.py and its unit tests SHALL stay for the stale-entry test.

Scenario: Helper tests still pass

  • WHEN uv run pytest tests/invariants/test_service_image.py -k trivyignore runs
  • THEN the command passes and the stale-entry and unit tests still use the helper.

Requirement: Trivy action assertions stay

The assertions on the trivy-action inputs SHALL stay unchanged.

Scenario: Action input test remains

  • WHEN uv run pytest tests/invariants/test_mcp_server_image.py -k pull_request_check runs
  • THEN the test passes and still checks severity, ignore-unfixed and exit-code.

Requirement: Expired entry is visible in the scan

The pull request SHALL show that Trivy reports a finding when its ignore entry is set to a past date.

Scenario: Expired ignore entry stops hiding the finding

  • WHEN a reviewer sets an entry of .trivyignore-mcp-server to a past date and runs trivy image --ignorefile .trivyignore-mcp-server
  • THEN Trivy reports the finding.

Existing Tool Considered

No alternatives check has run. No open, maintained tool or library covers the need: the change deletes three project-specific wall-clock tests and lowers three config-read counts. It builds no code, so it has no build cost.

Key questions

  • Which tests call trivyignore_problems with the wall clock and must be deleted?: Delete the three tests at tests/invariants/test_mcp_server_image.py:88-91, tests/invariants/test_runner_image.py:116-120 and tests/invariants/test_service_image.py:182-190. [sources: tests/invariants/test_mcp_server_image.py:88, tests/invariants/test_runner_image.py:116, tests/invariants/test_service_image.py:182]
  • What count must each line of tests/gate/tree_checks/config_reads.toml hold after the deletion?: Each of the three lines must fall from 5 to 4. [sources: tests/gate/tree_checks/config_reads.toml]
  • Does tests/support/trivyignore.py stay in this change?: Yes. The stale-entry test at test_service_image.py:130 and its unit tests at lines 144-180 still use it. Issue 8 removes those later. [sources: tests/support/trivyignore.py, tests/invariants/test_service_image.py:130]
  • Do the assertions on the trivy-action inputs stay?: Yes. The test that checks severity, ignore-unfixed and exit-code stays unchanged. [sources: tests/invariants/test_mcp_server_image.py]
  • How does the change prove that Trivy enforces the ignore expiry date?: Use the live scan check in the pull request: set an ignore entry to a past date and run trivy image --ignorefile .trivyignore-mcp-server. Trivy must report the finding. Do not add another wall-clock test. (best practice) [sources: SECURITY.md:76, tests/support/trivyignore.py]
    • Chosen: Live scan check in the pull request. It shows that the scan enforces the date without a test that reads the clock.
    • Rejected: Keep a wall-clock test. The owner rule of 2026-11-16 forbids config-value tests, and the test fails when an entry expires.
    • Rejected: Freeze the clock in tests. It keeps a config-value test and hides the real expiry date.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/test
    scope/security
    source/agent
    status/new
    effort/low
    value/high
    on Nov 19, 2026
  2. dan-petty commented on Nov 19, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P0-Critical. The body states test_mcp_server_image fails on every PR from 2026-11-20, which is a CI failure.
    • Related: fix(security): renew the MCP server Trivy ignores and bump kubectl and helm #4336, which asks for a different change. Both touch .trivyignore-mcp-server and the same failing test, but 4336 renews ignore entries and bumps tools while the candidate deletes the clock-reading tests.
  3. added
    priority/p0-critical
    owner/agent
    on Nov 19, 2026
  4. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  5. added
    status/in-progress
    and removed
    status/new
    on Nov 19, 2026
  6. removed
    status/in-progress
    owner/agent
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p0-criticalscope/securitysource/agenttype/testvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions