Skip to content

fix(security): trivy config skips .venv, node_modules and tests/fixtures #5790

Done

Description

@github-actions

Problem

Code-scanning alert 281 (Trivy DS-0029, HIGH) names .venv/lib/python3.14/site-packages/harbor/cli/template-adapter/task-template/environment/Dockerfile. That file is third-party content in the virtual environment. It is gitignored, and nothing in it deploys. trivy config scans it because the command does not skip .venv or node_modules. The DS-0029 entry of .trivyignore.yaml (lines 32-36, expired_at 2026-11-19) only hides the alert for a short time, and #6382 renews it.

Three more entries cover test fixtures that never deploy: KSV-0014 two times in tests/fixtures/image_pins/chart_render.yaml (#5948) and KSV-0118 in tests/fixtures/prompt_adversaries/kubernetes_adversary.yaml (#6268). They must be renewed every 3 days.

Change

Owner decision of 2026-11-19: trivy config skips tests/fixtures.

  1. Write a failing unit test first: the trivy config command that TrivyConfigScanner.build_command (src/devops_cli/security/trivy.py:231-246) and build_trivy_scan_cmd (src/devops_cli/config/commands.py:75-90) build skips **/.venv, **/node_modules and tests/fixtures.
  2. Add --skip-dirs for the three folders to both builders.
  3. Delete the DS-0029 entry (.trivyignore.yaml:32-36) and the 3 tests/fixtures entries.

Renovate. Not applicable.

Risk. Trivy no longer scans the skipped folders. .venv and node_modules hold gitignored third-party content, and tests/fixtures holds test inputs. Nothing in them deploys.

Proof

Depends on: none

Proposed design

Problem statement

Make trivy config skip .venv, node_modules and tests/fixtures, and then delete the four .trivyignore.yaml entries that hide the alerts of those folders. trivy config scans third-party and test content that never deploys: code-scanning alert 281 comes from a harbor Dockerfile under .venv, and three fixture entries expire every 3 days and need a renewal issue each time. The gates are the merge of this change and the next Security Scan run, which closes the alerts.

Acceptance criteria

Requirement: Config scan command carries each skip pattern once

The trivy config command that TrivyConfigScanner.build_command builds MUST pass --skip-dirs once for each of **/.venv, **/node_modules and tests/fixtures.

Scenario: Config command holds the three skip patterns

  • WHEN the test calls TrivyConfigScanner().build_command(Path("."))
  • THEN the returned argument list holds --skip-dirs followed by **/.venv, by **/node_modules and by tests/fixtures, and holds each of the three patterns once

Requirement: Shared builder passes the skip patterns to a config scan

The build_trivy_scan_cmd builder MUST pass --skip-dirs once for each of the three folders when scan_type is config.

Scenario: Shared builder keeps the three skip patterns

  • WHEN the test calls build_trivy_scan_cmd(Path("."), "config")
  • THEN the returned list holds --skip-dirs with **/.venv, with **/node_modules and with tests/fixtures, and holds each of the three patterns once

Requirement: Other scan types keep their command

The build_trivy_scan_cmd builder MUST NOT pass --skip-dirs to a scan type other than config.

Scenario: The fs command holds no skip flag

  • WHEN the test calls build_trivy_scan_cmd("src", "fs")
  • THEN the returned list equals the argument list that tests/config/test_command_builders.py asserts at line 39, with no --skip-dirs

Requirement: The harbor Dockerfile ignore entry is removed

The change MUST remove the DS-0029 entry for the .venv harbor Dockerfile from .trivyignore.yaml, and the next Security Scan MUST close code-scanning alert 281.

Scenario: The next Security Scan closes alert 281

  • WHEN the Security Scan workflow runs on the merged change and gh api repos/dan-petty/devops-cli/code-scanning/alerts/281 --jq .state reads the alert
  • THEN the command prints fixed

Requirement: The fixture ignore entries are removed

The change MUST remove every .trivyignore.yaml entry whose path is under tests/fixtures, and the next Security Scan MUST report no open Trivy-config alert there.

Scenario: The next Security Scan reports no fixture misconfiguration

  • WHEN the Security Scan workflow runs on the merged change and gh api 'repos/dan-petty/devops-cli/code-scanning/alerts?state=open&tool_name=Trivy-config' --jq '.[].most_recent_instance.location.path' lists the open Trivy-config alerts
  • THEN the output holds no path under tests/fixtures

Existing Tool Considered

No alternatives check has run on this item. The tool in use is Aqua Trivy, open source under Apache-2.0 and maintained; the runner image pins Trivy 0.76.2 (docs/CLUSTER.md:68), and its --skip-dirs flag covers the need, so the change builds no code and pays no build or upkeep cost. The proposal passes the three patterns to the trivy command builders and removes the four ignore entries. Trivy lacks nothing for this change.

Key questions

  • Which .trivyignore.yaml entries does the change remove?: The DS-0029 entry at lines 32-36 hides the .venv harbor Dockerfile. Lines 2-16 hold three tests/fixtures entries: KSV-0014 for image_pins/chart_render.yaml (line 2), KSV-0014 for prompt_adversaries/kubernetes_adversary.yaml (line 7), and KSV-0118 for image_pins/chart_render.yaml (line 12). The body pairs KSV-0118 with the prompt-adversary file, but the file at the refined commit pairs KSV-0118 with chart_render.yaml and KSV-0014 with the prompt-adversary file. All four entries leave the file. [sources: .trivyignore.yaml:2, .trivyignore.yaml:7, .trivyignore.yaml:12, .trivyignore.yaml:32, .trivyignore.yaml:36]
  • Does trivy config skip tests/fixtures?: Yes. The owner decided on 2026-11-19 that trivy config skips tests/fixtures, and the proposal applies it. The three fixture entries then leave .trivyignore.yaml, so no renewal issue is needed for them. (best practice) [sources: .trivyignore.yaml:2, .trivyignore.yaml:7, .trivyignore.yaml:12, SECURITY.md:81]
    • Chosen: Skip tests/fixtures with --skip-dirs. The owner decision of 2026-11-19 asks for it, and no fixture deploys.
    • Rejected: Keep the fixture entries in .trivyignore.yaml. Each entry expires 3 days after it is written (SECURITY.md:81) and needs a renewal issue.
  • Should the scan also skip .venv and node_modules?: Yes. .venv holds gitignored third-party site-packages (.gitignore:15), and alert 281 names a harbor Dockerfile inside it (.trivyignore.yaml:32). node_modules holds third-party npm packages of a tool install, and no deployment ships either folder. Skipping them removes the need for the DS-0029 entry. (best practice) [sources: .trivyignore.yaml:32, docs/adr/0010-openspec-is-the-spec-and-change-proposal-layer.md:167]
    • Chosen: Skip all three folders. The three folders hold third-party or test content that never deploys.
    • Rejected: Skip only tests/fixtures. The DS-0029 alert stays, and its entry expires on 2026-11-19.
    • Rejected: Hide the alerts with .trivyignore.yaml entries. Each entry needs a renewal 3 days later (SECURITY.md:81).
  • Which builder gets the --skip-dirs flags, and for which scan types?: Put the flags in build_trivy_scan_cmd, guarded to scan_type == "config". TrivyConfigScanner.build_command extends the shared builder through super() and passes config, so it gets the flags with no second copy, and plan_trivy_scan gets them for a config scan too. The guard leaves trivy fs and trivy image unchanged, which keeps the exact argument list that tests/config/test_command_builders.py:39 asserts for fs. Each config command holds each pattern once. (best practice) [sources: src/devops_cli/config/commands.py:75, src/devops_cli/security/trivy.py:199, src/devops_cli/security/trivy.py:231, src/devops_cli/security/scan_plans.py:34, tests/config/test_command_builders.py:39]
    • Chosen: Shared builder, guarded to config, one copy. Both entry points use it, one copy avoids duplicate flags, and fs and image commands stay as they are.
    • Rejected: Shared builder, every scan type. It changes the fs and image commands and breaks the exact-list assertion of tests/config/test_command_builders.py:39.
    • Rejected: Config scanner only. scan_plans.py:34 builds its command from the shared builder and would miss the flags.
    • Rejected: Both builders, one copy each. The config scanner extends the shared builder, so this repeats each pattern.
  • Does --skip-dirs accept **/.venv as a glob pattern?: Use the glob patterns **/.venv and **/node_modules, and the literal tests/fixtures. The issue measured --skip-dirs '**/.venv' against a folder that holds only .venv/lib/pkg/Dockerfile with Trivy 0.76.2, the version the runner image pins (docs/CLUSTER.md:68), and it reported 2 misconfigurations without the flag and none with it. The repository documents no other source for the flag's matching rules, so the offline test asserts the arguments and the measurement of the issue covers the effect. (best practice) [sources: docs/CLUSTER.md:68, src/devops_cli/config/commands.py:75, src/devops_cli/security/trivy.py:231]
    • Chosen: Glob patterns **/.venv and **/node_modules, literal tests/fixtures. The issue measured the **/.venv form with the pinned Trivy 0.76.2, and a glob matches the folder at any depth.
    • Rejected: Plain names .venv and node_modules. The issue measured only the glob form, and a plain name gives no evidence for a folder below the scan root.
    • Rejected: Keep the .trivyignore.yaml entries and add no flag. Each entry expires 3 days after it is written (SECURITY.md:81).
  • Which code-scanning tool name does the trivy config upload use?: Trivy-config, not Trivy. CONST_TRIVY_CONFIG_ALERT_TOOL is "Trivy-config", devops scan alerts queries the code-scanning API with it, and SECURITY.md names the tool Trivy-config. The live checks of the acceptance criteria use that name. [sources: src/devops_cli/config/constants.py:5285, src/devops_cli/security/scan_plans.py:55, SECURITY.md:99]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/security
    on Nov 15, 2026
  2. added
    status/new
    value/low
    effort/low
    on Nov 15, 2026
  3. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor
  4. changed the title [-]fix(security): judge Trivy-config DS-0029 in .venv/lib/python3.14/site-packages/harbor/cli/template-adapter/task-template/environment/Dockerfile[/-] [+]fix(security): Judge Trivy DS-0029 in task-template Dockerfile[/+] on Nov 15, 2026
  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    The job shortened the title of this item. The summary had 129 characters, and the limit is 60. The type and the scope stay.

    • Before: fix(security): judge Trivy-config DS-0029 in .venv/lib/python3.14/site-packages/harbor/cli/template-adapter/task-template/environment/Dockerfile
    • After: fix(security): Judge Trivy DS-0029 in task-template Dockerfile
    • Source of the summary: the background model
  6. devops-cli-service commented on Nov 18, 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.

  7. changed the title [-]fix(security): Judge Trivy DS-0029 in task-template Dockerfile[/-] [+]fix(security): trivy config skips .venv, node_modules and tests/fixtures[/+] on Nov 19, 2026
  8. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  9. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 29, 2026
  10. removed
    status/in-review
    owner/agent
    on Nov 29, 2026
  11. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:17 UTC

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/p2-mediumscope/securitytype/bugvalue/low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions