@codacy/tools-checkov-3
v0.21.0
Published
Checkov adapter — CLI-mode IaC security scanner
Readme
@codacy/tools-checkov-3
Table of Contents
Overview
Infrastructure-as-Code security scanner using the Checkov binary. Scans Terraform, CloudFormation, Kubernetes, Dockerfile, and many other IaC frameworks for security misconfigurations. Uses the CLI execution strategy with Python/pip installation into an isolated virtual environment.
| Property | Value |
| ----------------- | ---------------------------------------------------------------- |
| Tool ID | Checkov |
| Codacy UUID | 13af9d89-1ce5-4fec-a168-765c3e7b26b3 |
| Strategy | CLI |
| Languages | JSON, YAML, Terraform, Dockerfile |
| Binary | checkov (Python package) |
| File patterns | **/*.tf, **/*.yaml, **/*.yml, **/*.json, **/Dockerfile |
| Pattern count | ~1,358 |
| Pattern ID format | Checkov_{check_id} (e.g. Checkov_CKV_AWS_41) |
Updating patterns
# Re-fetch pattern metadata from the Codacy API
pnpm prefetch
# Commit the result
git add src/patterns.jsonUpdating the Checkov version
- Update
preferredVersioninsrc/adapter.ts - Update the
PIP_PACKAGEconstant insrc/adapter.ts(e.g.checkov==3.2.510) - Run
pnpm prefetchto refresh patterns (new versions may add checks) - Run
pnpm testto verify compatibility - Consider creating a new package (
checkov-4/) if the major version changes
Development
# Install checkov locally (requires Python 3.9+)
pip install checkov==3.2.508
# Build with tsup
pnpm build
# Run tests (skips binary-dependent tests if checkov is not installed)
pnpm testNotes for maintainers
Large pip install: Checkov has ~200 transitive dependencies (pydantic, boto3 stubs, networkx, etc.). First install into the venv can take several minutes. Subsequent runs use the cached venv.
Per-tool venv isolation: The adapter installs Checkov into
~/.codacy/runtimes/Checkov/venv/to avoid dependency conflicts with other Python-based tools.Multi-framework JSON output: Checkov can emit a single JSON object or an array of objects (one per framework). The adapter normalizes both to an array before parsing.
Path normalization:
repo_file_pathfrom Checkov always has a leading/which must be stripped.No column information: Checkov does not provide column numbers. All issues use
column: 1.Exit codes: Exit code 0 = no issues, 1 = issues found (normal), >1 = genuine error.
Container mode network blocking: In container mode (
ctx.runner === "container"), the adapter sets proxy env vars andRENDER_EDGES_DUPLICATE_ITER_COUNT=50to block Bridgecrew API calls and tune performance.Pattern filtering: Uses
--check CKV_xxx,CKV_yyy,...to run only specific checks. TheCheckov_prefix is stripped from pattern IDs to get the raw check ID.Config files: Looks for
.checkov.yamlor.checkov.yml. When local config is active, passes--config-file <path>.Parsing errors: Checkov reports
parsing_errorsin its JSON output, which are surfaced asAnalysisErrorobjects withkind: "ParsingError".Preset mappings (
src/pattern-mappings.json): gates 1,278 of the 1,358 patterns on a detected IaC framework, soinit --autodoesn't enable AWS resource policy in a repo with no infrastructure. Measured effect: a repo with only apackage.jsonwent from 1,225 enabled Checkov patterns to 80.The gate is per IaC framework, not per cloud, because a cloud resource can be declared several ways — the same bucket is an
aws_s3_bucketin Terraform, anAWS::S3::Bucketin CloudFormation and aresources:block under Serverless.filterAutoPatternsenables a framework pattern when any of its keys was detected, so the same prefix is listed under several keys to mean "AWS resources, however they are declared". That OR is what makes gating safe here; an earlier revision left all ~1,091 cloud-provider checks universal precisely because gating them on.tfalone would have dropped every cloud check for a CloudFormation-only repo."lang:Terraform"mapsCKV_TF_plus every cloud-provider family (CKV_AWS_,CKV_AZURE_,CKV_GCP_, and the 10 smaller clouds). No file signal is needed:.tfis theTerraformlanguage, solang:Terraformalready means "this repo has Terraform".cloudformationandserverless-frameworkalso claimCKV_AWS_/CKV2_AWS_;bicepalso claimsCKV_AZURE_/CKV2_AZURE_. Detected by file signal (samconfig.*, a roottemplate.yaml, acloudformation/directory,serverless.yml,*.bicep).kubernetesandhelmboth claimCKV_K8S_/CKV2_K8S_/CKV_ARGO_— a chart's templates render to manifests, so either is evidence. Detected fromkustomization.yaml/Chart.yaml.ansibleclaimsCKV_ANSIBLE_/CKV2_ANSIBLE_, fromansible.cfgor theroles/<name>/tasks/main.ymllayout.- Still universal (80 patterns), each for a stated reason:
CKV_SECRET_(18) andCKV_BCW_(1) by design — secret scanning must not be suppressed by any framework gate.CKV_OPENAPI_(21) — an OpenAPI/AsyncAPI document identifies itself by itsopenapi:/swagger:key, which a path-only signal cannot see. Needs the content probe.- The VCS governance families
CKV_GITHUB_(26),CKV_GIT_(7),CKV_GLB_(4),CKV_GITLAB_,CKV_BITBUCKET_,CKV2_ADO_(1 each). These are unresolved, not deferred: their titles read as platform/API settings (Checkov'sgithub_configurationframework, which reads API data and cannot fire on a filesystem scan), while an earlier reading of this file recorded them as governance resources managed through each platform's Terraform provider — in which case they belong underlang:Terraform. The two readings imply opposite fixes (prune vs. gate), so they are left untouched until checked against Checkov's own framework declarations.
- Known gap: a bare Kubernetes manifest (
k8s/deployment.yaml) or a bare CloudFormation template is still not detected — only the conventional shells around them are. Both declare themselves in their content, so closing this needs a bounded content probe (apiVersion:,AWSTemplateFormatVersion), which is not implemented. - Known gap (upstream): most patterns carry
languages: ["JSON", "YAML", "Terraform"], which is the tool-level fallback Codacy's API returns for a pattern with no per-pattern languages — not a claim about the check. It over-declares (JSON is why Checkov is selected almost everywhere) and under-declares (only 6 of 28CKV_DOCKER_checks listDockerfile, so 22 are dropped by the language filter in a Dockerfile-only repo). The durable fix is in the cloud tool definition; seetodo-checkov-languages.md.
