@codacy/tools-checkov-3 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -51
- package/dist/metadata.d.ts +13 -0
- package/dist/metadata.js +39 -0
- package/package.json +13 -3
package/dist/index.js
CHANGED
|
@@ -10908,6 +10908,18 @@ var patterns_default = [
|
|
|
10908
10908
|
}
|
|
10909
10909
|
];
|
|
10910
10910
|
|
|
10911
|
+
// src/metadata.ts
|
|
10912
|
+
var descriptor = {
|
|
10913
|
+
id: "Checkov",
|
|
10914
|
+
displayName: "Checkov",
|
|
10915
|
+
preferredVersion: "3.2.508",
|
|
10916
|
+
languages: ["JSON", "YAML", "Terraform"],
|
|
10917
|
+
filePatterns: ["**/*.tf", "**/*.yaml", "**/*.yml", "**/*.json", "**/Dockerfile"],
|
|
10918
|
+
supportedOS: ["linux", "darwin"],
|
|
10919
|
+
supportedArch: ["x64", "arm64"],
|
|
10920
|
+
supportedRunners: ["local", "container"]
|
|
10921
|
+
};
|
|
10922
|
+
|
|
10911
10923
|
// src/adapter.ts
|
|
10912
10924
|
var TOOL_ID = "Checkov";
|
|
10913
10925
|
var PATTERN_META = new Map(
|
|
@@ -10922,37 +10934,6 @@ var PATTERN_META = new Map(
|
|
|
10922
10934
|
function ruleMetadata(patternId) {
|
|
10923
10935
|
return PATTERN_META.get(patternId) ?? { category: "Security", severity: "Warning" };
|
|
10924
10936
|
}
|
|
10925
|
-
function getLineContent(lines, lineNumber) {
|
|
10926
|
-
return lines[lineNumber - 1] ?? "";
|
|
10927
|
-
}
|
|
10928
|
-
async function readFileLines(filePath) {
|
|
10929
|
-
try {
|
|
10930
|
-
const content = await import_promises.default.readFile(filePath, "utf-8");
|
|
10931
|
-
return content.split("\n");
|
|
10932
|
-
} catch {
|
|
10933
|
-
return [];
|
|
10934
|
-
}
|
|
10935
|
-
}
|
|
10936
|
-
function buildResult(startedAt, completedAt, issues, errors, filesAnalyzed) {
|
|
10937
|
-
const durationMs = completedAt.getTime() - startedAt.getTime();
|
|
10938
|
-
return {
|
|
10939
|
-
metadata: {
|
|
10940
|
-
startedAt: startedAt.toISOString(),
|
|
10941
|
-
completedAt: completedAt.toISOString(),
|
|
10942
|
-
durationMs
|
|
10943
|
-
},
|
|
10944
|
-
issues,
|
|
10945
|
-
errors,
|
|
10946
|
-
summary: {
|
|
10947
|
-
toolId: TOOL_ID,
|
|
10948
|
-
status: errors.some((e) => e.level === "error") ? "partial" : "success",
|
|
10949
|
-
issueCount: issues.length,
|
|
10950
|
-
errorCount: errors.length,
|
|
10951
|
-
durationMs,
|
|
10952
|
-
filesAnalyzed
|
|
10953
|
-
}
|
|
10954
|
-
};
|
|
10955
|
-
}
|
|
10956
10937
|
var CONFIG_FILE_CANDIDATES = [".checkov.yaml", ".checkov.yml"];
|
|
10957
10938
|
var PIP_PACKAGE = "checkov==3.2.508";
|
|
10958
10939
|
var BINARY = "checkov";
|
|
@@ -10985,16 +10966,9 @@ function stripLeadingSlash(filePath) {
|
|
|
10985
10966
|
return filePath.replace(/^\//, "");
|
|
10986
10967
|
}
|
|
10987
10968
|
var adapter = {
|
|
10988
|
-
|
|
10989
|
-
displayName: "Checkov",
|
|
10990
|
-
preferredVersion: "3.2.508",
|
|
10969
|
+
...descriptor,
|
|
10991
10970
|
compatibleVersions: ">=3.0.0",
|
|
10992
10971
|
website: "https://www.checkov.io/",
|
|
10993
|
-
languages: ["JSON", "YAML", "Terraform"],
|
|
10994
|
-
filePatterns: ["**/*.tf", "**/*.yaml", "**/*.yml", "**/*.json", "**/Dockerfile"],
|
|
10995
|
-
supportedOS: ["linux", "darwin"],
|
|
10996
|
-
supportedArch: ["x64", "arm64"],
|
|
10997
|
-
supportedRunners: ["local", "container"],
|
|
10998
10972
|
prerequisites: [
|
|
10999
10973
|
{
|
|
11000
10974
|
name: "Python",
|
|
@@ -11177,7 +11151,7 @@ var adapter = {
|
|
|
11177
11151
|
const issues = [];
|
|
11178
11152
|
const errors = [];
|
|
11179
11153
|
if (ctx.targetFiles.length === 0) {
|
|
11180
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
|
|
11154
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
|
|
11181
11155
|
}
|
|
11182
11156
|
let binary;
|
|
11183
11157
|
try {
|
|
@@ -11189,11 +11163,6 @@ var adapter = {
|
|
|
11189
11163
|
const useLocal = codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile;
|
|
11190
11164
|
if (useLocal) {
|
|
11191
11165
|
args.push("--config-file", codacyConfig.localConfigurationFile);
|
|
11192
|
-
} else if (codacyConfig.patterns.length === 0) {
|
|
11193
|
-
ctx.logger.info("Skipping analysis: no local config and no patterns enabled", {
|
|
11194
|
-
toolId: TOOL_ID
|
|
11195
|
-
});
|
|
11196
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
11197
11166
|
}
|
|
11198
11167
|
for (const file of ctx.targetFiles) {
|
|
11199
11168
|
args.push("-f", import_path.default.resolve(ctx.repositoryRoot, file));
|
|
@@ -11213,10 +11182,10 @@ var adapter = {
|
|
|
11213
11182
|
message: `checkov exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
|
|
11214
11183
|
level: "error"
|
|
11215
11184
|
});
|
|
11216
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
11185
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
11217
11186
|
}
|
|
11218
11187
|
if (!stdout.trim()) {
|
|
11219
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
11188
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
11220
11189
|
}
|
|
11221
11190
|
let parsed;
|
|
11222
11191
|
try {
|
|
@@ -11229,7 +11198,7 @@ var adapter = {
|
|
|
11229
11198
|
message: `Failed to parse checkov JSON output: ${err instanceof Error ? err.message : String(err)}`,
|
|
11230
11199
|
level: "error"
|
|
11231
11200
|
});
|
|
11232
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
11201
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
11233
11202
|
}
|
|
11234
11203
|
const frameworks = Array.isArray(parsed) ? parsed : [parsed];
|
|
11235
11204
|
const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
|
|
@@ -11260,7 +11229,7 @@ var adapter = {
|
|
|
11260
11229
|
continue;
|
|
11261
11230
|
}
|
|
11262
11231
|
if (!linesCache.has(relPath)) {
|
|
11263
|
-
linesCache.set(relPath, await readFileLines(import_path.default.join(ctx.repositoryRoot, relPath)));
|
|
11232
|
+
linesCache.set(relPath, await (0, import_tooling.readFileLines)(import_path.default.join(ctx.repositoryRoot, relPath)));
|
|
11264
11233
|
}
|
|
11265
11234
|
const lines = linesCache.get(relPath);
|
|
11266
11235
|
const lineStart = Math.max(check.file_line_range[0], 1);
|
|
@@ -11274,7 +11243,7 @@ var adapter = {
|
|
|
11274
11243
|
column: 1,
|
|
11275
11244
|
endLine: lineEnd,
|
|
11276
11245
|
message: check.check_name,
|
|
11277
|
-
lineContent: getLineContent(lines, lineStart),
|
|
11246
|
+
lineContent: (0, import_tooling.getLineContent)(lines, lineStart),
|
|
11278
11247
|
multilineContent: (0, import_tooling.getMultilineContent)(lines, lineStart, lineEnd),
|
|
11279
11248
|
category: meta.category,
|
|
11280
11249
|
severity: meta.severity
|
|
@@ -11310,7 +11279,7 @@ var adapter = {
|
|
|
11310
11279
|
errorCount: errors.length,
|
|
11311
11280
|
durationMs
|
|
11312
11281
|
});
|
|
11313
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
11282
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
11314
11283
|
}
|
|
11315
11284
|
};
|
|
11316
11285
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdapterDescriptor } from '@codacy/tooling';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Lightweight adapter descriptor for lazy loading.
|
|
5
|
+
*
|
|
6
|
+
* This module contains only plain-data metadata fields and has zero heavy
|
|
7
|
+
* imports (no patterns.json, no runtime utilities). The CLI imports this
|
|
8
|
+
* at startup for adapter registration without loading the full adapter module.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare const descriptor: AdapterDescriptor;
|
|
12
|
+
|
|
13
|
+
export { descriptor };
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/metadata.ts
|
|
21
|
+
var metadata_exports = {};
|
|
22
|
+
__export(metadata_exports, {
|
|
23
|
+
descriptor: () => descriptor
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(metadata_exports);
|
|
26
|
+
var descriptor = {
|
|
27
|
+
id: "Checkov",
|
|
28
|
+
displayName: "Checkov",
|
|
29
|
+
preferredVersion: "3.2.508",
|
|
30
|
+
languages: ["JSON", "YAML", "Terraform"],
|
|
31
|
+
filePatterns: ["**/*.tf", "**/*.yaml", "**/*.yml", "**/*.json", "**/Dockerfile"],
|
|
32
|
+
supportedOS: ["linux", "darwin"],
|
|
33
|
+
supportedArch: ["x64", "arm64"],
|
|
34
|
+
supportedRunners: ["local", "container"]
|
|
35
|
+
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
descriptor
|
|
39
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codacy/tools-checkov-3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Checkov adapter — CLI-mode IaC security scanner",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@codacy/tooling": "0.
|
|
11
|
+
"@codacy/tooling": "0.5.0"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "Codacy <support@codacy.com> (https://www.codacy.com)",
|
|
@@ -21,8 +21,18 @@
|
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20.0.0"
|
|
23
23
|
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./metadata": {
|
|
30
|
+
"types": "./dist/metadata.d.ts",
|
|
31
|
+
"default": "./dist/metadata.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
24
34
|
"scripts": {
|
|
25
|
-
"build": "tsup src/index.ts --format cjs --dts --clean",
|
|
35
|
+
"build": "tsup src/index.ts src/metadata.ts --format cjs --dts --clean",
|
|
26
36
|
"test": "vitest run",
|
|
27
37
|
"lint": "eslint src/",
|
|
28
38
|
"clean": "rm -rf dist",
|