Skip to content

fix(security): kube-linter findings carry their own check, message and manifest file, and scan reports keep each one #1045

Closed

Description

@dan-petty

Problem

_finding_from_report (src/devops_cli/security/kubelinter.py:44-59) reads the check name from the report's Diagnostic (:46-48). kube-linter puts Check and Remediation at report level, beside Diagnostic, which holds only Message. A local run of kube-linter lint k8s/cloudflared/deployment.yaml --format json (kube-linter 0.8.3, tree at da50329) returns one report with the keys Check, Diagnostic, Object and Remediation. Its Check is no-anti-affinity and its Diagnostic has only Message. So every kube-linter finding is titled [kube-linter-check] K8s Security Lint Warning, and its fix says "to resolve kube-linter-check". The bug has been there since the adapter was added in v0.1.8 (4e48cd7).

Two tests hide it. Both fixtures nest Check inside Diagnostic: tests/test_secops.py:67-70 (test_kubelinter_parser, "Check" at :69) and :165 (test_kubelinter_scanner_execution). tests/test_consolidation_security_scanner_base.py:349-359 has the real shape, but the contract test only asserts that some finding comes out (:470-473).

What it costs:

  • Reviews. In S7 and S8 (.data/reviews/20261003-005122 and -012555), all 5 kube-linter candidates have the same title: 1 is no-anti-affinity and 4 are dangling-service. In S8 all 5 are in the security class, because the template title says "Security". They are 5 of S8's 17 security candidates. The title and the fix name no check. kube-linter's message survives only in the description.
  • Scan reports. devops scan report dedupes by fingerprint, which is tool, rule id, path and message (src/devops_cli/security/normalization.py:150-159, deduped at security/pipeline.py:141). The rule id is the title's bracket, and the message is the rest of the title. Both are the same for every kube-linter finding. A directory scan also locates every finding at the directory, not at the manifest. parse_kubelinter_json uses target_path (kubelinter.py:62-65) and ignores Object.Metadata.FilePath. I replayed this at da50329 with the real adapter and build_report. kube-linter over k8s/ gives 7 reports, from 4 checks in 3 files. The report keeps 1 of the 7. Its rule id is kube-linter-check, its message is "K8s Security Lint Warning", and its location is k8s:Deployment/cloudflared.
  • SARIF and suppressions. SARIF's ruleId is that rule id (security/sarif.py:75, :103), so every kube-linter result has the same rule. A suppression by rule (security/suppression.py:63) cannot name one kube-linter check.
  • One message in one file. The fingerprint leaves out the symbol (Service/prometheus). So two objects in one manifest with the same check and message also share a fingerprint. I replayed it with the check name and kube-linter's message in the title. k8s/monitoring/service-aliases.yaml then keeps 3 of its 4 dangling-service findings, because the prometheus and kube-prometheus-kube-prome-prometheus Services select the same labels. The k8s/ report keeps 6 of 7.

The taxonomy replay (defect_class, src/devops_cli/ai/review_schema.py:625-640):

  • If the check name goes into today's template, no-anti-affinity becomes reliability and dangling-service stays security. 45 of the 63 checks built into kube-linter 0.8.3 would still be security, from the word in the template.
  • If kube-linter's message is the title, 6 of the 7 k8s/ findings are other. That includes run-as-non-root, which is a security misconfiguration.

