Policy Reports

Policies API v1 endpoints for policy reports, scan findings, and publishing scan results.

Read policy reports for clusters and namespaces, look up findings from scan runs, and publish scan results to Nirmata Control Hub.

All paths are relative to /policies/api/v1. See Policies API v1 for authentication and conventions.

Endpoints

OperationMethodPath
List policy reportsGET/policy-reports
Publish a report chunkPOST/publishReportResult
Count policy reportsGET/policy-reports/count
Get policy report summaryGET/policy-reports/summary
Get a policy reportGET/policy-reports/{id}
Get the active report run for a sourceGET/report-results/active
List findings for a sourceGET/report-results/findings
List policy reports by clusterGET/policy-reports/by-cluster/{clusterRef}
List policy reports by gradeGET/policy-reports/by-grade/{grade}
List policy reports by namespaceGET/policy-reports/by-namespace/{namespace}
List findings for a scanGET/report-results/reports/{scanId}/findings

Reference

List policy reports

GET /policies/api/v1/policy-reports

Returns all Kubernetes policy reports stored for the tenant, paginated in memory with limit/offset.

Roles: admin

Query parameters

NameTypeRequiredDefaultDescription
limitintegerNo50Maximum number of items to return
offsetintegerNo0Number of items to skip

Response 200 (application/json)

Paginated: {items: PolicyReportDto[], total, limit, offset}

FieldTypeDescription
idstringPolicy report ID
kindstringKubernetes kind (PolicyReport / ClusterPolicyReport)
apiVersionstringKubernetes API version
uidstringKubernetes UID of the report
namestringReport name
namespacestringNamespace (empty for cluster-scoped reports)
resourceVersionstringKubernetes resourceVersion
summaryByCategoryobjectResult counts grouped by policy category
gradestringLetter grade assigned to the report
policyViolationCountintegerNumber of policy violations
yamlstringRaw report YAML
clusterRefobject {id}Reference to the cluster the report came from
resultsarrayAlways null in this API
summaryobjectAlways null in this API
policyDetailsobjectAlways null in this API

Errors

  • 500 — Failed to retrieve policy reports
  • 401 — Not authenticated
  • 403 — Caller’s role is not permitted for this operation

Publish a report chunk

POST /policies/api/v1/publishReportResult

Accepts one chunk of scan findings for a source and queues it for asynchronous processing. When all chunks for a scanId (totalFindings) are received, the new results replace the source’s active report. Returns 202 immediately.

Roles: admin, platform, security

Request body (application/json)

FieldTypeRequiredDescription
scanIdstringYesScan ID shared by all chunks of one scan
totalFindingsintegerYesTotal findings across all chunks (> 0, same on every chunk)
labelsobjectYesSource labels; must include policies.nirmata.io/source-id
findingsobject[]NoFindings in this chunk

Response 202 (application/json)

{status: 'accepted', scanId}

FieldTypeDescription
statusstringaccepted
scanIdstring—

Errors

  • 400 — scanId missing, totalFindings <= 0, labels missing, or source-id label missing
  • 401 — Tenant could not be resolved
  • 500 — Failed to queue chunk
  • 401 — Not authenticated
  • 403 — Caller’s role is not permitted for this operation

Example

{"scanId":"scan-123","totalFindings":2,"labels":{"policies.nirmata.io/source-id":"my-repo"},"findings":[{...},{...}]}

Count policy reports

GET /policies/api/v1/policy-reports/count

Returns the number of policy reports for the tenant.

Roles: admin

Response 200 (application/json)

{count}

FieldTypeDescription
countintegerNumber of policy reports

Errors

  • 500 — Count failed
  • 401 — Not authenticated
  • 403 — Caller’s role is not permitted for this operation

Get policy report summary

GET /policies/api/v1/policy-reports/summary

Returns the total number of policy reports and the sum of their policy violation counts.

Roles: Any role with permission for this resource. See Roles.

Response 200 (application/json)

{totalReports, totalViolations}

FieldTypeDescription
totalReportsintegerNumber of policy reports
totalViolationsintegerSum of policyViolationCount across reports

Errors

  • 500 — Summary failed
  • 401 — Not authenticated
  • 403 — Caller’s role is not permitted for this operation

Get a policy report

GET /policies/api/v1/policy-reports/{id}

Returns a single policy report by ID.

Roles: admin

Path parameters

NameTypeDescription
idstringPolicy report ID

Response 200 (application/json)

PolicyReportDto

FieldTypeDescription
idstringPolicy report ID
kindstringKubernetes kind (PolicyReport / ClusterPolicyReport)
apiVersionstringKubernetes API version
uidstringKubernetes UID of the report
namestringReport name
namespacestringNamespace (empty for cluster-scoped reports)
resourceVersionstringKubernetes resourceVersion
summaryByCategoryobjectResult counts grouped by policy category
gradestringLetter grade assigned to the report
policyViolationCountintegerNumber of policy violations
yamlstringRaw report YAML
clusterRefobject {id}Reference to the cluster the report came from
resultsarrayAlways null in this API
summaryobjectAlways null in this API
policyDetailsobjectAlways null in this API

Errors

  • 404 — Policy report not found
  • 500 — Lookup failed
  • 401 — Not authenticated
  • 403 — Caller’s role is not permitted for this operation

Get the active report run for a source

GET /policies/api/v1/report-results/active

Returns metadata for the currently active scan (report run) of the given source.

Roles: Any role with permission for this resource. See Roles.

Query parameters

NameTypeRequiredDefaultDescription
sourceIdstringYes—Source identifier

Response 200 (application/json)

ReportRun object

FieldTypeDescription
scanIdstringScan (report run) ID
tenantIdstring—
sourceIdstringSource the scan belongs to
sourceTypestring—
statusstringRun status (ACTIVE for this endpoint)
totalFindingsintegerExpected findings
receivedFindingsintegerFindings received so far
createdAtstring—
updatedAtstring—
finalizedAtstring—
archivedAtstring—
labelsobjectSource labels

Errors

  • 400 — sourceId missing
  • 401 — Tenant could not be resolved
  • 404 — No active scan for this source
  • 401 — Not authenticated
  • 403 — Caller’s role is not permitted for this operation

List findings for a source

GET /policies/api/v1/report-results/findings

Returns paginated findings from the active scan of a source, optionally filtered by result. Ordered by finding ID.

Roles: Any role with permission for this resource. See Roles.

Query parameters

NameTypeRequiredDefaultDescription
sourceIdstringYes—Source identifier
resultstringNo—Only return findings with this result (e.g. fail)
limitintegerNo500Page size
offsetintegerNo0Items to skip (>= 0)

Response 200 (application/json)

{total, count, offset, findings: Finding[]}

FieldTypeDescription
totalintegerTotal matching findings
countintegerFindings in this page
offsetinteger—
scanIdstring—
sourceIdstring—
resultstringFinding result, e.g. pass/fail
messagestring—
severitystring—
descriptionstring—
timestampstring—
targetobject {type,name,metadata}Scanned target
policyobject {name,rule,kind,apiGroup}Policy that produced the finding
categoryarray/objectCategories

Errors

  • 400 — sourceId missing or offset < 0
  • 401 — Tenant could not be resolved
  • 500 — Query failed
  • 401 — Not authenticated
  • 403 — Caller’s role is not permitted for this operation

Example

GET /policies/api/v1/report-results/findings?sourceId=my-cluster&result=fail&limit=100

List policy reports by cluster

GET /policies/api/v1/policy-reports/by-cluster/{clusterRef}

Returns all policy reports for the tenant whose cluster matches the given value. Not paginated; returns an empty array if none match.

Roles: Any role with permission for this resource. See Roles.

Path parameters

NameTypeDescription
clusterRefstringCluster ID

Response 200 (application/json)

PolicyReportDto[] (plain array)

FieldTypeDescription
idstringPolicy report ID
kindstringKubernetes kind (PolicyReport / ClusterPolicyReport)
apiVersionstringKubernetes API version
uidstringKubernetes UID of the report
namestringReport name
namespacestringNamespace (empty for cluster-scoped reports)
resourceVersionstringKubernetes resourceVersion
summaryByCategoryobjectResult counts grouped by policy category
gradestringLetter grade assigned to the report
policyViolationCountintegerNumber of policy violations
yamlstringRaw report YAML
clusterRefobject {id}Reference to the cluster the report came from
resultsarrayAlways null in this API
summaryobjectAlways null in this API
policyDetailsobjectAlways null in this API

Errors

  • 500 — Query failed
  • 401 — Not authenticated
  • 403 — Caller’s role is not permitted for this operation

List policy reports by grade

GET /policies/api/v1/policy-reports/by-grade/{grade}

Returns all policy reports for the tenant whose grade matches the given value. Not paginated; returns an empty array if none match.

Roles: Any role with permission for this resource. See Roles.

Path parameters

NameTypeDescription
gradestringGrade value (exact match, e.g. A-F)

Response 200 (application/json)

PolicyReportDto[] (plain array)

FieldTypeDescription
idstringPolicy report ID
kindstringKubernetes kind (PolicyReport / ClusterPolicyReport)
apiVersionstringKubernetes API version
uidstringKubernetes UID of the report
namestringReport name
namespacestringNamespace (empty for cluster-scoped reports)
resourceVersionstringKubernetes resourceVersion
summaryByCategoryobjectResult counts grouped by policy category
gradestringLetter grade assigned to the report
policyViolationCountintegerNumber of policy violations
yamlstringRaw report YAML
clusterRefobject {id}Reference to the cluster the report came from
resultsarrayAlways null in this API
summaryobjectAlways null in this API
policyDetailsobjectAlways null in this API

Errors

  • 500 — Query failed
  • 401 — Not authenticated
  • 403 — Caller’s role is not permitted for this operation

List policy reports by namespace

GET /policies/api/v1/policy-reports/by-namespace/{namespace}

Returns all policy reports for the tenant whose namespace matches the given value. Not paginated; returns an empty array if none match.

Roles: Any role with permission for this resource. See Roles.

Path parameters

NameTypeDescription
namespacestringNamespace name (exact match)

Response 200 (application/json)

PolicyReportDto[] (plain array)

FieldTypeDescription
idstringPolicy report ID
kindstringKubernetes kind (PolicyReport / ClusterPolicyReport)
apiVersionstringKubernetes API version
uidstringKubernetes UID of the report
namestringReport name
namespacestringNamespace (empty for cluster-scoped reports)
resourceVersionstringKubernetes resourceVersion
summaryByCategoryobjectResult counts grouped by policy category
gradestringLetter grade assigned to the report
policyViolationCountintegerNumber of policy violations
yamlstringRaw report YAML
clusterRefobject {id}Reference to the cluster the report came from
resultsarrayAlways null in this API
summaryobjectAlways null in this API
policyDetailsobjectAlways null in this API

Errors

  • 500 — Query failed
  • 401 — Not authenticated
  • 403 — Caller’s role is not permitted for this operation

List findings for a scan

GET /policies/api/v1/report-results/reports/{scanId}/findings

Returns paginated findings for a specific scan, optionally filtered by policy name. No total count is returned.

Roles: Any role with permission for this resource. See Roles.

Path parameters

NameTypeDescription
scanIdstringScan ID

Query parameters

NameTypeRequiredDefaultDescription
policyNamestringNo—Only return findings for this policy
limitintegerNo500Page size
offsetintegerNo0Items to skip (>= 0)

Response 200 (application/json)

{scanId, count, findings: Finding[]}

FieldTypeDescription
scanIdstring—
countinteger—
scanIdstring—
sourceIdstring—
resultstringFinding result, e.g. pass/fail
messagestring—
severitystring—
descriptionstring—
timestampstring—
targetobject {type,name,metadata}Scanned target
policyobject {name,rule,kind,apiGroup}Policy that produced the finding
categoryarray/objectCategories

Errors

  • 400 — offset < 0
  • 401 — Tenant could not be resolved
  • 500 — Query failed
  • 401 — Not authenticated
  • 403 — Caller’s role is not permitted for this operation