Skip to content

fix(security): pin kubeconform and replace Checkov with Trivy's misconfiguration scan - #2464

Merged
dan-petty merged 18 commits into
mainfrom
fix/2214-pin-kubeconform-drop-checkov
Oct 28, 2026
Merged

dan-petty merged 18 commits into
mainfrom
fix/2214-pin-kubeconform-drop-checkov

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The scanner registry held a kubeconform adapter and a Checkov adapter, but tools.lock pinned neither tool, and devops install-tools installed neither. Both adapters had built-in patterns, so each scan ran hand-written checks in place of the tool. When a person installed a tool by hand, the adapter read its output wrong. The kubeconform parser read one JSON object for each line, but kubeconform -output json writes one object, {"resources": [...]}, so a report with invalid resources gave no finding. The Checkov parser took the severity from the name of the check, so the LOW in ALLOW made a check LOW.

kubeconform:

  • tools.lock pins kubeconform 0.8.0 as a binary with a SHA-256 for each platform. No other pinned tool validates each resource against the Kubernetes JSON schemas. The schema-validation check of kube-linter is not in its default checks, and it does not report an object that does not decode into its Go type.
  • The adapter reads the resources of the report. Each resource with statusInvalid or statusError is one HIGH finding at <manifest>:<Kind>/<name>. A resource with statusValid or statusSkipped gives no finding.
  • The adapter gives kubeconform only the path of each Kubernetes manifest of the target that git lists and does not ignore. kubeconform reports each other YAML or JSON file of a directory, for example a Helm values file or a dashboard, as statusError. A target with no manifest is not_applicable, and kubeconform does not start.
  • The hand-written fallback is deleted. With no kubeconform on PATH, the scan is unavailable and has no finding. devops k8s validate then says that the validation did not run and exits 1. The agent tool k8s_validate_manifests runs the adapter and replies as the other agent scan tools reply. Thus a validation that did not run never reads as a pass.

Checkov:

  • The Checkov adapter, its hand-written checks, the constants that only those checks read, devops scan iac and its MCP tool, their help and message strings, and the knowledge base page of Checkov are deleted. The pinned Trivy has a check for each defect that Checkov 3.3.30 found in a Dockerfile, a Terraform security group and a Pod. Without a Prisma Cloud API key, Checkov writes no severity. Each Checkov run also connects to pypi.org and api0.prismacloud.io. A hashed pin of Checkov holds 97 packages.
  • The registry holds trivy-config, which runs trivy config <target> --severity <severities> --format json --quiet. Thus devops scan report still scans IaC files. The agent tool scan_iac runs Trivy's misconfiguration scan. devops scan trivy --type config is the IaC scan of the command line.
  • The static job of CI installs the pinned Trivy before its security scan, so that scan also scans IaC files.

Tests and documents:

  • tests/fixtures/scanner_runs/runs_with_findings.json holds a run of kubeconform 0.8.0 with the command of the adapter, and tests/fixtures/scanner_runs/kubeconform_verbose_run.json holds a -verbose run with all four statuses. A contract test holds each run with findings to the version that tools.lock pins. The images pin uv, and tools.lock does not, so the test does not compare the run of uv audit.
  • The knowledge base page of kubeconform names the pinned version and its report. The knowledge base page of Trivy and docs/ROUTINE_TASKS.md show devops scan trivy --type config as the IaC scan. docs/DEVCONTAINER_USAGE.md, .github/labels.yml and the generated command, MCP tool and knowledge base documents name no Checkov.

The tflint and dive adapters stay in the registry. tools.lock does not pin them, and #2427 decides them.

Closes #2214

Change: openspec/changes/archive/2026-10-28-2214-pin-kubeconform-drop-checkov/

…2214

kubeconform has no pinned equivalent that validates every resource, so
tools.lock pins it. The pinned Trivy covers the checks of Checkov, so the
Checkov adapter goes and Trivy's misconfiguration scan takes its place.
tools.lock pins kubeconform 0.8.0. The recorded runs show the one report
object that kubeconform writes. The new tests fail: the parser reads one
object for each line, and a missing kubeconform runs the hand-written
fallback.
kubeconform -output json writes one object, {"resources": [...]}. The
parser now gives one HIGH finding at <manifest>:<Kind>/<name> for each
resource with statusInvalid or statusError, and no finding for
statusValid or statusSkipped. tools.lock pins kubeconform, so the
hand-written fallback and the parser of one object for each line go.