Acceptance criteria

  • _finding_from_report reads Check and Remediation from the report, and Message from Diagnostic. The title is [<check>] <message>, the same form the Bandit and Semgrep adapters use (security/bandit.py:33, security/semgrep.py:69). The fix is kube-linter's Remediation when there is one, and the template otherwise.
  • The adapter sets the category to the class that the check name or the message names. When neither names a class, or they name only security, the category is security_misconfiguration.
  • The location names the manifest from Object.Metadata.FilePath, made relative as _manifest_location does (kubelinter.py:21-34). target_path is used only when FilePath is missing. A directory scan names each file.
  • NormalizedFinding.fingerprint includes the symbol when the finding has one. A finding without a symbol keeps its fingerprint, and a test pins one. The line stays out of the fingerprint. A Kubernetes object's name, unlike a line, does not move when lines are added above it.
  • A test passes two Popeye issues on two resources of one sanitizer through build_report and keeps 2. It fails on the current code, which keeps 1.
  • The fixtures at tests/test_secops.py:67-70 and :165 put Check at report level. A fixture under tests/fixtures/ holds the 7 reports of kube-linter lint k8s --format json at da50329 (4 checks, 3 files), trimmed, with FilePath made relative. A test parses it. It asserts that each title names its own check, each location names its own file, no-anti-affinity is reliability and dangling-service is security_misconfiguration. It fails on the current code.
  • A test passes that fixture through build_report and keeps 7 of 7 findings, with the rule ids dangling-service, no-anti-affinity, no-read-only-root-fs and run-as-non-root. to_sarif emits those 4 rules. The test fails on the current code, which keeps 1 finding under 1 rule.
  • The kube-linter contract test (tests/test_consolidation_security_scanner_base.py:444-473) asserts that its finding's title names no-read-only-root-fs.
  • The tests run offline, call no kube-linter binary, and each runs well under 1 s.
  • changelog.d/1045.md records the fix under ### Fixed. It says that every symbol-located finding gets a new fingerprint, so a fingerprint suppression of a Trivy, Pluto, Popeye, Dive or kube-linter finding must be recorded again. CHANGELOG.md is not edited.
  • uv run devops ci passes.
  • (person-run) devops scan report k8s --scanner kubelinter lists 7 findings under 4 rule ids. devops k8s lint k8s/cloudflared/deployment.yaml names no-anti-affinity.

Key questions

  • What class should a kube-linter finding get when its words name none, or name only security? (proposed) security_misconfiguration, set by the adapter after the check name and the message are tried. kube-linter checks manifests for misconfiguration. With words alone, 6 of the 7 k8s/ findings would be other, run-as-non-root among them. With today's template, 45 of the 63 built-in checks land in security, the catch-all. Under the proposed rule, S8's 5 kube-linter candidates become 1 reliability and 4 security_misconfiguration, and S8's security count falls from 17 to 12.
  • Does the fingerprint change belong here? (proposed) Yes. Without it the k8s/ report keeps 6 of 7 even after the adapter fix. A line-located finding keeps its fingerprint. Every symbol-located finding gets a new one, not only kube-linter's: Trivy (<target>:<package> or <target>:<rule>, security/trivy.py:47, :70, :87), Pluto (pluto.py:41), Popeye (popeye.py:29) and Dive (dive.py:191). Their fingerprint suppressions and SARIF partialFingerprints change once. That also fixes the same collapse in Popeye. Its title is [<SANITIZER>] Cluster Sanitizer Finding for every issue at k8s:<sanitizer>/<resource> (popeye.py:27-31). A replay of two issues on two resources through build_report at da50329 keeps 1. The project is pre-1.0, so the changelog fragment states the change and no migration is added.
  • Should the SARIF fingerprint key devopsCli/v1 (src/devops_cli/config/constants.py:2616) change? (proposed) Follow test(security): pin the finding fingerprint and run-store digest to literal values #855 if it has landed first. Its rule is that an algorithm change bumps the key and updates the pinned values. If it has not landed, keep the key, and the changelog fragment is the record.
  • Should Semgrep and Bandit findings carry their CWE ids in references, so that security stops being the catch-all for them too? (proposed) Yes, but as a separate p3 item, not here. In S8, the 12 security candidates left after this fix are 7 Semgrep non-literal-import findings and 5 Bandit B108 findings. Bandit's JSON has issue_cwe: a local run gives B108 {"id": 377}. assign_category would turn that into CWE-377, which CONST_REVIEW_CWE_DEFECT_CLASSES (src/devops_cli/config/constants.py:2981) themes as race_condition. Semgrep rules carry extra.metadata.cwe, but the adapter reads only cve and owasp (security/semgrep.py:39-48). The registry lists CWE-706 for non-literal-import (not checked offline), and the table does not map 706. So those 7 would stay security until the table maps 706. It is separate because it changes two other adapters and the CWE table, and fix(review): the review's scanner config drops the rules that never produced a valid finding on this repository #1024 may drop non-literal-import altogether.

