@codacy/tools-checkov-3

中文文档
0.28.0发布于 2026/11/09MITTypeScriptCommonJS近 30 天下载 1.2万

Checkov adapter — CLI-mode IaC security scanner

原始使用文档
文档目录6 节
  1. Table of Contents
  2. Overview
  3. Updating patterns
  4. Updating the Checkov version
  5. Development
  6. Notes for maintainers

@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.

PropertyValue
Tool IDCheckov
Codacy UUID13af9d89-1ce5-4fec-a168-765c3e7b26b3
StrategyCLI
LanguagesJSON, YAML, Terraform, Dockerfile
Binarycheckov (Python package)
File patterns**/*.tf, **/*.yaml, **/*.yml, **/*.json, **/Dockerfile
Pattern count~1,359
Pattern ID formatCheckov_{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.json

Updating the Checkov version

  1. Update preferredVersion in src/adapter.ts
  2. Update the PIP_PACKAGE constant in src/adapter.ts (e.g. checkov==3.2.510)
  3. Run pnpm prefetch to refresh patterns (new versions may add checks)
  4. Run pnpm test to verify compatibility
  5. Consider creating a new package (checkov-4/) if the major version changes

Development

# Install checkov locally (requires Python 3.9+)
pip install checkov==3.3.19

# Build with tsup
pnpm build

# Run tests (skips binary-dependent tests if checkov is not installed)
pnpm test

Notes 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_path from 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 and RENDER_EDGES_DUPLICATE_ITER_COUNT=50 to block Bridgecrew API calls and tune performance.

  • Pattern filtering: Uses --check CKV_xxx,CKV_yyy,... to run only specific checks. The Checkov_ prefix is stripped from pattern IDs to get the raw check ID.

  • Config files: Looks for .checkov.yaml or .checkov.yml. When local config is active, passes --config-file <path>.

  • Parsing errors: Checkov reports parsing_errors in its JSON output, which are surfaced as AnalysisError objects with kind: "ParsingError".

  • Preset mappings (src/pattern-mappings.json): gates 1,280 of the 1,360 patterns on a detected IaC framework, so init --auto doesn't enable AWS resource policy in a repo with no infrastructure. Measured effect: a repo with only a package.json went 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_bucket in Terraform, an AWS::S3::Bucket in CloudFormation and a resources: block under Serverless. filterAutoPatterns enables 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 .tf alone would have dropped every cloud check for a CloudFormation-only repo.

    • "lang:Terraform" maps CKV_TF_ plus every cloud-provider family (CKV_AWS_, CKV_AZURE_, CKV_GCP_, and the 10 smaller clouds). No file signal is needed: .tf is the Terraform language, so lang:Terraform already means "this repo has Terraform".
    • cloudformation and serverless-framework also claim CKV_AWS_/CKV2_AWS_; bicep also claims CKV_AZURE_/CKV2_AZURE_. Detected by file signal (samconfig.*, a root template.yaml, a cloudformation/ directory, serverless.yml, *.bicep).
    • kubernetes and helm both claim CKV_K8S_/CKV2_K8S_/CKV_ARGO_ — a chart's templates render to manifests, so either is evidence. Detected from kustomization.yaml / Chart.yaml.
    • ansible claims CKV_ANSIBLE_/CKV2_ANSIBLE_, from ansible.cfg or the roles/<name>/tasks/main.yml layout.
    • Still universal (80 patterns), each for a stated reason:
      • CKV_SECRET_ (18) and CKV_BCW_ (1) by design — secret scanning must not be suppressed by any framework gate.
      • CKV_OPENAPI_ (21) — an OpenAPI/AsyncAPI document identifies itself by its openapi:/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's github_configuration framework, 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 under lang: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 28 CKV_DOCKER_ checks list Dockerfile, so 22 are dropped by the language filter in a Dockerfile-only repo). The durable fix is in the cloud tool definition; see todo-checkov-languages.md.

版本与发布记录

@codacy/tools-checkov-3 共发布 36 个版本,首次发布于 2026/03/24;过去 12 个月发布了 36 个版本。

版本发布日期距今
0.28.0latest2026/11/09今天
0.27.12026/11/054 天前
0.27.02026/11/036 天前
0.26.02026/10/3010 天前
0.25.02026/10/1921 天前
0.24.02026/09/251 个月前

关于 @codacy/tools-checkov-3 的常见问题

@codacy/tools-checkov-3 是什么?

Checkov adapter — CLI-mode IaC security scanner

如何安装 @codacy/tools-checkov-3?

在项目目录运行 npm install @codacy/tools-checkov-3,或使用 pnpm add / yarn add / bun add。

@codacy/tools-checkov-3 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@codacy/tools-checkov-3 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@codacy/tools-checkov-3 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@codacy/tools-checkov-3 可以商用吗?

@codacy/tools-checkov-3 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codacy/tools-checkov-3 的下载量有多少?

根据 npm 官方下载统计,@codacy/tools-checkov-3 在 2026/10/10 – 2026/11/08 这 30 天内被下载 11,960 次,日均约 399 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codacy/tools-checkov-3 还在维护吗?

最新版本 0.28.0 发布于 2026/11/09(今天);至今共发布 36 个版本,其中过去 12 个月发布了 36 个;首次发布于 2026/03/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。