Repository navigation
Description
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.
- Write a failing unit test first: the
trivy configcommand thatTrivyConfigScanner.build_command(src/devops_cli/security/trivy.py:231-246) andbuild_trivy_scan_cmd(src/devops_cli/config/commands.py:75-90) build skips**/.venv,**/node_modulesandtests/fixtures. - Add
--skip-dirsfor the three folders to both builders. - Delete the DS-0029 entry (
.trivyignore.yaml:32-36) and the 3tests/fixturesentries.
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
- The new unit test passes.
- Measured with Trivy 0.76.2: a folder that holds only
.venv/lib/pkg/Dockerfilegives 2 misconfigurations without the flag and none with--skip-dirs '**/.venv'. - After the merge, code-scanning alert 281 and the alerts of the fixtures close on the next Security Scan run. Then close fix(security): Add dated DS-0029 entry to .trivyignore.yaml #6382, fix(security): judge KSV-0014 in image_pins/chart_render.yaml #5948 and fix(security): judge Trivy KSV-0118 in kubernetes_adversary.yaml #6268.
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-dirsfollowed by**/.venv, by**/node_modulesand bytests/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-dirswith**/.venv, with**/node_modulesand withtests/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.pyasserts 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 .statereads 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.yamlentries does the change remove?: The DS-0029 entry at lines 32-36 hides the.venvharbor Dockerfile. Lines 2-16 hold threetests/fixturesentries: KSV-0014 forimage_pins/chart_render.yaml(line 2), KSV-0014 forprompt_adversaries/kubernetes_adversary.yaml(line 7), and KSV-0118 forimage_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 withchart_render.yamland 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 configskiptests/fixtures?: Yes. The owner decided on 2026-11-19 thattrivy configskipstests/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/fixtureswith--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.
- Chosen: Skip
- Should the scan also skip
.venvandnode_modules?: Yes..venvholds gitignored third-party site-packages (.gitignore:15), and alert 281 names a harbor Dockerfile inside it (.trivyignore.yaml:32).node_modulesholds 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.yamlentries. Each entry needs a renewal 3 days later (SECURITY.md:81).
- Which builder gets the
--skip-dirsflags, and for which scan types?: Put the flags inbuild_trivy_scan_cmd, guarded toscan_type == "config".TrivyConfigScanner.build_commandextends the shared builder throughsuper()and passesconfig, so it gets the flags with no second copy, andplan_trivy_scangets them for a config scan too. The guard leavestrivy fsandtrivy imageunchanged, which keeps the exact argument list thattests/config/test_command_builders.py:39asserts forfs. 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, andfsandimagecommands stay as they are. - Rejected: Shared builder, every scan type. It changes the
fsandimagecommands and breaks the exact-list assertion oftests/config/test_command_builders.py:39. - Rejected: Config scanner only.
scan_plans.py:34builds 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.
- Chosen: Shared builder, guarded to
- Does
--skip-dirsaccept**/.venvas a glob pattern?: Use the glob patterns**/.venvand**/node_modules, and the literaltests/fixtures. The issue measured--skip-dirs '**/.venv'against a folder that holds only.venv/lib/pkg/Dockerfilewith 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
**/.venvand**/node_modules, literaltests/fixtures. The issue measured the**/.venvform with the pinned Trivy 0.76.2, and a glob matches the folder at any depth. - Rejected: Plain names
.venvandnode_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.yamlentries and add no flag. Each entry expires 3 days after it is written (SECURITY.md:81).
- Chosen: Glob patterns
- Which code-scanning tool name does the
trivy configupload use?:Trivy-config, notTrivy.CONST_TRIVY_CONFIG_ALERT_TOOLis"Trivy-config",devops scan alertsqueries the code-scanning API with it, and SECURITY.md names the toolTrivy-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
devops-cli-service commentedon Nov 15, 2026
#4409 is the umbrella that judges all 52 Trivy-config alerts. The candidate judges only DS-0029 in one file.[-]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[/+]devops-cli-service commentedon Nov 15, 2026
The job shortened the title of this item. The summary had 129 characters, and the limit is 60. The type and the scope stay.
fix(security): judge Trivy-config DS-0029 in .venv/lib/python3.14/site-packages/harbor/cli/template-adapter/task-template/environment/Dockerfilefix(security): Judge Trivy DS-0029 in task-template Dockerfiledevops-cli-service commentedon Nov 18, 2026
Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.
[-]fix(security): Judge Trivy DS-0029 in task-template Dockerfile[/-][+]fix(security): trivy config skips .venv, node_modules and tests/fixtures[/+]devops-cli-service commentedon Nov 19, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
devops-cli-service commentedon Nov 29, 2026
Released in v0.247.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.247.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 16:17 UTC