Depends on: none.
Order: no ordering constraint. The change touches security/kubelinter.py, security/normalization.py (fingerprint only) and their tests. #1024 removes dangling-service from the review's kube-linter config, and either order works. #1021's golden replays use S5's saved kube-linter findings with today's titles, so this change does not affect them. #855 (no milestone) pins fingerprints to literal values. Whichever lands second updates the pins for a symbol-located finding.
Related: #855 (fingerprint pins and the key-bump rule). #1024 (drops dangling-service and two Semgrep rules from the review's scanner config). #1021 (proposes that its restatement guard ignore scanner boilerplate words such as kube-linter's template. The new titles carry kube-linter's message instead). #948 (the category taxonomy that made the catch-all visible). #788 (scanner paths in review findings are absolute; this item fixes only kube-linter's directory location). #1023 (cloudflared's no-anti-affinity, the one valid kube-linter finding in S7 and S8).

Review redesign additions (2026-10-03)

This item is a phase P0 child of the evidence-first review (#1137). The body stands, with these additions:

Acceptance criteria (added).

Related (added). #1141 (fingerprint v2; this item is its P0 child), #855 (its fingerprint pins move to #1141 and are pinned on v2).

Update 2026-10-09: re-scope before building (v0.2.30)

An assessor and a challenger checked this item against release/v0.2.30 (edd2578), replaying kube-linter 0.8.3 offline. The original body still holds and is built as written. Of the 2026-10-03 "review redesign additions":

Activity

  1. added
    type/bug
    scope/security
    scope/review
    priority/p2-medium
    on Oct 3, 2026
  2. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    What S10 adds (review session 20261003-034353, release/v0.2.25 at d6ebe97; .data/review-evaluation-20261003-s10.md, sections 3-4).

    The same-title bug also loses findings inside a review (D12).

    Suggested scope line: a test runs the 27 reports (a trimmed fixture) through the review's consolidation and keeps 27 candidates, 9 per check. It fails on the current code.

    Related, p3 and outside kube-linter [inference; Semgrep was not re-run]:

    • The 2 Semgrep yaml.kubernetes.security.* findings on the same file each merge 9 matches across DaemonSets that share a backticked symbol. A replay with synthetic matches gives 18 → 2.
    • Each merged finding's location names the 16gib DaemonSet (:50, :33), while its description names the 24gib one (:150, :136).
  3. added this to the v0.2.30 milestone on Oct 8, 2026
  4. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.30 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: P1 secret and sandbox-boundary fixes, the review tools lock, kube-linter finding identity and a faster gate. Position 7 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.

  5. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Linked: #788 (repo-relative Bandit and Semgrep paths) and #1140, whose per-manifest failure rule this item keeps for kube-linter and Pluto. Found by the 2026-10-08 backlog review.

  6. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1471, merged into release/v0.2.30 as c58079f.

    Summary

    kube-linter puts Check and Remediation next to Diagnostic, but the adapter read the check from inside Diagnostic. Because of that, every kube-linter finding since v0.1.8 had the title [kube-linter-check] K8s Security Lint Warning, and a directory scan located every finding at the directory itself. Every finding of a scan got the same fingerprint, so devops scan report kept 1 of the 7 reports over k8s/ at da50329, and a review merged different checks on one object into one candidate.

    • Adapter (security/kubelinter.py):
      • The title is [<check>] <message>, so the check becomes the rule id and the SARIF ruleId.
      • The fix is kube-linter's Remediation, or the template when there is none.
      • The location is <manifest from Object.Metadata.FilePath>:<Kind>/<namespace>/<name>, or <Kind>/<name> when there is no namespace. No default namespace is guessed.
      • The category is the class named by the check or the message; when neither names one, it is security_misconfiguration.
    • Identity (security/normalization.py):
      • The fingerprint includes the symbol when there is one. A finding without a symbol keeps its old fingerprint (pinned in a test).
      • correlation_key includes the symbol.
      • split_location reads path:start-end and :<line> as lines, so those never become symbols.
    • Display:
      • format_k8s_lint_table escapes its location, title and fix cells. Before, Rich read [no-anti-affinity] as a markup tag and dropp…

    16 file(s) changed.

    How it was verified

    Check runs at cc86c24:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1045-kube-linter-finding-identity.md:

    • _finding_from_report reads Check and Remediation from the report and Message from Diagnostic. The title is [<check>] <message>, and the fix is the Remediation, or the template without one (test_each_title_names_its_own_check_and_message, test_the_fix_is_kube_linters_remediation, test_a_report_without_a_remediation_gets_the_template_fix in tests/test_security_kubelinter.py).
    • The category is the class the check name or the message names, and security_misconfiguration when neither names one or they name only security (test_the_category_is_the_class_the_check_names_or_a_misconfiguration).
    • The location names the manifest from Object.Metadata.FilePath, made relative as _manifest_location does; target_path is used only when FilePath is missing, and a directory scan names each file (test_each_location_names_its_own_file_and_object; test_kubelinter_locations_are_relative_to_the_nested_worktree in tests/test_secops.py covers a report without FilePath).
    • NormalizedFinding.fingerprint includes the symbol when the finding has one, a finding without a symbol keeps its fingerprint, and the line stays out (test_a_fingerprint_distinguishes_two_objects_with_one_message, test_a_finding_without_a_symbol_keeps_its_fingerprint, test_a_fingerprint_survives_the_finding_moving_to_a_new_line and test_a_multi_line_result_keeps_its_fingerprint_when_it_moves in tests/test_security_sarif.py).
    • Two Popeye issues on two resources of one sanitizer go through build_report and both are kept; the base code kept 1 (test_two_popeye_issues_on_two_resources_of_one_sanitizer_are_kept).
    • The fixtures of test_kubelinter_parser and test_kubelinter_scanner_execution put Check at report level (the second also puts Kind under GroupVersionKind). tests/fixtures/kubelinter/k8s-da50329.json holds the 7 reports of kube-linter lint k8s --format json at da50329 (kube-linter 0.8.3, 4 checks, 3 files), trimmed to Check, Diagnostic.Message, Remediation, Object.Metadata.FilePath (made relative) and Object.K8sObject, plus Summary.KubeLinterVersion. tests/test_security_kubelinter.py parses it; each test failed on the base code.
    • The fixture through build_report keeps 7 of 7 findings in 7 clusters, whose 7 --json entries are distinct, under the rule ids dangling-service, no-anti-affinity, no-read-only-root-fs and run-as-non-root, and to_sarif declares those 4 rules; the base code kept 1 under 1 rule (test_a_scan_report_keeps_every_finding_under_its_own_rule).
    • devops k8s lint prints the check in its Title column: a finding titled [no-anti-affinity] ... renders with [no-anti-affinity] (test_the_kube_linter_table_names_each_check in tests/test_output.py; it failed before the cells were escaped).
    • The kube-linter contract sample's title names no-read-only-root-fs (test_kubelinter_contract_finding_names_its_check in tests/test_consolidation_security_scanner_base.py, beside the parametrized contract test).
    • The tests run offline, call no kube-linter binary, and each runs well under 1 s.
    • changelog.d/1045.md records the fix under ### Fixed, including the one-time fingerprint change of every symbol-located finding (Trivy, Pluto, Popeye, Dive, kube-linter). CHANGELOG.md and docs/ROADMAP.md are not edited.
    • uv run devops ci passes.
    • From the 2026-10-03 additions: the check name is the SARIF ruleId, and kube-linter's symbol is Kind/<namespace>/<name>, or Kind/name without a namespace.
    • From the S10 comment: consolidate_duplicate_findings keeps the 7 fixture findings; the base code kept 6, because the registry Deployment's two checks merged (test_a_review_keeps_two_checks_on_one_object).
    • Pending a person: devops scan report k8s --scanner kubelinter shows one row per kube-linter report under its own check: 7 rows under 4 rule ids over da50329's k8s/, 6 under 4 over the release head's k8s/ (the pyroscope alias is gone). An agent run on this branch with kube-linter 0.8.3 gave 6 findings in 6 distinct --json clusters, each naming its object.
    • Pending a person: devops k8s lint k8s/cloudflared/deployment.yaml names no-anti-affinity. An agent run on this branch with kube-linter 0.8.3 showed [no-anti-affinity] object has 2 replicas ... in the Title column.
  7. added a commit that references this issue on Oct 9, 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

    priority/p2-mediumscope/reviewscope/securitytype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions