Skip to content

Commit 1bceffd

Browse files
committed
Enhance Kubescape tool by adding runtime observability features
- Introduced checks for ApplicationProfiles and NetworkNeighborhoods CRDs in health checks, with corresponding recommendations for enabling runtime observability. - Added handlers for listing and retrieving ApplicationProfiles and NetworkNeighborhoods, capturing runtime behavior and network communication patterns of workloads. Signed-off-by: Ben <[email protected]>
1 parent 781eb91 commit 1bceffd

File tree

3 files changed

+1121
-7
lines changed

3 files changed

+1121
-7
lines changed

internal/errors/tool_errors.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ func NewKubescapeError(operation string, cause error) *ToolError {
307307
// Determine which capability might be missing based on the operation
308308
suggestions := []string{
309309
"Check if the Kubescape operator is installed in the cluster",
310-
"Verify the manifest name and namespace",
310+
"Verify the resource name and namespace",
311311
}
312-
if strings.Contains(operation, "vulnerabilit") {
312+
if strings.Contains(operation, "vulnerabilit") || strings.Contains(operation, "sbom") {
313313
suggestions = append(suggestions,
314314
"Ensure vulnerability scanning is enabled in the Kubescape Helm chart",
315315
"Enable with: helm upgrade kubescape kubescape/kubescape-operator -n kubescape --set capabilities.vulnerabilityScan=enable",
@@ -321,11 +321,23 @@ func NewKubescapeError(operation string, cause error) *ToolError {
321321
"Enable with: helm upgrade kubescape kubescape/kubescape-operator -n kubescape --set capabilities.continuousScan=enable",
322322
"Use 'kubectl get workloadconfigurationscans -A' to list available scans",
323323
)
324+
} else if strings.Contains(operation, "application_profile") || strings.Contains(operation, "network_neighborhood") {
325+
suggestions = append(suggestions,
326+
"Ensure runtime observability is enabled in the Kubescape Helm chart",
327+
"Enable with: helm upgrade kubescape kubescape/kubescape-operator -n kubescape --set capabilities.runtimeObservability=enable",
328+
"Runtime data collection requires time - allow workloads to run before profiles are available",
329+
)
330+
if strings.Contains(operation, "application_profile") {
331+
suggestions = append(suggestions, "Use 'kubectl get applicationprofiles -A' to list available profiles")
332+
} else {
333+
suggestions = append(suggestions, "Use 'kubectl get networkneighborhoods -A' to list available network data")
334+
}
324335
} else {
325336
suggestions = append(suggestions,
326337
"Ensure the required scanning capabilities are enabled in the Kubescape Helm chart",
327338
"For vulnerability scanning: --set capabilities.vulnerabilityScan=enable",
328339
"For configuration scanning: --set capabilities.continuousScan=enable",
340+
"For runtime observability: --set capabilities.runtimeObservability=enable",
329341
)
330342
}
331343
err = err.WithSuggestions(suggestions...).WithRetryable(false).WithErrorCode("KUBESCAPE_RESOURCE_NOT_FOUND")
@@ -338,17 +350,19 @@ func NewKubescapeError(operation string, cause error) *ToolError {
338350
} else if strings.Contains(causeStr, "forbidden") {
339351
err = err.WithSuggestions(
340352
"Check your RBAC permissions for Kubescape CRDs",
341-
"Verify your service account has read access to VulnerabilityManifests and WorkloadConfigurationScans",
353+
"Verify your service account has read access to Kubescape storage CRDs",
354+
"Required CRDs: VulnerabilityManifests, WorkloadConfigurationScans, ApplicationProfiles, NetworkNeighborhoods, SBOMSyfts",
342355
"Contact your cluster administrator",
343356
).WithRetryable(false).WithErrorCode("KUBESCAPE_PERMISSION_ERROR")
344357
} else {
345358
err = err.WithSuggestions(
346359
"Check Kubescape operator status: kubectl get pods -n kubescape",
347360
"Verify kubeconfig is valid",
348361
"Check if CRDs are installed: kubectl get crd vulnerabilitymanifests.spdx.softwarecomposition.kubescape.io",
349-
"Ensure scanning capabilities are enabled in the Helm chart",
350-
"For vulnerability scanning: --set capabilities.vulnerabilityScan=enable",
351-
"For configuration scanning: --set capabilities.continuousScan=enable",
362+
"Ensure scanning capabilities are enabled in the Helm chart:",
363+
" - Vulnerability scanning: --set capabilities.vulnerabilityScan=enable",
364+
" - Configuration scanning: --set capabilities.continuousScan=enable",
365+
" - Runtime observability: --set capabilities.runtimeObservability=enable",
352366
).WithRetryable(true).WithErrorCode("KUBESCAPE_GENERIC_ERROR")
353367
}
354368

0 commit comments

Comments
 (0)