@codacy/tools-bandit-1 0.13.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 +67 -57
- package/dist/metadata.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -753,7 +753,7 @@ var descriptor = {
|
|
|
753
753
|
preferredVersion: "1.8.3",
|
|
754
754
|
languages: ["Python"],
|
|
755
755
|
filePatterns: ["**/*.py"],
|
|
756
|
-
supportedOS: ["linux", "darwin"],
|
|
756
|
+
supportedOS: ["linux", "darwin", "win32"],
|
|
757
757
|
supportedArch: ["x64", "arm64"],
|
|
758
758
|
supportedRunners: ["local", "container"]
|
|
759
759
|
};
|
|
@@ -788,7 +788,7 @@ function mapConfidence(confidence) {
|
|
|
788
788
|
var CONFIG_FILE_CANDIDATES = [".bandit", "bandit.yml", "pyproject.toml"];
|
|
789
789
|
async function resolveBinaryPath(ctx) {
|
|
790
790
|
const venvDir = (0, import_tooling.getVenvDir)(ctx.globalDir, ADAPTER_ID);
|
|
791
|
-
const venvBin =
|
|
791
|
+
const venvBin = (0, import_tooling.resolveVenvBinary)((0, import_tooling.getVenvPaths)(venvDir), "bandit");
|
|
792
792
|
try {
|
|
793
793
|
await import_promises.default.access(venvBin);
|
|
794
794
|
return venvBin;
|
|
@@ -844,14 +844,8 @@ var adapter = {
|
|
|
844
844
|
];
|
|
845
845
|
const venvDir = (0, import_tooling.getVenvDir)(ctx.globalDir, ADAPTER_ID);
|
|
846
846
|
try {
|
|
847
|
-
const
|
|
848
|
-
await import_promises.default.access(
|
|
849
|
-
const venv = {
|
|
850
|
-
root: venvDir,
|
|
851
|
-
binDir: import_path.default.join(venvDir, "bin"),
|
|
852
|
-
python: venvPython,
|
|
853
|
-
pip: import_path.default.join(venvDir, "bin", "pip")
|
|
854
|
-
};
|
|
847
|
+
const venv = (0, import_tooling.getVenvPaths)(venvDir);
|
|
848
|
+
await import_promises.default.access(venv.python);
|
|
855
849
|
const version = await (0, import_tooling.checkVenvTool)(
|
|
856
850
|
venv,
|
|
857
851
|
"bandit",
|
|
@@ -1002,54 +996,80 @@ var adapter = {
|
|
|
1002
996
|
args.push("-c", configPath);
|
|
1003
997
|
}
|
|
1004
998
|
}
|
|
1005
|
-
|
|
999
|
+
const fileChunks = (0, import_tooling.chunkFilesForArgv)(absoluteFiles);
|
|
1006
1000
|
try {
|
|
1007
|
-
const
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
errors.push({
|
|
1013
|
-
toolId: TOOL_ID,
|
|
1014
|
-
phase: "toolInvoke",
|
|
1015
|
-
kind: "NonZeroExit",
|
|
1016
|
-
message: `bandit exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
|
|
1017
|
-
level: "error"
|
|
1018
|
-
});
|
|
1019
|
-
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
1020
|
-
}
|
|
1021
|
-
if (!stdout.trim()) {
|
|
1022
|
-
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
1023
|
-
}
|
|
1024
|
-
const jsonStart = stdout.indexOf("{");
|
|
1025
|
-
const jsonPayload = jsonStart === -1 ? stdout : stdout.slice(jsonStart);
|
|
1026
|
-
let banditOutput;
|
|
1027
|
-
try {
|
|
1028
|
-
banditOutput = JSON.parse(jsonPayload);
|
|
1029
|
-
} catch (err) {
|
|
1030
|
-
errors.push({
|
|
1031
|
-
toolId: TOOL_ID,
|
|
1032
|
-
phase: "outputParse",
|
|
1033
|
-
kind: "MalformedOutput",
|
|
1034
|
-
message: `Failed to parse bandit JSON output: ${err instanceof Error ? err.message : String(err)}`,
|
|
1035
|
-
level: "error"
|
|
1001
|
+
const results = [];
|
|
1002
|
+
for (const chunk of fileChunks) {
|
|
1003
|
+
const { stdout, stderr, exitCode } = await (0, import_tooling.spawnTool)(binary, [...args, ...chunk], {
|
|
1004
|
+
cwd: ctx.repositoryRoot,
|
|
1005
|
+
logger: ctx.logger
|
|
1036
1006
|
});
|
|
1037
|
-
|
|
1038
|
-
}
|
|
1039
|
-
if (banditOutput.errors && banditOutput.errors.length > 0) {
|
|
1040
|
-
for (const banditError of banditOutput.errors) {
|
|
1007
|
+
if (exitCode > 1) {
|
|
1041
1008
|
errors.push({
|
|
1042
1009
|
toolId: TOOL_ID,
|
|
1043
1010
|
phase: "toolInvoke",
|
|
1044
|
-
kind: "
|
|
1045
|
-
message:
|
|
1011
|
+
kind: "NonZeroExit",
|
|
1012
|
+
message: `bandit exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
|
|
1013
|
+
level: "error"
|
|
1014
|
+
});
|
|
1015
|
+
return (0, import_tooling.buildResult)(
|
|
1016
|
+
TOOL_ID,
|
|
1017
|
+
startedAt,
|
|
1018
|
+
/* @__PURE__ */ new Date(),
|
|
1019
|
+
issues,
|
|
1020
|
+
errors,
|
|
1021
|
+
ctx.targetFiles.length
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
const stderrFiltered = stderr.split("\n").filter((line) => !/^\[.*\]\s+INFO\s+/.test(line.trim())).join("\n").trim();
|
|
1025
|
+
if (stderrFiltered) {
|
|
1026
|
+
errors.push({
|
|
1027
|
+
toolId: TOOL_ID,
|
|
1028
|
+
phase: "outputParse",
|
|
1029
|
+
kind: "ParseWarning",
|
|
1030
|
+
message: `bandit stderr: ${stderrFiltered}`,
|
|
1046
1031
|
level: "warning"
|
|
1047
1032
|
});
|
|
1048
1033
|
}
|
|
1034
|
+
if (!stdout.trim()) continue;
|
|
1035
|
+
const jsonStart = stdout.indexOf("{");
|
|
1036
|
+
const jsonPayload = jsonStart === -1 ? stdout : stdout.slice(jsonStart);
|
|
1037
|
+
let banditOutput;
|
|
1038
|
+
try {
|
|
1039
|
+
banditOutput = JSON.parse(jsonPayload);
|
|
1040
|
+
} catch (err) {
|
|
1041
|
+
errors.push({
|
|
1042
|
+
toolId: TOOL_ID,
|
|
1043
|
+
phase: "outputParse",
|
|
1044
|
+
kind: "MalformedOutput",
|
|
1045
|
+
message: `Failed to parse bandit JSON output: ${err instanceof Error ? err.message : String(err)}`,
|
|
1046
|
+
level: "error"
|
|
1047
|
+
});
|
|
1048
|
+
return (0, import_tooling.buildResult)(
|
|
1049
|
+
TOOL_ID,
|
|
1050
|
+
startedAt,
|
|
1051
|
+
/* @__PURE__ */ new Date(),
|
|
1052
|
+
issues,
|
|
1053
|
+
errors,
|
|
1054
|
+
ctx.targetFiles.length
|
|
1055
|
+
);
|
|
1056
|
+
}
|
|
1057
|
+
if (banditOutput.errors && banditOutput.errors.length > 0) {
|
|
1058
|
+
for (const banditError of banditOutput.errors) {
|
|
1059
|
+
errors.push({
|
|
1060
|
+
toolId: TOOL_ID,
|
|
1061
|
+
phase: "toolInvoke",
|
|
1062
|
+
kind: "FileError",
|
|
1063
|
+
message: `${banditError.filename}: ${banditError.reason}`,
|
|
1064
|
+
level: "warning"
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
results.push(...banditOutput.results);
|
|
1049
1069
|
}
|
|
1050
1070
|
const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
|
|
1051
1071
|
const resultsByFile = /* @__PURE__ */ new Map();
|
|
1052
|
-
for (const result2 of
|
|
1072
|
+
for (const result2 of results) {
|
|
1053
1073
|
const list = resultsByFile.get(result2.filename) ?? [];
|
|
1054
1074
|
list.push(result2);
|
|
1055
1075
|
resultsByFile.set(result2.filename, list);
|
|
@@ -1085,16 +1105,6 @@ var adapter = {
|
|
|
1085
1105
|
issues.push(issue);
|
|
1086
1106
|
}
|
|
1087
1107
|
}
|
|
1088
|
-
const stderrFiltered = stderr.split("\n").filter((line) => !/^\[.*\]\s+INFO\s+/.test(line.trim())).join("\n").trim();
|
|
1089
|
-
if (stderrFiltered) {
|
|
1090
|
-
errors.push({
|
|
1091
|
-
toolId: TOOL_ID,
|
|
1092
|
-
phase: "outputParse",
|
|
1093
|
-
kind: "ParseWarning",
|
|
1094
|
-
message: `bandit stderr: ${stderrFiltered}`,
|
|
1095
|
-
level: "warning"
|
|
1096
|
-
});
|
|
1097
|
-
}
|
|
1098
1108
|
} catch (err) {
|
|
1099
1109
|
errors.push({
|
|
1100
1110
|
toolId: TOOL_ID,
|
package/dist/metadata.js
CHANGED
|
@@ -29,7 +29,7 @@ var descriptor = {
|
|
|
29
29
|
preferredVersion: "1.8.3",
|
|
30
30
|
languages: ["Python"],
|
|
31
31
|
filePatterns: ["**/*.py"],
|
|
32
|
-
supportedOS: ["linux", "darwin"],
|
|
32
|
+
supportedOS: ["linux", "darwin", "win32"],
|
|
33
33
|
supportedArch: ["x64", "arm64"],
|
|
34
34
|
supportedRunners: ["local", "container"]
|
|
35
35
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codacy/tools-bandit-1",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Bandit adapter — CLI-mode Python security 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)",
|