@vaultcompass/vault-guard 1.1.0 → 1.1.2
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/cli-entry.js +2 -5
- package/dist/cli.js +18 -21
- package/dist/commands/check.js +2 -34
- package/dist/commands/scan.d.ts +1 -1
- package/dist/commands/scan.js +4 -2
- package/package.json +4 -4
package/dist/cli-entry.js
CHANGED
|
@@ -9,11 +9,8 @@ if (nodeMajor < 22) {
|
|
|
9
9
|
}
|
|
10
10
|
const program = (0, cli_1.buildCli)();
|
|
11
11
|
// Parse arguments and execute command
|
|
12
|
-
program.parseAsync().
|
|
13
|
-
// Successful completion
|
|
14
|
-
process.exit(0);
|
|
15
|
-
}).catch((error) => {
|
|
12
|
+
program.parseAsync().catch((error) => {
|
|
16
13
|
// Handle errors
|
|
17
14
|
console.error(error);
|
|
18
|
-
process.
|
|
15
|
+
process.exitCode = 1;
|
|
19
16
|
});
|
package/dist/cli.js
CHANGED
|
@@ -52,6 +52,11 @@ function readCliVersion() {
|
|
|
52
52
|
const raw = fs.readFileSync(pkgPath, 'utf-8');
|
|
53
53
|
return JSON.parse(raw).version;
|
|
54
54
|
}
|
|
55
|
+
function setExitCode(exitCode) {
|
|
56
|
+
if (exitCode !== 0) {
|
|
57
|
+
process.exitCode = exitCode;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
55
60
|
function buildCli() {
|
|
56
61
|
const program = new commander_1.Command();
|
|
57
62
|
program
|
|
@@ -64,8 +69,7 @@ function buildCli() {
|
|
|
64
69
|
.description('Validate the nearest .vault-guard.json (structure + scanner load)')
|
|
65
70
|
.action(async () => {
|
|
66
71
|
const exitCode = await (0, config_1.configValidateCommand)(process.cwd());
|
|
67
|
-
|
|
68
|
-
process.exit(exitCode);
|
|
72
|
+
setExitCode(exitCode);
|
|
69
73
|
});
|
|
70
74
|
// Scan command
|
|
71
75
|
program
|
|
@@ -77,9 +81,7 @@ function buildCli() {
|
|
|
77
81
|
.action(async (path, options) => {
|
|
78
82
|
const format = options.format ?? 'text';
|
|
79
83
|
const exitCode = await (0, scan_1.scanCommand)(path, format, Boolean(options.staged));
|
|
80
|
-
|
|
81
|
-
process.exit(exitCode);
|
|
82
|
-
}
|
|
84
|
+
setExitCode(exitCode);
|
|
83
85
|
});
|
|
84
86
|
// Install-hook command
|
|
85
87
|
program
|
|
@@ -90,7 +92,8 @@ function buildCli() {
|
|
|
90
92
|
const m = (options.manager ?? 'native').toLowerCase();
|
|
91
93
|
if (!['native', 'husky', 'lefthook', 'precommit'].includes(m)) {
|
|
92
94
|
console.error(`Unknown manager: ${options.manager}`);
|
|
93
|
-
process.
|
|
95
|
+
process.exitCode = 1;
|
|
96
|
+
return;
|
|
94
97
|
}
|
|
95
98
|
await (0, install_hook_1.installHookCommand)(m);
|
|
96
99
|
});
|
|
@@ -108,20 +111,16 @@ function buildCli() {
|
|
|
108
111
|
.argument('[files...]', 'Files to check')
|
|
109
112
|
.action(async (files) => {
|
|
110
113
|
const exitCode = await (0, fix_1.fixCommand)(files);
|
|
111
|
-
|
|
112
|
-
process.exit(exitCode);
|
|
113
|
-
}
|
|
114
|
+
setExitCode(exitCode);
|
|
114
115
|
});
|
|
115
116
|
// Check command
|
|
116
117
|
program
|
|
117
118
|
.command('check')
|
|
118
|
-
.description('
|
|
119
|
+
.description('Scan files with config and baselines')
|
|
119
120
|
.argument('[files...]', 'Files to check')
|
|
120
121
|
.action(async (files) => {
|
|
121
122
|
const exitCode = await (0, check_1.checkCommand)(files);
|
|
122
|
-
|
|
123
|
-
process.exit(exitCode);
|
|
124
|
-
}
|
|
123
|
+
setExitCode(exitCode);
|
|
125
124
|
});
|
|
126
125
|
program
|
|
127
126
|
.command('statusline')
|
|
@@ -162,7 +161,8 @@ function buildCli() {
|
|
|
162
161
|
const n = Number(options.maxRpm);
|
|
163
162
|
if (!Number.isFinite(n) || n < 1) {
|
|
164
163
|
console.error('--max-rpm must be a positive number');
|
|
165
|
-
process.
|
|
164
|
+
process.exitCode = 1;
|
|
165
|
+
return;
|
|
166
166
|
}
|
|
167
167
|
maxRpm = Math.floor(n);
|
|
168
168
|
}
|
|
@@ -192,7 +192,7 @@ function buildCli() {
|
|
|
192
192
|
}
|
|
193
193
|
catch (e) {
|
|
194
194
|
console.error(String(e));
|
|
195
|
-
process.
|
|
195
|
+
process.exitCode = 1;
|
|
196
196
|
}
|
|
197
197
|
});
|
|
198
198
|
// `data` parent command — inspects, exports, and resets the local
|
|
@@ -207,8 +207,7 @@ function buildCli() {
|
|
|
207
207
|
.option('--json', 'Print JSON', false)
|
|
208
208
|
.action(async (options) => {
|
|
209
209
|
const exitCode = await (0, data_1.dataStatusCommand)({ json: Boolean(options.json) });
|
|
210
|
-
|
|
211
|
-
process.exit(exitCode);
|
|
210
|
+
setExitCode(exitCode);
|
|
212
211
|
});
|
|
213
212
|
dataCmd
|
|
214
213
|
.command('reset')
|
|
@@ -222,8 +221,7 @@ function buildCli() {
|
|
|
222
221
|
dryRun: Boolean(options.dryRun),
|
|
223
222
|
json: Boolean(options.json),
|
|
224
223
|
});
|
|
225
|
-
|
|
226
|
-
process.exit(exitCode);
|
|
224
|
+
setExitCode(exitCode);
|
|
227
225
|
});
|
|
228
226
|
dataCmd
|
|
229
227
|
.command('export')
|
|
@@ -233,8 +231,7 @@ function buildCli() {
|
|
|
233
231
|
.action(async (options) => {
|
|
234
232
|
const fmt = options.format === 'jsonl' ? 'jsonl' : 'json';
|
|
235
233
|
const exitCode = await (0, data_1.dataExportCommand)({ output: options.output, format: fmt });
|
|
236
|
-
|
|
237
|
-
process.exit(exitCode);
|
|
234
|
+
setExitCode(exitCode);
|
|
238
235
|
});
|
|
239
236
|
return program;
|
|
240
237
|
}
|
package/dist/commands/check.js
CHANGED
|
@@ -1,39 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.checkCommand = checkCommand;
|
|
7
|
-
const
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const scan_utils_1 = require("../utils/scan-utils");
|
|
4
|
+
const scan_1 = require("./scan");
|
|
11
5
|
async function checkCommand(files) {
|
|
12
|
-
|
|
13
|
-
const filesToCheck = files.length > 0 ? files : ['.'];
|
|
14
|
-
console.log(chalk_1.default.blue('✅ Quick check\n'));
|
|
15
|
-
// Use async scanning logic with same safeguards as scan command
|
|
16
|
-
const results = await (0, scan_utils_1.scanFilesAsync)(filesToCheck, scanner, {
|
|
17
|
-
verbose: false,
|
|
18
|
-
skipBinary: true,
|
|
19
|
-
progress: false
|
|
20
|
-
});
|
|
21
|
-
if (results.length === 0) {
|
|
22
|
-
console.log(chalk_1.default.green.bold('✅ Clean:'), chalk_1.default.white('No secrets found\n'));
|
|
23
|
-
return 0; // Success exit code
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
const totalSecrets = results.reduce((sum, r) => sum + r.matches.length, 0);
|
|
27
|
-
console.log(chalk_1.default.red.bold('🔴 BLOCKED:'), chalk_1.default.white(`Found ${totalSecrets} secret${totalSecrets > 1 ? 's' : ''}\n`));
|
|
28
|
-
// Display simplified results
|
|
29
|
-
for (const { file, matches } of results) {
|
|
30
|
-
const relativePath = relativePathCwd(file);
|
|
31
|
-
console.log(chalk_1.default.red('🔴'), chalk_1.default.white(`${relativePath}: ${matches.length} secret${matches.length > 1 ? 's' : ''}`));
|
|
32
|
-
}
|
|
33
|
-
console.log('');
|
|
34
|
-
return 1; // Error exit code (secrets found)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function relativePathCwd(filePath) {
|
|
38
|
-
return path_1.default.relative(process.cwd(), filePath);
|
|
6
|
+
return (0, scan_1.scanCommand)(files.length > 0 ? files : '.', 'text', false);
|
|
39
7
|
}
|
package/dist/commands/scan.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type OutputFormat = 'text' | 'json' | 'sarif';
|
|
2
|
-
export declare function scanCommand(targetPath: string, format?: OutputFormat, staged?: boolean): Promise<number>;
|
|
2
|
+
export declare function scanCommand(targetPath: string | string[], format?: OutputFormat, staged?: boolean): Promise<number>;
|
package/dist/commands/scan.js
CHANGED
|
@@ -9,6 +9,8 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
9
9
|
const scan_utils_1 = require("../utils/scan-utils");
|
|
10
10
|
async function scanCommand(targetPath, format = 'text', staged = false) {
|
|
11
11
|
const cwd = process.cwd();
|
|
12
|
+
const targetPaths = Array.isArray(targetPath) ? targetPath : [targetPath];
|
|
13
|
+
const targetLabel = targetPaths.length === 1 ? targetPaths[0] : `${targetPaths.length} paths`;
|
|
12
14
|
let config;
|
|
13
15
|
try {
|
|
14
16
|
config = (0, vault_guard_core_1.loadConfig)(cwd);
|
|
@@ -54,7 +56,7 @@ async function scanCommand(targetPath, format = 'text', staged = false) {
|
|
|
54
56
|
'you have audited every pattern.\n'));
|
|
55
57
|
}
|
|
56
58
|
if (format === 'text' && !staged) {
|
|
57
|
-
console.log(chalk_1.default.blue('🔍 Scanning'), chalk_1.default.cyan(
|
|
59
|
+
console.log(chalk_1.default.blue('🔍 Scanning'), chalk_1.default.cyan(targetLabel));
|
|
58
60
|
}
|
|
59
61
|
const stats = { filesScanned: 0, bytesScanned: 0 };
|
|
60
62
|
const t0 = Date.now();
|
|
@@ -96,7 +98,7 @@ async function scanCommand(targetPath, format = 'text', staged = false) {
|
|
|
96
98
|
});
|
|
97
99
|
}
|
|
98
100
|
else {
|
|
99
|
-
results = await (0, scan_utils_1.scanFilesAsync)(
|
|
101
|
+
results = await (0, scan_utils_1.scanFilesAsync)(targetPaths, scanner, {
|
|
100
102
|
verbose: format === 'text',
|
|
101
103
|
skipBinary: true,
|
|
102
104
|
progress: format === 'text',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaultcompass/vault-guard",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Block secrets at commit and in CI. Pre-commit hooks, SARIF output, and fast staged-file scans for AI-native workflows.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"chalk": "^4.1.2",
|
|
38
38
|
"commander": "^12.0.0",
|
|
39
|
-
"@vaultcompass/vault-guard-core": "1.1.
|
|
40
|
-
"@vaultcompass/vault-guard-telemetry": "1.1.
|
|
39
|
+
"@vaultcompass/vault-guard-core": "1.1.2",
|
|
40
|
+
"@vaultcompass/vault-guard-telemetry": "1.1.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/jest": "^30.0.0",
|
|
44
|
-
"@types/node": "^25.9.
|
|
44
|
+
"@types/node": "^25.9.3",
|
|
45
45
|
"jest": "^30.4.2",
|
|
46
46
|
"ts-jest": "^29.4.11",
|
|
47
47
|
"typescript": "^5.3.3"
|