Skip to content

kyverno: Associated Report Results never match namespaced policies #1148

Description

@HuzaifaAbdulRehman

What's happening

Opening any namespaced Policy's detail page in the Kyverno plugin shows an empty "Associated Report Results" table, even when matching PolicyReport results genuinely exist for it.

Why

AssociatedReportsSection in PolicyViewer.tsx matches report results by comparing the bare policy name:

for (const report of policyReports) {
  for (const result of report.results) {
    if (result.policy === policyName) {
      matchingResults.push({ ... });
    }
  }
}

Kyverno prefixes namespaced-policy results as <namespace>/<name> — this is already the convention bucketReportResults/usePolicyResultCounts rely on elsewhere in this plugin (policyResultBucket.ts). AssociatedReportsSection never applied it, so for a namespaced policy the comparison is always "default/require-labels" === "require-labels", which is never true.

Separately, the two report lists (policyReports, clusterPolicyReports) are scanned independently, but a ClusterPolicy's results can land in either report type depending on whether the matched resource is namespaced or cluster-scoped, so results could be missed even once the key comparison is fixed.

Fix

Reuse the existing <namespace>/<name> (or bare <name> for cluster-scoped) key convention from policyResultBucket.ts, and merge both report lists before filtering.

I have this implemented and tested locally, opening a PR now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions