@vaultcompass/vault-guard-core 1.0.2 → 1.0.4
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/README.md +90 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @vaultcompass/vault-guard-core
|
|
2
|
+
|
|
3
|
+
The scanning engine behind [Vault Guard](https://github.com/vaultcompasshq/vault-guard), as a library: vendor-anchored patterns, entropy gating, baselines, and SARIF/JSON output, with no CLI to shell out to. For building your own CI checks, editor plugins, or security tooling.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vaultcompass/vault-guard-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires **Node.js 22+**.
|
|
12
|
+
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
**Scan a file for secrets**
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { SecretScanner } from '@vaultcompass/vault-guard-core';
|
|
19
|
+
|
|
20
|
+
const scanner = new SecretScanner();
|
|
21
|
+
const matches = scanner.scan('/path/to/file.ts');
|
|
22
|
+
|
|
23
|
+
for (const m of matches) {
|
|
24
|
+
console.log(m.type, m.severity, `line ${m.line}`);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Load repo config**
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { loadConfig } from '@vaultcompass/vault-guard-core';
|
|
32
|
+
|
|
33
|
+
const config = loadConfig('/path/to/repo');
|
|
34
|
+
const scanner = new SecretScanner(config);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Format results as JSON or SARIF**
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import {
|
|
41
|
+
SecretScanner,
|
|
42
|
+
formatJson,
|
|
43
|
+
formatSarif,
|
|
44
|
+
} from '@vaultcompass/vault-guard-core';
|
|
45
|
+
|
|
46
|
+
const scanner = new SecretScanner();
|
|
47
|
+
const results = [{ file: 'src/api.ts', matches: scanner.scan('src/api.ts') }];
|
|
48
|
+
|
|
49
|
+
const json = formatJson(results);
|
|
50
|
+
const sarif = formatSarif(results, { cwd: process.cwd() });
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## What it detects
|
|
54
|
+
|
|
55
|
+
Built-in patterns cover AI/ML API keys (Anthropic, OpenAI, HuggingFace), cloud credentials (AWS, GCP, Azure), payment processors (Stripe, PayPal), database URLs, VCS tokens, SSH private keys, JWTs, and entropy-gated generic assignments.
|
|
56
|
+
|
|
57
|
+
Full rule reference: [docs/RULES.md](https://github.com/vaultcompasshq/vault-guard/blob/main/docs/RULES.md)
|
|
58
|
+
|
|
59
|
+
## Main exports
|
|
60
|
+
|
|
61
|
+
| Export | Description |
|
|
62
|
+
|--------|-------------|
|
|
63
|
+
| `SecretScanner` | Scan files and text for secrets |
|
|
64
|
+
| `TokenCounter` | Rough on-disk token estimates |
|
|
65
|
+
| `PreCommitHook` | Install pre-commit hooks (native, Husky, Lefthook) |
|
|
66
|
+
| `loadConfig` / `validateVaultGuardConfig` | `.vault-guard.json` loading and validation |
|
|
67
|
+
| `formatJson` / `formatSarif` | Structured output for CI and GitHub Code Scanning |
|
|
68
|
+
| `fingerprintForMatch` | Baseline fingerprinting (no raw secrets stored) |
|
|
69
|
+
| `scanTextFileAsync` / `scanTextFileSync` | Stream-aware file scanning |
|
|
70
|
+
| `getGitStagedFilePaths` | Staged-file enumeration for hooks |
|
|
71
|
+
|
|
72
|
+
## Prefer the CLI?
|
|
73
|
+
|
|
74
|
+
Most users should install the full CLI instead:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm install -g @vaultcompass/vault-guard
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
This package is for building integrations (MCP servers, CI plugins, custom tooling) on top of the same engine.
|
|
81
|
+
|
|
82
|
+
## Documentation
|
|
83
|
+
|
|
84
|
+
- [GitHub repository](https://github.com/vaultcompasshq/vault-guard)
|
|
85
|
+
- [Configuration schema](https://github.com/vaultcompasshq/vault-guard/blob/main/schemas/vault-guard-config.json)
|
|
86
|
+
- [Product scope & JSON output](https://github.com/vaultcompasshq/vault-guard/blob/main/docs/PRODUCT_SCOPE.md)
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT. [Vault & Compass LLC](https://vaultcompass.io)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaultcompass/vault-guard-core",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Secret-scanning engine: vendor-anchored patterns, entropy gating, baselines, SARIF/JSON, hook helpers.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|