Skip to content

Kubescape Executor

Category: IaC, Containers and Kubernetes Script: kubescape.py Integration: CLI Faraday Plugin: KubescapePlugin Website: https://kubescape.io/

Description

Runs a Kubescape posture scan against a Kubernetes cluster or local manifest files and imports the failed controls into Faraday. You can scan with all frameworks, a single framework, or a single control.

Prerequisites

  • kubescape installed and available in the agent's PATH (checked with kubescape version)
  • To scan a live cluster: a kubeconfig file readable by the agent, with permission to read the cluster's resources
  • To scan manifests: the YAML files readable by the agent (for Docker deployments, mount them into the container)

Configuration

Environment Variables (Setup)

This executor does not require setup environment variables.

Execution Arguments

Parameter Type Mandatory Description
KUBESCAPE_SCAN_TARGET string No What to scan: cluster (all default frameworks), framework (the framework in KUBESCAPE_FRAMEWORK) or control (the control in KUBESCAPE_CONTROL_ID). Default: cluster.
KUBESCAPE_FRAMEWORK string No Framework to use when KUBESCAPE_SCAN_TARGET is framework, e.g. nsa, mitre, cis, armobest, devopsbest, soc2 (default: nsa)
KUBESCAPE_CONTROL_ID string No Control to run when KUBESCAPE_SCAN_TARGET is control (e.g., C-0001). Required in that mode.
KUBESCAPE_KUBECONFIG string No Path to the kubeconfig file used to reach the cluster (e.g., /root/.kube/config). By default Kubescape uses its standard kubeconfig lookup.
KUBESCAPE_MANIFEST_PATH string No Path to a YAML file or directory to scan instead of the live cluster (e.g., /manifests/)

YAML Configuration Example

executors:
  kubescape:
    repo_executor: kubescape.py
    max_size: 65536
    varenvs: {}
    params:
      KUBESCAPE_SCAN_TARGET:
        mandatory: false
        type: string
        base: string
      KUBESCAPE_FRAMEWORK:
        mandatory: false
        type: string
        base: string
      KUBESCAPE_CONTROL_ID:
        mandatory: false
        type: string
        base: string
      KUBESCAPE_KUBECONFIG:
        mandatory: false
        type: string
        base: string
      KUBESCAPE_MANIFEST_PATH:
        mandatory: false
        type: string
        base: string

How It Works

  1. Builds a kubescape scan command for the selected target: the whole cluster, framework <name> or control <id>
  2. Adds KUBESCAPE_MANIFEST_PATH as the scan input when it is set, and --kubeconfig when KUBESCAPE_KUBECONFIG is set
  3. Runs the scan with JSON output to a temporary file
  4. Parses the report with KubescapePlugin and sends the results to Faraday

Notes

  • An invalid KUBESCAPE_SCAN_TARGET, or control without KUBESCAPE_CONTROL_ID, stops the run.
  • KUBESCAPE_FRAMEWORK is ignored unless KUBESCAPE_SCAN_TARGET is framework.
  • The run fails if Kubescape does not write a report.
  • Supports the shared agent parameters (AGENT_CONFIG_* tags and severity filters).