@rafter-security/cli 0.7.9 → 0.8.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/commands/agent/baseline.js +15 -15
- package/dist/commands/agent/index.js +2 -2
- package/dist/commands/agent/init.js +165 -24
- package/dist/commands/agent/scan.js +24 -24
- package/dist/commands/agent/status.js +19 -10
- package/dist/commands/agent/update-betterleaks.js +39 -0
- package/dist/commands/agent/verify.js +19 -8
- package/dist/commands/completion.js +15 -15
- package/dist/commands/issues/from-scan.js +2 -2
- package/dist/commands/mcp/server.js +11 -11
- package/dist/scanners/{gitleaks.js → betterleaks.js} +49 -61
- package/dist/scanners/secret-patterns.js +1 -1
- package/dist/utils/binary-manager.js +205 -109
- package/package.json +1 -1
- package/resources/agents/rafter.md +1 -1
- package/resources/rafter-security-skill.md +2 -2
- package/resources/skills/rafter/SKILL.md +1 -1
- package/resources/skills/rafter/docs/cli-reference.md +5 -5
- package/dist/commands/agent/update-gitleaks.js +0 -40
|
@@ -15,7 +15,7 @@ _rafter_completions() {
|
|
|
15
15
|
return 0
|
|
16
16
|
;;
|
|
17
17
|
agent)
|
|
18
|
-
COMPREPLY=( $(compgen -W "scan init audit config exec audit-skill install-hook verify status update-
|
|
18
|
+
COMPREPLY=( $(compgen -W "scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline --help" -- "\${cur}") )
|
|
19
19
|
return 0
|
|
20
20
|
;;
|
|
21
21
|
brief)
|
|
@@ -66,7 +66,7 @@ _rafter_completions() {
|
|
|
66
66
|
;;
|
|
67
67
|
init)
|
|
68
68
|
if [[ "\${COMP_WORDS[1]}" == "agent" ]]; then
|
|
69
|
-
COMPREPLY=( $(compgen -W "--risk-level --with-openclaw --with-claude-code --with-codex --with-gemini --with-aider --with-cursor --with-windsurf --with-continue --with-
|
|
69
|
+
COMPREPLY=( $(compgen -W "--risk-level --with-openclaw --with-claude-code --with-codex --with-gemini --with-aider --with-cursor --with-windsurf --with-continue --with-betterleaks --all --help" -- "\${cur}") )
|
|
70
70
|
elif [[ "\${COMP_WORDS[1]}" == "ci" ]]; then
|
|
71
71
|
COMPREPLY=( $(compgen -W "--platform --output --with-remote --with-backend --help" -- "\${cur}") )
|
|
72
72
|
fi
|
|
@@ -106,7 +106,7 @@ _rafter() {
|
|
|
106
106
|
'install-hook:Install git hook (pre-commit or pre-push)'
|
|
107
107
|
'verify:Check integration status'
|
|
108
108
|
'status:Show agent status'
|
|
109
|
-
'update-
|
|
109
|
+
'update-betterleaks:Update betterleaks binary'
|
|
110
110
|
'baseline:Manage findings baseline'
|
|
111
111
|
)
|
|
112
112
|
|
|
@@ -166,7 +166,7 @@ _rafter() {
|
|
|
166
166
|
'--json[Output as JSON]' \\
|
|
167
167
|
'--staged[Scan only staged files]' \\
|
|
168
168
|
'--diff[Scan files changed since ref]:ref:' \\
|
|
169
|
-
'--engine[Scanner engine]:engine:(
|
|
169
|
+
'--engine[Scanner engine]:engine:(betterleaks patterns)' \\
|
|
170
170
|
'1:path:_files'
|
|
171
171
|
;;
|
|
172
172
|
init)
|
|
@@ -180,7 +180,7 @@ _rafter() {
|
|
|
180
180
|
'--with-cursor[Install Cursor integration]' \\
|
|
181
181
|
'--with-windsurf[Install Windsurf integration]' \\
|
|
182
182
|
'--with-continue[Install Continue.dev integration]' \\
|
|
183
|
-
'--with-
|
|
183
|
+
'--with-betterleaks[Download Betterleaks binary]' \\
|
|
184
184
|
'--all[Install all detected integrations]'
|
|
185
185
|
;;
|
|
186
186
|
audit)
|
|
@@ -314,21 +314,21 @@ complete -c rafter -n '__fish_seen_subcommand_from usage' -s k -l api-key -d 'AP
|
|
|
314
314
|
complete -c rafter -n '__fish_seen_subcommand_from brief' -a 'security scanning commands setup setup/claude-code setup/codex setup/gemini setup/cursor setup/windsurf setup/aider setup/openclaw setup/continue setup/generic all' -d 'Topic'
|
|
315
315
|
|
|
316
316
|
# agent subcommands
|
|
317
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
318
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
319
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
320
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
321
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
322
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
323
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
324
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
317
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a scan -d 'Scan files for secrets'
|
|
318
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a init -d 'Initialize agent security'
|
|
319
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a audit -d 'View audit log'
|
|
320
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a config -d 'Manage configuration'
|
|
321
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a exec -d 'Execute with security'
|
|
322
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a audit-skill -d 'Audit a skill file'
|
|
323
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a install-hook -d 'Install pre-commit hook'
|
|
324
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a verify -d 'Check integration status'
|
|
325
325
|
|
|
326
326
|
# agent scan options
|
|
327
327
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -s q -l quiet -d 'Only output if secrets found'
|
|
328
328
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -l json -d 'Output as JSON'
|
|
329
329
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -l staged -d 'Scan only staged files'
|
|
330
330
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -l diff -d 'Scan changed since ref' -r
|
|
331
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -l engine -d 'Scanner engine' -ra '
|
|
331
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -l engine -d 'Scanner engine' -ra 'betterleaks patterns'
|
|
332
332
|
|
|
333
333
|
# agent init options
|
|
334
334
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l risk-level -d 'Risk level' -ra 'minimal moderate aggressive'
|
|
@@ -340,7 +340,7 @@ complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcom
|
|
|
340
340
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l with-cursor -d 'Install Cursor'
|
|
341
341
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l with-windsurf -d 'Install Windsurf'
|
|
342
342
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l with-continue -d 'Install Continue.dev'
|
|
343
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l with-
|
|
343
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l with-betterleaks -d 'Install Betterleaks'
|
|
344
344
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l all -d 'Install all detected'
|
|
345
345
|
|
|
346
346
|
# agent audit options
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Supports both:
|
|
5
5
|
* - Backend scans: --scan-id <id> (fetches from Rafter API)
|
|
6
|
-
* - Local scans: --from-local <path> (reads JSON file from `rafter
|
|
6
|
+
* - Local scans: --from-local <path> (reads JSON file from `rafter secrets --format json`)
|
|
7
7
|
*/
|
|
8
8
|
import { Command } from "commander";
|
|
9
9
|
import fs from "fs";
|
|
@@ -18,7 +18,7 @@ export function createFromScanCommand() {
|
|
|
18
18
|
return new Command("from-scan")
|
|
19
19
|
.description("Create GitHub issues from scan results")
|
|
20
20
|
.option("--scan-id <id>", "Backend scan ID to create issues from")
|
|
21
|
-
.option("--from-local <path>", "Path to local scan JSON (from rafter
|
|
21
|
+
.option("--from-local <path>", "Path to local scan JSON (from rafter secrets --format json)")
|
|
22
22
|
.option("-r, --repo <repo>", "Target GitHub repo (org/repo)")
|
|
23
23
|
.option("-k, --api-key <key>", "Rafter API key (for --scan-id)")
|
|
24
24
|
.option("--no-dedup", "Skip deduplication check")
|
|
@@ -3,7 +3,7 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import { RegexScanner } from "../../scanners/regex-scanner.js";
|
|
6
|
-
import {
|
|
6
|
+
import { BetterleaksScanner } from "../../scanners/betterleaks.js";
|
|
7
7
|
import { CommandInterceptor } from "../../core/command-interceptor.js";
|
|
8
8
|
import { AuditLogger } from "../../core/audit-logger.js";
|
|
9
9
|
import { ConfigManager } from "../../core/config-manager.js";
|
|
@@ -42,8 +42,8 @@ export function createServer() {
|
|
|
42
42
|
path: { type: "string", description: "File or directory path to scan" },
|
|
43
43
|
engine: {
|
|
44
44
|
type: "string",
|
|
45
|
-
enum: ["auto", "
|
|
46
|
-
description: "Scan engine: auto (default),
|
|
45
|
+
enum: ["auto", "betterleaks", "patterns"],
|
|
46
|
+
description: "Scan engine: auto (default), betterleaks, or patterns.",
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
49
|
required: ["path"],
|
|
@@ -118,20 +118,20 @@ export function createServer() {
|
|
|
118
118
|
case "scan_secrets": {
|
|
119
119
|
const scanPath = args?.path;
|
|
120
120
|
const engine = args?.engine || "auto";
|
|
121
|
-
if (engine === "
|
|
122
|
-
const
|
|
123
|
-
if (await
|
|
121
|
+
if (engine === "betterleaks" || engine === "auto") {
|
|
122
|
+
const bl = new BetterleaksScanner();
|
|
123
|
+
if (await bl.isAvailable()) {
|
|
124
124
|
try {
|
|
125
|
-
const results = await
|
|
125
|
+
const results = await bl.scanDirectory(scanPath);
|
|
126
126
|
return textResult(formatScanResults(results));
|
|
127
127
|
}
|
|
128
128
|
catch {
|
|
129
|
-
if (engine === "
|
|
130
|
-
return errorResult("
|
|
129
|
+
if (engine === "betterleaks")
|
|
130
|
+
return errorResult("Betterleaks scan failed");
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
else if (engine === "
|
|
134
|
-
return errorResult("
|
|
133
|
+
else if (engine === "betterleaks") {
|
|
134
|
+
return errorResult("Betterleaks not installed");
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
const scanner = new RegexScanner();
|
|
@@ -6,46 +6,64 @@ import fs from "fs";
|
|
|
6
6
|
import os from "os";
|
|
7
7
|
import path from "path";
|
|
8
8
|
const execFileAsync = promisify(execFile);
|
|
9
|
-
export class
|
|
9
|
+
export class BetterleaksScanner {
|
|
10
10
|
constructor() {
|
|
11
|
+
this.resolvedPath = null;
|
|
11
12
|
this.binaryManager = new BinaryManager();
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* Resolve the betterleaks binary to use. Prefer the rafter-managed binary at
|
|
16
|
+
* ~/.rafter/bin/betterleaks; otherwise fall back to one on PATH (e.g. Homebrew).
|
|
17
|
+
* Cached after first lookup.
|
|
15
18
|
*/
|
|
16
|
-
async
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
19
|
+
async resolveBinary() {
|
|
20
|
+
if (this.resolvedPath !== null)
|
|
21
|
+
return this.resolvedPath || null;
|
|
22
|
+
if (this.binaryManager.isBetterleaksInstalled()) {
|
|
23
|
+
const managed = this.binaryManager.getBetterleaksPath();
|
|
24
|
+
if (await this.binaryManager.verifyBetterleaks()) {
|
|
25
|
+
this.resolvedPath = managed;
|
|
26
|
+
return managed;
|
|
27
|
+
}
|
|
19
28
|
}
|
|
20
|
-
|
|
29
|
+
const onPath = this.binaryManager.findBetterleaksOnPath();
|
|
30
|
+
if (onPath) {
|
|
31
|
+
const ok = await this.binaryManager.verifyBetterleaksVerbose(onPath);
|
|
32
|
+
if (ok.ok) {
|
|
33
|
+
this.resolvedPath = onPath;
|
|
34
|
+
return onPath;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
this.resolvedPath = "";
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
async isAvailable() {
|
|
41
|
+
return (await this.resolveBinary()) !== null;
|
|
21
42
|
}
|
|
22
43
|
/**
|
|
23
|
-
* Scan a file with
|
|
44
|
+
* Scan a single file with Betterleaks (uses `dir` subcommand on a single path).
|
|
24
45
|
*/
|
|
25
46
|
async scanFile(filePath) {
|
|
26
|
-
|
|
27
|
-
|
|
47
|
+
const blPath = await this.resolveBinary();
|
|
48
|
+
if (!blPath) {
|
|
49
|
+
throw new Error("Betterleaks not available");
|
|
28
50
|
}
|
|
29
|
-
const
|
|
30
|
-
const tmpReport = path.join(os.tmpdir(), `gitleaks-${Date.now()}-${randomBytes(6).toString("hex")}.json`);
|
|
51
|
+
const tmpReport = path.join(os.tmpdir(), `betterleaks-${Date.now()}-${randomBytes(6).toString("hex")}.json`);
|
|
31
52
|
try {
|
|
32
|
-
//
|
|
33
|
-
await execFileAsync(
|
|
34
|
-
// If no leaks found, gitleaks exits 0 with empty report
|
|
53
|
+
// `--` ensures a target path beginning with `-` isn't parsed as a flag by betterleaks.
|
|
54
|
+
await execFileAsync(blPath, ["dir", "-f", "json", "--report-path", tmpReport, "--", filePath], { timeout: 60000 });
|
|
35
55
|
if (!fs.existsSync(tmpReport)) {
|
|
36
56
|
return { file: filePath, matches: [] };
|
|
37
57
|
}
|
|
38
58
|
const results = this.parseResults(tmpReport);
|
|
39
|
-
// Clean up report
|
|
40
59
|
fs.unlinkSync(tmpReport);
|
|
41
|
-
// Convert to our format
|
|
42
60
|
return {
|
|
43
61
|
file: filePath,
|
|
44
62
|
matches: results.map(r => this.convertToPatternMatch(r))
|
|
45
63
|
};
|
|
46
64
|
}
|
|
47
65
|
catch (e) {
|
|
48
|
-
//
|
|
66
|
+
// Betterleaks exits with --exit-code (default 1) when leaks found — read report before cleanup
|
|
49
67
|
if (e.code === 1 && fs.existsSync(tmpReport)) {
|
|
50
68
|
const results = this.parseResults(tmpReport);
|
|
51
69
|
fs.unlinkSync(tmpReport);
|
|
@@ -54,16 +72,12 @@ export class GitleaksScanner {
|
|
|
54
72
|
matches: results.map(r => this.convertToPatternMatch(r))
|
|
55
73
|
};
|
|
56
74
|
}
|
|
57
|
-
// Clean up report for non-leak errors
|
|
58
75
|
if (fs.existsSync(tmpReport)) {
|
|
59
76
|
fs.unlinkSync(tmpReport);
|
|
60
77
|
}
|
|
61
|
-
throw new Error(`
|
|
78
|
+
throw new Error(`Betterleaks scan failed: ${e.message}`);
|
|
62
79
|
}
|
|
63
80
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Scan multiple files
|
|
66
|
-
*/
|
|
67
81
|
async scanFiles(filePaths) {
|
|
68
82
|
const results = [];
|
|
69
83
|
for (const filePath of filePaths) {
|
|
@@ -80,46 +94,37 @@ export class GitleaksScanner {
|
|
|
80
94
|
return results;
|
|
81
95
|
}
|
|
82
96
|
/**
|
|
83
|
-
* Scan a directory
|
|
97
|
+
* Scan a directory. With useGit=true, scans git history (`betterleaks git`);
|
|
98
|
+
* otherwise scans the filesystem (`betterleaks dir`).
|
|
84
99
|
*/
|
|
85
100
|
async scanDirectory(dirPath, opts) {
|
|
86
|
-
|
|
87
|
-
|
|
101
|
+
const blPath = await this.resolveBinary();
|
|
102
|
+
if (!blPath) {
|
|
103
|
+
throw new Error("Betterleaks not available");
|
|
88
104
|
}
|
|
89
|
-
const
|
|
90
|
-
const
|
|
105
|
+
const tmpReport = path.join(os.tmpdir(), `betterleaks-${Date.now()}-${randomBytes(6).toString("hex")}.json`);
|
|
106
|
+
const subcommand = opts?.useGit ? "git" : "dir";
|
|
91
107
|
try {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
args.splice(1, 0, "--no-git");
|
|
95
|
-
}
|
|
96
|
-
// Run gitleaks detect on directory
|
|
97
|
-
await execFileAsync(gitleaksPath, args, { timeout: 60000 });
|
|
98
|
-
// No leaks found
|
|
108
|
+
// `--` ensures a target path beginning with `-` isn't parsed as a flag by betterleaks.
|
|
109
|
+
await execFileAsync(blPath, [subcommand, "-f", "json", "--report-path", tmpReport, "--", dirPath], { timeout: 60000 });
|
|
99
110
|
if (!fs.existsSync(tmpReport)) {
|
|
100
111
|
return [];
|
|
101
112
|
}
|
|
102
113
|
const results = this.parseResults(tmpReport);
|
|
103
114
|
fs.unlinkSync(tmpReport);
|
|
104
|
-
// Group by file
|
|
105
115
|
return this.groupByFile(results);
|
|
106
116
|
}
|
|
107
117
|
catch (e) {
|
|
108
|
-
// Clean up report
|
|
109
118
|
if (fs.existsSync(tmpReport)) {
|
|
110
119
|
const results = this.parseResults(tmpReport);
|
|
111
120
|
fs.unlinkSync(tmpReport);
|
|
112
|
-
// Gitleaks exits 1 when leaks found
|
|
113
121
|
if (e.code === 1) {
|
|
114
122
|
return this.groupByFile(results);
|
|
115
123
|
}
|
|
116
124
|
}
|
|
117
|
-
throw new Error(`
|
|
125
|
+
throw new Error(`Betterleaks scan failed: ${e.message}`);
|
|
118
126
|
}
|
|
119
127
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Parse Gitleaks JSON report
|
|
122
|
-
*/
|
|
123
128
|
parseResults(reportPath) {
|
|
124
129
|
try {
|
|
125
130
|
const content = fs.readFileSync(reportPath, "utf-8");
|
|
@@ -128,26 +133,22 @@ export class GitleaksScanner {
|
|
|
128
133
|
}
|
|
129
134
|
const parsed = JSON.parse(content);
|
|
130
135
|
if (!Array.isArray(parsed)) {
|
|
131
|
-
console.error("[rafter] Warning:
|
|
136
|
+
console.error("[rafter] Warning: Betterleaks output is not an array — possible version mismatch");
|
|
132
137
|
return [];
|
|
133
138
|
}
|
|
134
139
|
return parsed;
|
|
135
140
|
}
|
|
136
141
|
catch (e) {
|
|
137
|
-
console.error(`[rafter] Warning: Failed to parse
|
|
142
|
+
console.error(`[rafter] Warning: Failed to parse Betterleaks report: ${e instanceof Error ? e.message : e}`);
|
|
138
143
|
return [];
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Convert Gitleaks result to our PatternMatch format
|
|
143
|
-
*/
|
|
144
146
|
convertToPatternMatch(result) {
|
|
145
|
-
// Map Gitleaks severity to our levels
|
|
146
147
|
const severity = this.getSeverity(result.RuleID, result.Tags);
|
|
147
148
|
return {
|
|
148
149
|
pattern: {
|
|
149
150
|
name: result.RuleID || result.Description,
|
|
150
|
-
regex: "",
|
|
151
|
+
regex: "",
|
|
151
152
|
severity,
|
|
152
153
|
description: result.Description
|
|
153
154
|
},
|
|
@@ -157,12 +158,8 @@ export class GitleaksScanner {
|
|
|
157
158
|
redacted: this.redact(result.Secret || result.Match)
|
|
158
159
|
};
|
|
159
160
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Determine severity from Gitleaks rule ID and tags
|
|
162
|
-
*/
|
|
163
161
|
getSeverity(ruleID, tags) {
|
|
164
162
|
const lowerID = ruleID.toLowerCase();
|
|
165
|
-
// Critical: Private keys, passwords, database credentials, access tokens
|
|
166
163
|
if (lowerID.includes("private-key") ||
|
|
167
164
|
lowerID.includes("password") ||
|
|
168
165
|
lowerID.includes("database") ||
|
|
@@ -172,24 +169,18 @@ export class GitleaksScanner {
|
|
|
172
169
|
(tags.includes("key") && tags.includes("secret"))) {
|
|
173
170
|
return "critical";
|
|
174
171
|
}
|
|
175
|
-
// High: API keys, generic tokens
|
|
176
172
|
if (lowerID.includes("api-key") ||
|
|
177
173
|
lowerID.includes("-token") ||
|
|
178
174
|
lowerID.startsWith("token-") ||
|
|
179
175
|
tags.includes("api")) {
|
|
180
176
|
return "high";
|
|
181
177
|
}
|
|
182
|
-
// Medium: Generic secrets
|
|
183
178
|
if (lowerID.includes("generic") ||
|
|
184
179
|
tags.includes("generic")) {
|
|
185
180
|
return "medium";
|
|
186
181
|
}
|
|
187
|
-
// Default to high for safety
|
|
188
182
|
return "high";
|
|
189
183
|
}
|
|
190
|
-
/**
|
|
191
|
-
* Redact a secret
|
|
192
|
-
*/
|
|
193
184
|
redact(match) {
|
|
194
185
|
if (match.length <= 8) {
|
|
195
186
|
return "*".repeat(match.length);
|
|
@@ -200,9 +191,6 @@ export class GitleaksScanner {
|
|
|
200
191
|
const middle = "*".repeat(match.length - (visibleChars * 2));
|
|
201
192
|
return start + middle + end;
|
|
202
193
|
}
|
|
203
|
-
/**
|
|
204
|
-
* Group results by file
|
|
205
|
-
*/
|
|
206
194
|
groupByFile(results) {
|
|
207
195
|
const grouped = new Map();
|
|
208
196
|
for (const result of results) {
|