With no kubeconform on PATH, the scan is unavailable. devops k8s
validate then says that the validation did not run and exits 1. The
agent tool k8s_validate_manifests replies as the other agent scan
tools reply.
The knowledge base page of kubeconform applies to 0.8, the version that
tools.lock pins. It says what the report holds, which resources are
findings, and that no hand-written check replaces a missing
kubeconform. The scanner fake says when the kubeconform run was
recorded.
The new tests fail: the registry holds no trivy-config scanner,
devops scan iac still runs Checkov, and the agent tool scan_iac still
runs Checkov. The tests that named Checkov as a sample program or a
drifted manual now name kubeconform and grafana.md.
tools.lock does not pin Checkov, so each scan ran its hand-written
checks. The pinned Trivy has a check for each defect that Checkov found
on the same Dockerfile, Terraform and Kubernetes files, and it writes a
severity for each check. Checkov wrote no severity without an API key
and called pypi.org and api0.prismacloud.io on each run.

The registry holds trivy-config, which runs trivy config over the
target, in the place of the Checkov adapter. The agent tool scan_iac
runs it. The Checkov adapter, its hand-written checks, the constants
that only they read, and devops scan iac with its MCP tool go. devops
scan trivy --type config scans IaC files from the command line, and its
help names config in the place of iac, which Trivy does not have.
…scan

Delete the knowledge base page of Checkov, its index row and the
`devops scan iac` row of the knowledge base command reference. The knowledge
base page of Trivy shows `devops scan trivy --type config` as the IaC scan and
the `trivy-config` registry entry. The devcontainer document and the label of
scope/security name kubeconform and no Checkov. The generated command, MCP and
knowledge base documents are regenerated. tasks.md names #2427 for tflint and
dive.
The change deletes `devops scan iac`, so the requirement of scan-json-stdout
that names it is MODIFIED to name the other scan commands only. The
k8s-validate requirement says what the command does when kubeconform finds
nothing, and design.md records that a finding still exits 0, as
`devops k8s check-deprecated` does.
The test that hides kubeconform set PATH to an empty directory. The command
loads GitPython, which fails to import with no git on PATH, so the test passed
only when an earlier test of the same worker had imported GitPython. The PATH
of the test now holds git and no scanner.
The change deletes `devops scan iac`. The value command set of the format adoption test still named it, so the test failed. The set now holds 143 commands.
kubeconform reads each YAML and JSON file of a directory that it gets. It
reported each Helm values file, Helm template, workflow and dashboard as
`statusError`, and the parser made each of them a HIGH finding. Over `k8s/`
of this repository, it gave 33 such findings.

The adapter now gives kubeconform the path of each manifest of the target
that git lists and does not ignore. A target with no manifest is
`not_applicable`, and kubeconform does not start. The recorded runs name the
manifest file, and the OpenSpec change records the decision.
… job

The Checkov fallback was the IaC check of the CI security scan, and its
findings went to code scanning. The change deletes Checkov, and
`trivy-config` takes its place, but the static job had no Trivy. So the
scan checked no IaC file.

The static job now installs the pinned Trivy before the scan. Over this
tree, `trivy-config` found the privileged container and the root user that
the Checkov fallback found, in 23 s. The scan skips `trivy`, the
filesystem scan, which took 194 s.
Trivy has no `iac` command, so `devops scan trivy k8s/ --type iac` stopped with an error. The routine scan now uses `--type config`, the IaC scan of the command line.
A kubeconform finding names the kind and the name of the resource, and its
schema errors, from the manifest. The schema table of `devops k8s validate`
read each cell as Rich markup, so a name such as `web[/bold]` stopped the
command with a markup error. The table now escapes each cell, as the
kube-linter table does.
…e sentences

