@codacy/tools-hadolint-2 0.14.0 → 0.15.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 +63 -43
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1000,7 +1000,10 @@ var PLATFORM_MAP = {
|
|
|
1000
1000
|
"darwin-arm64": "macos-arm64",
|
|
1001
1001
|
"darwin-x64": "macos-x86_64",
|
|
1002
1002
|
"linux-x64": "linux-x86_64",
|
|
1003
|
-
"linux-arm64": "linux-arm64"
|
|
1003
|
+
"linux-arm64": "linux-arm64",
|
|
1004
|
+
// Windows ships a raw `.exe` (hadolint-Windows-x86_64.exe) — the `.exe`
|
|
1005
|
+
// suffix is added at the download/resolve sites via exeName.
|
|
1006
|
+
"win32-x64": "Windows-x86_64"
|
|
1004
1007
|
};
|
|
1005
1008
|
async function getVersionFromBinary(binaryPath) {
|
|
1006
1009
|
try {
|
|
@@ -1015,7 +1018,7 @@ async function getVersionFromBinary(binaryPath) {
|
|
|
1015
1018
|
}
|
|
1016
1019
|
}
|
|
1017
1020
|
async function resolveBinaryPath(ctx) {
|
|
1018
|
-
const codacyBin = import_path.default.join(ctx.toolInstallDir, BINARY);
|
|
1021
|
+
const codacyBin = import_path.default.join(ctx.toolInstallDir, (0, import_tooling.exeName)(BINARY));
|
|
1019
1022
|
const version = await getVersionFromBinary(codacyBin);
|
|
1020
1023
|
if (version) return codacyBin;
|
|
1021
1024
|
return BINARY;
|
|
@@ -1096,12 +1099,13 @@ var adapter = {
|
|
|
1096
1099
|
};
|
|
1097
1100
|
}
|
|
1098
1101
|
const version = adapter.preferredVersion;
|
|
1099
|
-
const
|
|
1100
|
-
const
|
|
1102
|
+
const assetExt = import_tooling.IS_WINDOWS ? ".exe" : "";
|
|
1103
|
+
const url = `https://github.com/hadolint/hadolint/releases/download/v${version}/hadolint-${platformSuffix}${assetExt}`;
|
|
1104
|
+
const destPath = import_path.default.join(ctx.toolInstallDir, (0, import_tooling.exeName)(BINARY));
|
|
1101
1105
|
try {
|
|
1102
1106
|
ctx.logger.info(`Downloading hadolint v${version} for ${platformKey}...`);
|
|
1103
1107
|
await (0, import_tooling.downloadFile)(url, destPath, ctx.logger);
|
|
1104
|
-
await import_promises.default.chmod(destPath, 493);
|
|
1108
|
+
if (!import_tooling.IS_WINDOWS) await import_promises.default.chmod(destPath, 493);
|
|
1105
1109
|
ctx.logger.info(`Installed hadolint v${version} to ${destPath}`);
|
|
1106
1110
|
return { success: true, installedPath: destPath, installedVersion: version };
|
|
1107
1111
|
} catch (err) {
|
|
@@ -1192,37 +1196,62 @@ var adapter = {
|
|
|
1192
1196
|
args.push(flag, code);
|
|
1193
1197
|
}
|
|
1194
1198
|
}
|
|
1195
|
-
|
|
1199
|
+
const fileChunks = (0, import_tooling.chunkFilesForArgv)(absoluteFiles);
|
|
1196
1200
|
try {
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
errors.push({
|
|
1203
|
-
toolId: TOOL_ID,
|
|
1204
|
-
phase: "toolInvoke",
|
|
1205
|
-
kind: "NonZeroExit",
|
|
1206
|
-
message: `hadolint exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
|
|
1207
|
-
level: "error"
|
|
1201
|
+
const findings = [];
|
|
1202
|
+
for (const chunk of fileChunks) {
|
|
1203
|
+
const { stdout, stderr, exitCode } = await (0, import_tooling.spawnTool)(binary, [...args, ...chunk], {
|
|
1204
|
+
cwd: ctx.repositoryRoot,
|
|
1205
|
+
logger: ctx.logger
|
|
1208
1206
|
});
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1207
|
+
if (exitCode >= 2) {
|
|
1208
|
+
errors.push({
|
|
1209
|
+
toolId: TOOL_ID,
|
|
1210
|
+
phase: "toolInvoke",
|
|
1211
|
+
kind: "NonZeroExit",
|
|
1212
|
+
message: `hadolint exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
|
|
1213
|
+
level: "error"
|
|
1214
|
+
});
|
|
1215
|
+
return (0, import_tooling.buildResult)(
|
|
1216
|
+
TOOL_ID,
|
|
1217
|
+
startedAt,
|
|
1218
|
+
/* @__PURE__ */ new Date(),
|
|
1219
|
+
issues,
|
|
1220
|
+
errors,
|
|
1221
|
+
ctx.targetFiles.length
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1224
|
+
if (stderr.trim()) {
|
|
1225
|
+
errors.push({
|
|
1226
|
+
toolId: TOOL_ID,
|
|
1227
|
+
phase: "outputParse",
|
|
1228
|
+
kind: "ParseWarning",
|
|
1229
|
+
message: `hadolint stderr: ${stderr.trim()}`,
|
|
1230
|
+
level: "warning"
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
if (!stdout.trim()) continue;
|
|
1234
|
+
let chunkFindings;
|
|
1235
|
+
try {
|
|
1236
|
+
chunkFindings = JSON.parse(stdout);
|
|
1237
|
+
} catch (err) {
|
|
1238
|
+
errors.push({
|
|
1239
|
+
toolId: TOOL_ID,
|
|
1240
|
+
phase: "outputParse",
|
|
1241
|
+
kind: "MalformedOutput",
|
|
1242
|
+
message: `Failed to parse hadolint JSON output: ${err instanceof Error ? err.message : String(err)}`,
|
|
1243
|
+
level: "error"
|
|
1244
|
+
});
|
|
1245
|
+
return (0, import_tooling.buildResult)(
|
|
1246
|
+
TOOL_ID,
|
|
1247
|
+
startedAt,
|
|
1248
|
+
/* @__PURE__ */ new Date(),
|
|
1249
|
+
issues,
|
|
1250
|
+
errors,
|
|
1251
|
+
ctx.targetFiles.length
|
|
1252
|
+
);
|
|
1253
|
+
}
|
|
1254
|
+
findings.push(...chunkFindings);
|
|
1226
1255
|
}
|
|
1227
1256
|
const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
|
|
1228
1257
|
const findingsByFile = /* @__PURE__ */ new Map();
|
|
@@ -1258,15 +1287,6 @@ var adapter = {
|
|
|
1258
1287
|
});
|
|
1259
1288
|
}
|
|
1260
1289
|
}
|
|
1261
|
-
if (stderr.trim()) {
|
|
1262
|
-
errors.push({
|
|
1263
|
-
toolId: TOOL_ID,
|
|
1264
|
-
phase: "outputParse",
|
|
1265
|
-
kind: "ParseWarning",
|
|
1266
|
-
message: `hadolint stderr: ${stderr.trim()}`,
|
|
1267
|
-
level: "warning"
|
|
1268
|
-
});
|
|
1269
|
-
}
|
|
1270
1290
|
} catch (err) {
|
|
1271
1291
|
errors.push({
|
|
1272
1292
|
toolId: TOOL_ID,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codacy/tools-hadolint-2",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Hadolint adapter — CLI-mode Dockerfile linter",
|
|
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.15.0"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "Codacy <support@codacy.com> (https://www.codacy.com)",
|