codesentry 0.1.5 → 0.1.7
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 +31 -3
- package/package.json +3 -4
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
5
|
+
import { createRequire as createRequire4 } from "module";
|
|
4
6
|
import { Command } from "commander";
|
|
5
7
|
import figlet from "figlet";
|
|
6
8
|
import gradient from "gradient-string";
|
|
@@ -140,6 +142,25 @@ import { join as join2 } from "path";
|
|
|
140
142
|
import chalk2 from "chalk";
|
|
141
143
|
import { Listr } from "listr2";
|
|
142
144
|
|
|
145
|
+
// src/errors.ts
|
|
146
|
+
var errorDetail = (error) => {
|
|
147
|
+
const stderr = error.stderr;
|
|
148
|
+
const stderrText = typeof stderr === "string" && stderr.trim().length > 0 ? ` (stderr: ${stderr.trim()})` : "";
|
|
149
|
+
return `${error.message}${stderrText}`;
|
|
150
|
+
};
|
|
151
|
+
var formatErrorChain = (error) => {
|
|
152
|
+
if (!(error instanceof Error)) {
|
|
153
|
+
return "erro desconhecido";
|
|
154
|
+
}
|
|
155
|
+
const parts = [errorDetail(error)];
|
|
156
|
+
let current = error.cause;
|
|
157
|
+
while (current instanceof Error) {
|
|
158
|
+
parts.push(errorDetail(current));
|
|
159
|
+
current = current.cause;
|
|
160
|
+
}
|
|
161
|
+
return parts.join(" | Causa: ");
|
|
162
|
+
};
|
|
163
|
+
|
|
143
164
|
// src/reporters/console.reporter.ts
|
|
144
165
|
import chalk from "chalk";
|
|
145
166
|
import Table from "cli-table3";
|
|
@@ -461,9 +482,10 @@ var runBundledSemgrep = async (targetDir, runtime = resolveBundledSemgrepRuntime
|
|
|
461
482
|
"."
|
|
462
483
|
];
|
|
463
484
|
let stdout;
|
|
485
|
+
const SYSTEM_PATH_FALLBACK = process.platform === "win32" ? "C:\\Windows\\System32;C:\\Windows" : "/usr/local/bin:/usr/bin:/bin";
|
|
464
486
|
const env = {
|
|
465
487
|
...process.env,
|
|
466
|
-
PATH: `${dirname2(runtime.semgrep)}${delimiter}${process.env.PATH ?? ""}`
|
|
488
|
+
PATH: `${dirname2(runtime.semgrep)}${delimiter}${process.env.PATH ?? ""}${delimiter}${SYSTEM_PATH_FALLBACK}`
|
|
467
489
|
};
|
|
468
490
|
try {
|
|
469
491
|
({ stdout } = await execute(runtime.semgrep, args, { cwd: targetDir, maxBuffer: 20 * 1024 * 1024, env }));
|
|
@@ -495,7 +517,7 @@ var generateMarkdownReportFilename = (date = /* @__PURE__ */ new Date()) => {
|
|
|
495
517
|
var errorMessage2 = (error) => error instanceof Error ? error.message : "erro desconhecido";
|
|
496
518
|
var reportScanFailure = (error) => {
|
|
497
519
|
process.exitCode = 1;
|
|
498
|
-
console.error(`Falha ao executar o scan: ${
|
|
520
|
+
console.error(`Falha ao executar o scan: ${formatErrorChain(error)}`);
|
|
499
521
|
};
|
|
500
522
|
var printResult = (result, options) => {
|
|
501
523
|
if (options.json) {
|
|
@@ -2505,9 +2527,15 @@ var registerSecurityCommands = (program) => {
|
|
|
2505
2527
|
registerSensitiveDataInLogsCommand(program);
|
|
2506
2528
|
registerPublicEnvVarSecretCommand(program);
|
|
2507
2529
|
};
|
|
2530
|
+
var require5 = createRequire4(import.meta.url);
|
|
2531
|
+
var readPackageVersion = () => {
|
|
2532
|
+
const packageJsonPath = require5.resolve("../package.json");
|
|
2533
|
+
const { version } = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
2534
|
+
return version;
|
|
2535
|
+
};
|
|
2508
2536
|
var createCli = () => {
|
|
2509
2537
|
printBanner();
|
|
2510
|
-
const program = new Command().name("codesentry").description("CLI de verifica\xE7\xE3o de vulnerabilidades e qualidade de c\xF3digo").version(
|
|
2538
|
+
const program = new Command().name("codesentry").description("CLI de verifica\xE7\xE3o de vulnerabilidades e qualidade de c\xF3digo").version(readPackageVersion()).helpCommand(false);
|
|
2511
2539
|
registerInitCommand(program);
|
|
2512
2540
|
registerAnalysisCommands(program);
|
|
2513
2541
|
registerQualityCommands(program);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codesentry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"workspaces": [
|
|
5
5
|
"packages/semgrep-rules"
|
|
6
6
|
],
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"@clack/prompts": "^1.7.0",
|
|
49
49
|
"chalk": "^6.0.0",
|
|
50
50
|
"cli-table3": "^0.6.5",
|
|
51
|
-
"codesentry-semgrep-rules": "0.1.5",
|
|
52
51
|
"commander": "^15.0.0",
|
|
53
52
|
"eslint": "^10.10.0",
|
|
54
53
|
"eslint-plugin-no-unsanitized": "^4.1.5",
|
|
@@ -59,8 +58,8 @@
|
|
|
59
58
|
"p-limit": "^7.3.2"
|
|
60
59
|
},
|
|
61
60
|
"optionalDependencies": {
|
|
62
|
-
"codesentry-semgrep-linux-x64": "0.1.
|
|
63
|
-
"codesentry-semgrep-win32-x64": "0.1.
|
|
61
|
+
"codesentry-semgrep-linux-x64": "0.1.7",
|
|
62
|
+
"codesentry-semgrep-win32-x64": "0.1.7"
|
|
64
63
|
},
|
|
65
64
|
"devDependencies": {
|
|
66
65
|
"@types/node": "^26.4.1",
|