The proposal, the design and the spec deltas had sentences of more than 25
words, and the message of a validation that did not run used the passive
voice. ASD-STE100 asks for at most 25 words in a description and for the
active voice. The proposal also says that #2427 decides tflint and dive,
which acceptance criterion 1 also names.
The run with findings of uv audit came from main (#2106). The images pin
uv, and tools.lock does not. Thus the version test of the runs with
findings does not compare the run of uv.
@dan-petty dan-petty added scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak labels Oct 28, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results of the head 0583a994 (after the rebase onto origin/main at 1f9231d2):

  • uv run devops ci test over the 19 test files that this change touches, and tests/test_docs.py, tests/test_github_labels.py and tests/test_security_uv_audit.py: 555 passed.
  • After the second rebase, uv run devops ci test over tests/commands/test_k8s_validate.py, tests/test_builtin_tools.py, tests/test_consolidation_security_scanner_base.py, tests/test_scan.py, tests/test_scanner_contract.py, tests/test_secops.py, tests/test_security_kubeconform.py, tests/test_subprocess_env_boundary.py and tests/test_config_audit_keys.py: 305 passed.
  • uv run devops openspec check: passed. uv run devops docs generate --sync-readme changed no file.
  • The pre-push hook (fast static checks of devops ci) passed.

The rebase had a conflict with #2446, which added a recorded uv audit run to tests/fixtures/scanner_runs/runs_with_findings.json. The images pin uv, and tools.lock does not, so the commit test(security): compare only the runs of the tools that the lock pins keeps the uv run out of the version test.

Fail-to-pass, uv run devops ci fail-to-pass --base origin/main (exit 0): 32 tests failed on the base and 465 passed, and all of them pass on the head. For example, devops k8s validate exited 0 with "valid schemas" on the base when kubeconform did not run, the recorded kubeconform report gave a failed scan with no finding on the base, and devops scan iac exited 0 on the base. An earlier run, before the rebase, gave 26 failed and 343 passed.

Tests that failed on the base
failed on base: tests.test_kb::test_get_knowledge_base_stats (AssertionError: assert 39 == 38)
failed on base: tests.test_kb::test_list_knowledge_base_articles_by_category (AssertionError: assert 29 == 28)
failed on base: tests.test_kb::test_list_knowledge_base_articles_by_division (AssertionError: assert 39 == 38)
failed on base: tests.test_kb::test_list_knowledge_base_articles_all (AssertionError: assert 77 == 76)
failed on base: tests.test_ci::test_ci_security_scan_installs_the_pinned_trivy_for_its_iac_scan (AssertionError: assert (False, 'uv r...-skip bandit') == (True, 'uv ru...bandit,trivy'))
failed on base: tests.test_ci::test_ci_workflow_publishes_scanner_sarif_to_code_scanning (AssertionError: assert ('write', 'uv...ps-scan', ...) == ('write', 'uv...ps-scan', ...))
failed on base: tests.commands.test_k8s_validate::test_a_target_with_no_manifest_says_so_and_fails (assert (0, True, Fal...ir_files={})]) == (1, False, True, []))
failed on base: tests.commands.test_k8s_validate::test_a_validation_that_did_not_run_says_so_and_fails (AssertionError: assert (0, True, 'Va...lid schemas.') == (1, False, 'V...id not pass.'))
failed on base: tests.commands.test_k8s_validate::test_a_finding_shows_the_text_of_the_manifest_as_text (assert (0, False, False) == (0, True, True))
failed on base: tests.test_builtin_tools::test_an_agent_scan_tool_whose_scanner_fails_with_no_output_says_failed_and_not_clean[trivy-config] (assert ('Checkov IaC...olations.', 0) == ('Trivy scan ...as clean.', 1))
failed on base: tests.test_builtin_tools::test_the_agent_manifest_tool_reports_each_resource_that_kubeconform_finds_invalid (assert ([ScannerRun(...ool_r0/k8s'.") == ([ScannerRun(...nt integer.)'))
failed on base: tests.test_builtin_tools::test_an_agent_scan_tool_whose_scanner_is_not_installed_says_so_and_not_clean[trivy-config] (AssertionError: assert 'Checkov IaC ...y violations.' == 'Trivy scan s...get as clean.')
failed on base: tests.test_builtin_tools::test_the_agent_iac_tool_runs_the_misconfiguration_scan_of_trivy (AssertionError: assert ([], 'Checkov... violations.') == ([['trivy', '...No findings.'))
failed on base: tests.test_builtin_tools::test_an_agent_scan_tool_whose_scanner_is_not_installed_says_so_and_not_clean[kubeconform] (assert "Kubeconform ...ol_whose_14'." == 'Kubeconform ...get as clean.')
failed on base: tests.test_builtin_tools::test_an_agent_scan_tool_whose_scanner_fails_with_no_output_says_failed_and_not_clean[kubeconform] (assert ("Kubeconform...hose_16'.", 1) == ('Kubeconform...as clean.', 1))
failed on base: tests.test_scan::test_scan_has_no_iac_command (assert (0, False) == (2, True))
failed on base: tests.test_kb_manuals_metadata::test_every_target_manual_has_valid_front_matter (AssertionError: assert 61 == 60)
failed on base: tests.test_consolidation_security_scanner_base::test_all_11_scanners_dry_run_simulation (assert None is not None)
failed on base: tests.test_consolidation_security_scanner_base::test_all_11_scanners_registered_in_global_registry (AssertionError: Scanner 'trivy-config' is not registered in global_scanner_registry)
failed on base: tests.test_consolidation_security_scanner_base::test_scanner_contract_execution_and_parsing[trivy-config] (assert None is not None)
failed on base: tests.test_consolidation_security_scanner_base::test_scanner_fallback_when_binary_unavailable (assert None is not None)
failed on base: tests.test_consolidation_security_scanner_base::test_scanner_contract_execution_and_parsing[kubeconform] (AssertionError: Scanner 'kubeconform' failed to produce normalized findings from sample output)
failed on base: tests.test_consolidation_security_scanner_base::test_all_11_scanner_classes_inherit_base_security_scanner (ImportError: cannot import name 'TrivyConfigScanner' from 'devops_cli.security' (/tmp/tmpbwor3e31/tree/src/devops_cli/security/__init__.py))
failed on base: tests.test_secops::test_the_registry_scans_iac_files_with_the_misconfiguration_scan_of_trivy (KeyError: 'trivy-config')
failed on base: tests.test_scanner_contract::test_a_registry_scan_whose_pinned_program_is_missing_runs_no_built_in_patterns (assert 'kubeconform' in {'bandit': ScanOutcome(status='unavailable', findings=[], reason="Binary 'bandit' not found on PATH", unscanned={}, fa...', findings=[], reason="Binary 'kube-linter' not found on PATH", unscanned={}, failed_files={}, file_statuses={}), ...})
failed on base: tests.test_scanner_contract::test_each_run_with_findings_is_of_the_version_the_tools_lock_pins (KeyError: 'kubeconform')
failed on base: tests.test_security_kubeconform::test_a_resource_that_kubeconform_cannot_read_is_named_by_its_manifest (AssertionError: assert [] == [('k8s/app.ya...e validated')])
failed on base: tests.test_security_kubeconform::test_kubeconform_gives_no_finding_for_a_valid_or_skipped_resource (KeyError: 'kubeconform')
failed on base: tests.test_security_kubeconform::test_kubeconform_reports_each_resource_it_finds_invalid_or_cannot_validate (AssertionError: assert ([ScannerRun(... 'failed', []) == ([ScannerRun(...operties={})]))
failed on base: tests.test_security_kubeconform::test_kubeconform_reads_only_the_manifests_that_git_lists (AssertionError: assert (ScanOutcome(...trict', ...]]) == (ScanOutcome(...trict', ...]]))
failed on base: tests.test_security_kubeconform::test_a_target_with_no_manifest_is_not_applicable_and_starts_no_kubeconform (AssertionError: assert (ScanOutcome(...ir_files={})]) == (ScanOutcome(...tuses={}), []))
failed on base: tests.test_security_kubeconform::test_a_missing_kubeconform_is_unavailable_and_runs_no_fallback (AssertionError: assert ScanOutcome(s...e_statuses={}) == ScanOutcome(s...e_statuses={}))
32 failed on base (32 failed and 465 passed in tests/commands/test_k8s_validate.py, tests/test_builtin_tools.py, tests/test_ci.py, tests/test_cli_format_adoption.py, tests/test_consolidation_process_json.py, tests/test_consolidation_security_scanner_base.py, tests/test_fastmcp_contracts.py, tests/test_k8s.py, tests/test_k8s_manifest_validation.py, tests/test_kb.py, tests/test_kb_manuals_metadata.py, tests/test_scan.py, tests/test_scanner_contract.py, tests/test_secops.py, tests/test_security_kubeconform.py, tests/test_suite_refuses_real_programs.py; 0 errored).

@github-advanced-security

Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

TrivyScanner.build_command takes scan_type as str | None, so that a
registry run uses the scan type of its class. The override of
TrivySbomScanner kept str, and mypy refused the override.
The specs of scanner-adapters, agent-scan-tools and scan-json-stdout
get the requirements of the change, and the new k8s-validate spec
holds the outcome of devops k8s validate.
@dan-petty
dan-petty force-pushed the fix/2214-pin-kubeconform-drop-checkov branch from 40ffa8e to add6e91 Compare October 28, 2026 17:20
@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 17:26
@dan-petty
dan-petty merged commit 960e357 into main Oct 28, 2026
17 checks passed
@dan-petty
dan-petty deleted the fix/2214-pin-kubeconform-drop-checkov branch October 28, 2026 17:26
@dan-petty

Copy link
Copy Markdown
Owner Author

The first run of Static Analysis failed on mypy: TrivySbomScanner.build_command in src/devops_cli/security/sbom.py kept scan_type: str, but this change made the argument of TrivyScanner.build_command str | None. The commit fix(security): give the SBOM scanner the scan type signature of Trivy changes the override to str | None. uv run mypy src found no issue in 560 files, and uv run devops ci test tests/test_sbom.py tests/test_secops.py tests/test_consolidation_security_scanner_base.py gave 52 passed. The archive commit stays the last commit. All 17 checks pass on the head add6e912.

dan-petty pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.10.0](v0.9.0...v0.10.0)
(2026-10-28)


### Features

* **review:** devops review intake hands the findings of a session on
merged code to roadmap intake
([#2455](#2455))
([a5c7b82](a5c7b82))
* **security:** devops k8s audit runs Popeye in the tool sandbox with a
kube-api network profile that only reads the API server
([#2467](#2467))
([e02c3fb](e02c3fb))
* **security:** the App's installation tokens carry only the permissions
the roadmap jobs use
([#2482](#2482))
([9599ef2](9599ef2)),
closes [#2473](#2473)


### Bug Fixes

* **config:** a config file that is not valid YAML stops the load with
an error that quotes none of its text
([#2468](#2468))
([91fe5dc](91fe5dc))
* **config:** config set reports an unknown key as unknown, not as a key
that needs a value
([#2465](#2465))
([8b650a6](8b650a6))
* **devcontainer:** run the checkout's devops in devcontainer terminals
([#2460](#2460))
([abd2d41](abd2d41))
* **k8s:** loki runs from the grafana-community chart on loki 3.7.9, out
of reach of CVE-2026-21729
([#2470](#2470))
([96c50c9](96c50c9))
* **security:** a credential keyword at the end of a line no longer
masks the first word of the next line
([#2461](#2461))
([b754a73](b754a73))
* **security:** a credential value is masked also when the next line
starts with a parenthesis
([#2477](#2477))
([ece25ca](ece25ca)),
closes [#2471](#2471)
* **security:** pin kubeconform and replace Checkov with Trivy's
misconfiguration scan
([#2464](#2464))
([960e357](960e357))
* **security:** refuse GCONV_PATH, SHELLOPTS, BASHOPTS and PS4 from a
caller, and archive the merged security changes
([#2453](#2453))
([1f9231d](1f9231d))


### Code Refactoring

* **ai:** chat_structured is the one structured-output path
([#2452](#2452))
([3509732](3509732))
* **github:** pr check-readiness reads one merge-readiness verdict from
github/ ([#2456](#2456))
([16442c4](16442c4))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
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/security Type security: a vulnerability or a leak

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(security): kubeconform and checkov are pinned and their adapters read what those tools write, or the adapters go

2 participants