shieldcortex 2.8.3 → 2.9.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/dashboard/.next/standalone/dashboard/.next/BUILD_ID +1 -1
- package/dashboard/.next/standalone/dashboard/.next/build-manifest.json +2 -2
- package/dashboard/.next/standalone/dashboard/.next/prerender-manifest.json +3 -3
- package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.html +2 -2
- package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.html +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/index.html +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/index.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/pages/404.html +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/pages/500.html +2 -2
- package/dashboard/.next/standalone/dashboard/.next/server/server-reference-manifest.js +1 -1
- package/dashboard/.next/standalone/dashboard/.next/server/server-reference-manifest.json +1 -1
- package/dist/audit/env-scanner.d.ts +15 -0
- package/dist/audit/env-scanner.d.ts.map +1 -0
- package/dist/audit/env-scanner.js +206 -0
- package/dist/audit/env-scanner.js.map +1 -0
- package/dist/audit/index.d.ts +14 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +13 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/mcp-config-scanner.d.ts +14 -0
- package/dist/audit/mcp-config-scanner.d.ts.map +1 -0
- package/dist/audit/mcp-config-scanner.js +177 -0
- package/dist/audit/mcp-config-scanner.js.map +1 -0
- package/dist/audit/memory-scanner.d.ts +15 -0
- package/dist/audit/memory-scanner.d.ts.map +1 -0
- package/dist/audit/memory-scanner.js +205 -0
- package/dist/audit/memory-scanner.js.map +1 -0
- package/dist/audit/report-formatter.d.ts +24 -0
- package/dist/audit/report-formatter.d.ts.map +1 -0
- package/dist/audit/report-formatter.js +237 -0
- package/dist/audit/report-formatter.js.map +1 -0
- package/dist/audit/rules-file-scanner.d.ts +17 -0
- package/dist/audit/rules-file-scanner.d.ts.map +1 -0
- package/dist/audit/rules-file-scanner.js +176 -0
- package/dist/audit/rules-file-scanner.js.map +1 -0
- package/dist/audit/types.d.ts +67 -0
- package/dist/audit/types.d.ts.map +1 -0
- package/dist/audit/types.js +27 -0
- package/dist/audit/types.js.map +1 -0
- package/dist/cli/audit.d.ts +17 -0
- package/dist/cli/audit.d.ts.map +1 -0
- package/dist/cli/audit.js +131 -0
- package/dist/cli/audit.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/setup/openclaw.d.ts +4 -0
- package/dist/setup/openclaw.d.ts.map +1 -1
- package/dist/setup/openclaw.js +33 -16
- package/dist/setup/openclaw.js.map +1 -1
- package/package.json +1 -1
- /package/dashboard/.next/standalone/dashboard/.next/static/{1qrgySClAGq-utdM3v43v → VvHJmUpDhBZ-8LaJ5n-QH}/_buildManifest.js +0 -0
- /package/dashboard/.next/standalone/dashboard/.next/static/{1qrgySClAGq-utdM3v43v → VvHJmUpDhBZ-8LaJ5n-QH}/_clientMiddlewareManifest.json +0 -0
- /package/dashboard/.next/standalone/dashboard/.next/static/{1qrgySClAGq-utdM3v43v → VvHJmUpDhBZ-8LaJ5n-QH}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report Formatter
|
|
3
|
+
*
|
|
4
|
+
* Formats the audit report for terminal output with:
|
|
5
|
+
* - ASCII art shield header
|
|
6
|
+
* - Security grade (A-F)
|
|
7
|
+
* - Colour-coded findings by severity
|
|
8
|
+
* - Summary statistics
|
|
9
|
+
* - Markdown export mode for CI/GitHub
|
|
10
|
+
*/
|
|
11
|
+
// ── ANSI Colours ──
|
|
12
|
+
const c = {
|
|
13
|
+
reset: '\x1b[0m',
|
|
14
|
+
bold: '\x1b[1m',
|
|
15
|
+
dim: '\x1b[2m',
|
|
16
|
+
red: '\x1b[31m',
|
|
17
|
+
green: '\x1b[32m',
|
|
18
|
+
yellow: '\x1b[33m',
|
|
19
|
+
blue: '\x1b[34m',
|
|
20
|
+
magenta: '\x1b[35m',
|
|
21
|
+
cyan: '\x1b[36m',
|
|
22
|
+
white: '\x1b[37m',
|
|
23
|
+
bgRed: '\x1b[41m',
|
|
24
|
+
bgGreen: '\x1b[42m',
|
|
25
|
+
bgYellow: '\x1b[43m',
|
|
26
|
+
brightRed: '\x1b[91m',
|
|
27
|
+
};
|
|
28
|
+
// ── Grade Colours ──
|
|
29
|
+
function gradeColour(grade) {
|
|
30
|
+
switch (grade) {
|
|
31
|
+
case 'A': return c.green;
|
|
32
|
+
case 'B': return c.blue;
|
|
33
|
+
case 'C': return c.yellow;
|
|
34
|
+
case 'D': return c.brightRed;
|
|
35
|
+
case 'F': return c.red;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function severityColour(severity) {
|
|
39
|
+
switch (severity) {
|
|
40
|
+
case 'critical': return c.red;
|
|
41
|
+
case 'high': return c.brightRed;
|
|
42
|
+
case 'medium': return c.yellow;
|
|
43
|
+
case 'low': return c.cyan;
|
|
44
|
+
case 'info': return c.dim;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function severityIcon(severity) {
|
|
48
|
+
switch (severity) {
|
|
49
|
+
case 'critical': return 'X';
|
|
50
|
+
case 'high': return '!';
|
|
51
|
+
case 'medium': return '~';
|
|
52
|
+
case 'low': return '-';
|
|
53
|
+
case 'info': return 'i';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// ── ASCII Art ──
|
|
57
|
+
const SHIELD_ART = `
|
|
58
|
+
_____ __ _ __ ______ __
|
|
59
|
+
/ ___// /_ (_)__ / /___/ / ____/___ _____/ /____ _ __
|
|
60
|
+
\\__ \\/ __ \\/ / _ \\/ / __ / / / __ \\/ ___/ __/ _ \\| |/_/
|
|
61
|
+
___/ / / / / / __/ / /_/ / /___/ /_/ / / / /_/ __/> <
|
|
62
|
+
/____/_/ /_/_/\\___/_/\\__,_/\\____/\\____/_/ \\__/\\___/_/|_|
|
|
63
|
+
`;
|
|
64
|
+
const GRADE_ART = {
|
|
65
|
+
A: `
|
|
66
|
+
╔═══════════════════╗
|
|
67
|
+
║ Grade: A ║
|
|
68
|
+
║ ALL CLEAR ║
|
|
69
|
+
╚═══════════════════╝`,
|
|
70
|
+
B: `
|
|
71
|
+
╔═══════════════════╗
|
|
72
|
+
║ Grade: B ║
|
|
73
|
+
║ LOW RISK ║
|
|
74
|
+
╚═══════════════════╝`,
|
|
75
|
+
C: `
|
|
76
|
+
╔═══════════════════╗
|
|
77
|
+
║ Grade: C ║
|
|
78
|
+
║ MODERATE RISK ║
|
|
79
|
+
╚═══════════════════╝`,
|
|
80
|
+
D: `
|
|
81
|
+
╔═══════════════════╗
|
|
82
|
+
║ Grade: D ║
|
|
83
|
+
║ HIGH RISK ║
|
|
84
|
+
╚═══════════════════╝`,
|
|
85
|
+
F: `
|
|
86
|
+
╔═══════════════════════╗
|
|
87
|
+
║ Grade: F ║
|
|
88
|
+
║ CRITICAL RISK ║
|
|
89
|
+
╚═══════════════════════╝`,
|
|
90
|
+
};
|
|
91
|
+
// ── Terminal Formatter ──
|
|
92
|
+
/**
|
|
93
|
+
* Format an audit report for terminal display.
|
|
94
|
+
*/
|
|
95
|
+
export function formatTerminalReport(report) {
|
|
96
|
+
const lines = [];
|
|
97
|
+
const gc = gradeColour(report.grade);
|
|
98
|
+
// Header
|
|
99
|
+
lines.push(`${c.cyan}${SHIELD_ART}${c.reset}`);
|
|
100
|
+
lines.push(`${c.bold} Security Audit${c.reset} v${report.version} ${c.dim}${report.timestamp}${c.reset}`);
|
|
101
|
+
lines.push('');
|
|
102
|
+
// Grade box
|
|
103
|
+
lines.push(`${gc}${c.bold}${GRADE_ART[report.grade]}${c.reset}`);
|
|
104
|
+
lines.push('');
|
|
105
|
+
// Summary bar
|
|
106
|
+
const summaryParts = [];
|
|
107
|
+
if (report.bySeverity.critical > 0)
|
|
108
|
+
summaryParts.push(`${c.red}${report.bySeverity.critical} critical${c.reset}`);
|
|
109
|
+
if (report.bySeverity.high > 0)
|
|
110
|
+
summaryParts.push(`${c.brightRed}${report.bySeverity.high} high${c.reset}`);
|
|
111
|
+
if (report.bySeverity.medium > 0)
|
|
112
|
+
summaryParts.push(`${c.yellow}${report.bySeverity.medium} medium${c.reset}`);
|
|
113
|
+
if (report.bySeverity.low > 0)
|
|
114
|
+
summaryParts.push(`${c.cyan}${report.bySeverity.low} low${c.reset}`);
|
|
115
|
+
if (report.bySeverity.info > 0)
|
|
116
|
+
summaryParts.push(`${c.dim}${report.bySeverity.info} info${c.reset}`);
|
|
117
|
+
if (summaryParts.length > 0) {
|
|
118
|
+
lines.push(` ${c.bold}Findings:${c.reset} ${summaryParts.join(' ')}`);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
lines.push(` ${c.green}${c.bold}No security issues found.${c.reset}`);
|
|
122
|
+
}
|
|
123
|
+
lines.push('');
|
|
124
|
+
// Scanner results
|
|
125
|
+
lines.push(` ${c.bold}Scanners${c.reset}`);
|
|
126
|
+
lines.push(` ${'─'.repeat(60)}`);
|
|
127
|
+
for (const scanner of report.scanners) {
|
|
128
|
+
const findingCount = scanner.findings.length;
|
|
129
|
+
const icon = scanner.skipped ? `${c.dim}○${c.reset}` :
|
|
130
|
+
findingCount === 0 ? `${c.green}✓${c.reset}` :
|
|
131
|
+
`${c.red}✗${c.reset}`;
|
|
132
|
+
const countStr = scanner.skipped ? `${c.dim}skipped${c.reset}` :
|
|
133
|
+
findingCount === 0 ? `${c.green}clean${c.reset}` :
|
|
134
|
+
`${c.red}${findingCount} finding(s)${c.reset}`;
|
|
135
|
+
const scannedStr = scanner.skipped ? '' : ` (${scanner.itemsScanned} scanned)`;
|
|
136
|
+
const timeStr = `${c.dim}${scanner.durationMs}ms${c.reset}`;
|
|
137
|
+
lines.push(` ${icon} ${scanner.name.padEnd(25)} ${countStr}${scannedStr} ${timeStr}`);
|
|
138
|
+
if (scanner.skipped && scanner.skipReason) {
|
|
139
|
+
lines.push(` ${c.dim}${scanner.skipReason}${c.reset}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
lines.push('');
|
|
143
|
+
// Detailed findings (grouped by severity)
|
|
144
|
+
const severityOrder = ['critical', 'high', 'medium', 'low', 'info'];
|
|
145
|
+
const hasPrintableFindings = report.findings.some(f => f.severity !== 'info');
|
|
146
|
+
if (hasPrintableFindings) {
|
|
147
|
+
lines.push(` ${c.bold}Findings${c.reset}`);
|
|
148
|
+
lines.push(` ${'─'.repeat(60)}`);
|
|
149
|
+
for (const severity of severityOrder) {
|
|
150
|
+
const findings = report.findings.filter(f => f.severity === severity);
|
|
151
|
+
if (findings.length === 0)
|
|
152
|
+
continue;
|
|
153
|
+
// Skip info findings in the detailed view (they're noise)
|
|
154
|
+
if (severity === 'info')
|
|
155
|
+
continue;
|
|
156
|
+
for (const finding of findings) {
|
|
157
|
+
const sc = severityColour(finding.severity);
|
|
158
|
+
const icon = severityIcon(finding.severity);
|
|
159
|
+
lines.push(` ${sc}[${icon}] ${finding.severity.toUpperCase().padEnd(8)}${c.reset} ${finding.title}`);
|
|
160
|
+
lines.push(` ${c.dim}${finding.description}${c.reset}`);
|
|
161
|
+
if (finding.filePath) {
|
|
162
|
+
lines.push(` ${c.dim}File: ${finding.filePath}${c.reset}`);
|
|
163
|
+
}
|
|
164
|
+
if (finding.matchedText) {
|
|
165
|
+
lines.push(` ${c.dim}Match: ${finding.matchedText}${c.reset}`);
|
|
166
|
+
}
|
|
167
|
+
lines.push('');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// Footer
|
|
172
|
+
lines.push(` ${'─'.repeat(60)}`);
|
|
173
|
+
lines.push(` ${c.dim}Scan completed in ${report.durationMs}ms${c.reset}`);
|
|
174
|
+
lines.push(` ${c.dim}Learn more: https://shieldcortex.ai/docs/audit${c.reset}`);
|
|
175
|
+
lines.push('');
|
|
176
|
+
return lines.join('\n');
|
|
177
|
+
}
|
|
178
|
+
// ── Markdown Formatter (for CI/GitHub) ──
|
|
179
|
+
/**
|
|
180
|
+
* Format an audit report as markdown (for GitHub PR comments).
|
|
181
|
+
*/
|
|
182
|
+
export function formatMarkdownReport(report) {
|
|
183
|
+
const lines = [];
|
|
184
|
+
const gradeEmoji = report.grade === 'A' ? '🟢' :
|
|
185
|
+
report.grade === 'B' ? '🔵' :
|
|
186
|
+
report.grade === 'C' ? '🟡' :
|
|
187
|
+
report.grade === 'D' ? '🟠' : '🔴';
|
|
188
|
+
lines.push(`## ${gradeEmoji} ShieldCortex Security Audit — Grade ${report.grade}`);
|
|
189
|
+
lines.push('');
|
|
190
|
+
// Summary table
|
|
191
|
+
if (report.totalFindings > 0) {
|
|
192
|
+
lines.push('| Severity | Count |');
|
|
193
|
+
lines.push('|----------|-------|');
|
|
194
|
+
if (report.bySeverity.critical > 0)
|
|
195
|
+
lines.push(`| 🔴 Critical | ${report.bySeverity.critical} |`);
|
|
196
|
+
if (report.bySeverity.high > 0)
|
|
197
|
+
lines.push(`| 🟠 High | ${report.bySeverity.high} |`);
|
|
198
|
+
if (report.bySeverity.medium > 0)
|
|
199
|
+
lines.push(`| 🟡 Medium | ${report.bySeverity.medium} |`);
|
|
200
|
+
if (report.bySeverity.low > 0)
|
|
201
|
+
lines.push(`| 🔵 Low | ${report.bySeverity.low} |`);
|
|
202
|
+
if (report.bySeverity.info > 0)
|
|
203
|
+
lines.push(`| ⚪ Info | ${report.bySeverity.info} |`);
|
|
204
|
+
lines.push('');
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
lines.push('**No security issues found.** All checks passed.');
|
|
208
|
+
lines.push('');
|
|
209
|
+
}
|
|
210
|
+
// Findings
|
|
211
|
+
const printable = report.findings.filter(f => f.severity !== 'info');
|
|
212
|
+
if (printable.length > 0) {
|
|
213
|
+
lines.push('### Findings');
|
|
214
|
+
lines.push('');
|
|
215
|
+
for (const finding of printable) {
|
|
216
|
+
const icon = finding.severity === 'critical' ? '🔴' :
|
|
217
|
+
finding.severity === 'high' ? '🟠' :
|
|
218
|
+
finding.severity === 'medium' ? '🟡' : '🔵';
|
|
219
|
+
lines.push(`- ${icon} **${finding.title}**`);
|
|
220
|
+
lines.push(` ${finding.description}`);
|
|
221
|
+
if (finding.filePath)
|
|
222
|
+
lines.push(` 📄 \`${finding.filePath}\``);
|
|
223
|
+
lines.push('');
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
lines.push('---');
|
|
227
|
+
lines.push(`*Scanned by [ShieldCortex](https://shieldcortex.ai) v${report.version} in ${report.durationMs}ms*`);
|
|
228
|
+
return lines.join('\n');
|
|
229
|
+
}
|
|
230
|
+
// ── JSON Formatter ──
|
|
231
|
+
/**
|
|
232
|
+
* Format an audit report as JSON (for programmatic consumption).
|
|
233
|
+
*/
|
|
234
|
+
export function formatJsonReport(report) {
|
|
235
|
+
return JSON.stringify(report, null, 2);
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=report-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-formatter.js","sourceRoot":"","sources":["../../src/audit/report-formatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,qBAAqB;AAErB,MAAM,CAAC,GAAG;IACR,KAAK,EAAI,SAAS;IAClB,IAAI,EAAK,SAAS;IAClB,GAAG,EAAM,SAAS;IAClB,GAAG,EAAM,UAAU;IACnB,KAAK,EAAI,UAAU;IACnB,MAAM,EAAG,UAAU;IACnB,IAAI,EAAK,UAAU;IACnB,OAAO,EAAE,UAAU;IACnB,IAAI,EAAK,UAAU;IACnB,KAAK,EAAI,UAAU;IACnB,KAAK,EAAI,UAAU;IACnB,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAC,UAAU;IACnB,SAAS,EAAE,UAAU;CACtB,CAAC;AAEF,sBAAsB;AAEtB,SAAS,WAAW,CAAC,KAAiB;IACpC,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;QACzB,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC;QACxB,KAAK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AgB,CAAC,MAAmB;IAClD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules File Scanner
|
|
3
|
+
*
|
|
4
|
+
* Scans AI agent instruction/rules files for:
|
|
5
|
+
* - Unicode-hidden backdoors (the "Rules File Backdoor" attack)
|
|
6
|
+
* - Prompt injection in project configs
|
|
7
|
+
* - Malicious instructions in CLAUDE.md, .cursorrules, etc.
|
|
8
|
+
*
|
|
9
|
+
* Reuses the skill scanner for threat detection and adds Unicode
|
|
10
|
+
* analysis that the skill scanner doesn't cover in depth.
|
|
11
|
+
*/
|
|
12
|
+
import type { ScannerResult } from './types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Run the rules file scanner.
|
|
15
|
+
*/
|
|
16
|
+
export declare function scanRulesFiles(): ScannerResult;
|
|
17
|
+
//# sourceMappingURL=rules-file-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules-file-scanner.d.ts","sourceRoot":"","sources":["../../src/audit/rules-file-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAgB,aAAa,EAAiB,MAAM,YAAY,CAAC;AAsJ7E;;GAEG;AACH,wBAAgB,cAAc,IAAI,aAAa,CA8B9C"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules File Scanner
|
|
3
|
+
*
|
|
4
|
+
* Scans AI agent instruction/rules files for:
|
|
5
|
+
* - Unicode-hidden backdoors (the "Rules File Backdoor" attack)
|
|
6
|
+
* - Prompt injection in project configs
|
|
7
|
+
* - Malicious instructions in CLAUDE.md, .cursorrules, etc.
|
|
8
|
+
*
|
|
9
|
+
* Reuses the skill scanner for threat detection and adds Unicode
|
|
10
|
+
* analysis that the skill scanner doesn't cover in depth.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readFileSync, statSync } from 'fs';
|
|
13
|
+
import { join, basename } from 'path';
|
|
14
|
+
import { scanSkill, discoverSkillFiles } from '../defence/skill-scanner/index.js';
|
|
15
|
+
const LEARN_MORE = 'https://shieldcortex.ai/docs/threats/rules-file-backdoor';
|
|
16
|
+
// ── Unicode Backdoor Detection ──
|
|
17
|
+
/** Invisible Unicode characters used in the "Rules File Backdoor" attack. */
|
|
18
|
+
const INVISIBLE_UNICODE = [
|
|
19
|
+
{ char: '\u200B', name: 'Zero-Width Space', codePoint: 'U+200B' },
|
|
20
|
+
{ char: '\u200C', name: 'Zero-Width Non-Joiner', codePoint: 'U+200C' },
|
|
21
|
+
{ char: '\u200D', name: 'Zero-Width Joiner', codePoint: 'U+200D' },
|
|
22
|
+
{ char: '\u200E', name: 'Left-to-Right Mark', codePoint: 'U+200E' },
|
|
23
|
+
{ char: '\u200F', name: 'Right-to-Left Mark', codePoint: 'U+200F' },
|
|
24
|
+
{ char: '\u2060', name: 'Word Joiner', codePoint: 'U+2060' },
|
|
25
|
+
{ char: '\u2061', name: 'Function Application', codePoint: 'U+2061' },
|
|
26
|
+
{ char: '\u2062', name: 'Invisible Times', codePoint: 'U+2062' },
|
|
27
|
+
{ char: '\u2063', name: 'Invisible Separator', codePoint: 'U+2063' },
|
|
28
|
+
{ char: '\u2064', name: 'Invisible Plus', codePoint: 'U+2064' },
|
|
29
|
+
{ char: '\uFEFF', name: 'Zero-Width No-Break Space (BOM)', codePoint: 'U+FEFF' },
|
|
30
|
+
// Bidirectional text control characters
|
|
31
|
+
{ char: '\u202A', name: 'Left-to-Right Embedding', codePoint: 'U+202A' },
|
|
32
|
+
{ char: '\u202B', name: 'Right-to-Left Embedding', codePoint: 'U+202B' },
|
|
33
|
+
{ char: '\u202C', name: 'Pop Directional Formatting', codePoint: 'U+202C' },
|
|
34
|
+
{ char: '\u202D', name: 'Left-to-Right Override', codePoint: 'U+202D' },
|
|
35
|
+
{ char: '\u202E', name: 'Right-to-Left Override', codePoint: 'U+202E' },
|
|
36
|
+
{ char: '\u2066', name: 'Left-to-Right Isolate', codePoint: 'U+2066' },
|
|
37
|
+
{ char: '\u2067', name: 'Right-to-Left Isolate', codePoint: 'U+2067' },
|
|
38
|
+
{ char: '\u2068', name: 'First Strong Isolate', codePoint: 'U+2068' },
|
|
39
|
+
{ char: '\u2069', name: 'Pop Directional Isolate', codePoint: 'U+2069' },
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* Detect invisible Unicode characters in content.
|
|
43
|
+
* BOM at position 0 is normal; all others are suspicious.
|
|
44
|
+
*/
|
|
45
|
+
function detectInvisibleUnicode(content) {
|
|
46
|
+
const found = [];
|
|
47
|
+
for (const { char, name, codePoint } of INVISIBLE_UNICODE) {
|
|
48
|
+
let count = 0;
|
|
49
|
+
let pos = -1;
|
|
50
|
+
while ((pos = content.indexOf(char, pos + 1)) !== -1) {
|
|
51
|
+
// Skip BOM at position 0
|
|
52
|
+
if (codePoint === 'U+FEFF' && pos === 0)
|
|
53
|
+
continue;
|
|
54
|
+
count++;
|
|
55
|
+
}
|
|
56
|
+
if (count > 0) {
|
|
57
|
+
found.push({ codePoint, name, count });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return found;
|
|
61
|
+
}
|
|
62
|
+
/** Maximum file size for rules files (512 KB) */
|
|
63
|
+
const MAX_FILE_SIZE = 512 * 1024;
|
|
64
|
+
/**
|
|
65
|
+
* Discover additional rules files beyond what discoverSkillFiles finds.
|
|
66
|
+
* Specifically looks for project-level configs that may have been
|
|
67
|
+
* added by malicious PRs.
|
|
68
|
+
*/
|
|
69
|
+
function discoverExtraRulesFiles() {
|
|
70
|
+
const files = [];
|
|
71
|
+
const cwd = process.cwd();
|
|
72
|
+
const candidates = [
|
|
73
|
+
join(cwd, '.github', 'copilot-instructions.md'),
|
|
74
|
+
join(cwd, '.github', 'CLAUDE.md'),
|
|
75
|
+
join(cwd, '.cursorrules'),
|
|
76
|
+
join(cwd, '.windsurfrules'),
|
|
77
|
+
join(cwd, '.clinerules'),
|
|
78
|
+
join(cwd, 'CLAUDE.md'),
|
|
79
|
+
join(cwd, '.aider.conf.yml'),
|
|
80
|
+
join(cwd, '.continue', 'config.json'),
|
|
81
|
+
];
|
|
82
|
+
for (const p of candidates) {
|
|
83
|
+
try {
|
|
84
|
+
if (existsSync(p) && statSync(p).isFile() && statSync(p).size <= MAX_FILE_SIZE) {
|
|
85
|
+
files.push(p);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch { /* ignore */ }
|
|
89
|
+
}
|
|
90
|
+
return files;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Scan a single rules/instruction file.
|
|
94
|
+
*/
|
|
95
|
+
function scanRulesFile(filePath) {
|
|
96
|
+
const findings = [];
|
|
97
|
+
const fileName = basename(filePath);
|
|
98
|
+
let content;
|
|
99
|
+
try {
|
|
100
|
+
content = readFileSync(filePath, 'utf-8');
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return findings;
|
|
104
|
+
}
|
|
105
|
+
if (!content.trim())
|
|
106
|
+
return findings;
|
|
107
|
+
// 1. Unicode backdoor detection
|
|
108
|
+
const unicodeFindings = detectInvisibleUnicode(content);
|
|
109
|
+
if (unicodeFindings.length > 0) {
|
|
110
|
+
const totalHidden = unicodeFindings.reduce((sum, f) => sum + f.count, 0);
|
|
111
|
+
const types = unicodeFindings.map(f => `${f.name} (${f.codePoint}) ×${f.count}`).join(', ');
|
|
112
|
+
findings.push({
|
|
113
|
+
scanner: 'rules',
|
|
114
|
+
severity: 'critical',
|
|
115
|
+
title: `Unicode backdoor in ${fileName}`,
|
|
116
|
+
description: `Found ${totalHidden} invisible Unicode character(s) that could hide malicious instructions from code review. This matches the "Rules File Backdoor" attack pattern (CVE-2025-54135). Characters: ${types}`,
|
|
117
|
+
filePath,
|
|
118
|
+
learnMoreUrl: LEARN_MORE,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
// 2. Run through the skill scanner for threat pattern detection
|
|
122
|
+
try {
|
|
123
|
+
const result = scanSkill(filePath);
|
|
124
|
+
if (!result.safe) {
|
|
125
|
+
for (const finding of result.findings) {
|
|
126
|
+
const severity = finding.severity === 'critical' ? 'critical' :
|
|
127
|
+
finding.severity === 'high' ? 'high' :
|
|
128
|
+
finding.severity === 'medium' ? 'medium' : 'low';
|
|
129
|
+
findings.push({
|
|
130
|
+
scanner: 'rules',
|
|
131
|
+
severity,
|
|
132
|
+
title: `${finding.pattern} in ${fileName}`,
|
|
133
|
+
description: finding.description,
|
|
134
|
+
filePath,
|
|
135
|
+
matchedText: finding.matchedText,
|
|
136
|
+
learnMoreUrl: LEARN_MORE,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// Skill scanner errors shouldn't crash the audit
|
|
143
|
+
}
|
|
144
|
+
return findings;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Run the rules file scanner.
|
|
148
|
+
*/
|
|
149
|
+
export function scanRulesFiles() {
|
|
150
|
+
const start = Date.now();
|
|
151
|
+
// Combine skill-discovered files with extra project-level files
|
|
152
|
+
const skillFiles = discoverSkillFiles();
|
|
153
|
+
const extraFiles = discoverExtraRulesFiles();
|
|
154
|
+
const allFiles = [...new Set([...skillFiles, ...extraFiles])];
|
|
155
|
+
if (allFiles.length === 0) {
|
|
156
|
+
return {
|
|
157
|
+
name: 'Rules File Scanner',
|
|
158
|
+
itemsScanned: 0,
|
|
159
|
+
findings: [],
|
|
160
|
+
durationMs: Date.now() - start,
|
|
161
|
+
skipped: true,
|
|
162
|
+
skipReason: 'No agent instruction/rules files found',
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const allFindings = [];
|
|
166
|
+
for (const file of allFiles) {
|
|
167
|
+
allFindings.push(...scanRulesFile(file));
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
name: 'Rules File Scanner',
|
|
171
|
+
itemsScanned: allFiles.length,
|
|
172
|
+
findings: allFindings,
|
|
173
|
+
durationMs: Date.now() - start,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=rules-file-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules-file-scanner.js","sourceRoot":"","sources":["../../src/audit/rules-file-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAElF,MAAM,UAAU,GAAG,0DAA0D,CAAC;AAE9E,mCAAmC;AAEnC,6EAA6E;AAC7E,MAAM,iBAAiB,GAA6D;IAClF,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,QAAQ,EAAE;IACjE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,uBAAuB,EAAE,SAAS,EAAE,QAAQ,EAAE;IACtE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAmB,EAAE,SAAS,EAAE,QAAQ,EAAE;IAClE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,oBAAoB,EAAE,SAAS,EAAE,QAAQ,EAAE;IACnE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,oBAAoB,EAAE,SAAS,EAAE,QAAQ,EAAE;IACnE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE;IAC5D,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,sBAAsB,EAAE,SAAS,EAAE,QAAQ,EAAE;IACrE,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AU,GAAG,uBAAuB,EAAE,CAAC;IAC7C,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,UAAU,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IAE9D,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO;YACL,IAAI,EAAE,oBAAoB;YAC1B,YAAY,EAAE,CAAC;YACf,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;YAC9B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,wCAAwC;SACrD,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAmB,EAAE,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,WAAW,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO;QACL,IAAI,EAAE,oBAAoB;QAC1B,YAAY,EAAE,QAAQ,CAAC,MAAM;QAC7B,QAAQ,EAAE,WAAW;QACrB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;KAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Types
|
|
3
|
+
*
|
|
4
|
+
* Shared types for the `shieldcortex audit` command — a comprehensive
|
|
5
|
+
* security scanner for AI agent environments.
|
|
6
|
+
*/
|
|
7
|
+
export type AuditSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
|
|
8
|
+
export interface AuditFinding {
|
|
9
|
+
/** Scanner that produced this finding */
|
|
10
|
+
scanner: string;
|
|
11
|
+
/** Severity of the finding */
|
|
12
|
+
severity: AuditSeverity;
|
|
13
|
+
/** Short human-readable title */
|
|
14
|
+
title: string;
|
|
15
|
+
/** Detailed description of the finding */
|
|
16
|
+
description: string;
|
|
17
|
+
/** File path where the finding was located (if applicable) */
|
|
18
|
+
filePath?: string;
|
|
19
|
+
/** Matched text snippet (truncated) */
|
|
20
|
+
matchedText?: string;
|
|
21
|
+
/** URL to learn more about this finding category */
|
|
22
|
+
learnMoreUrl?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ScannerResult {
|
|
25
|
+
/** Scanner name for display */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Number of items scanned */
|
|
28
|
+
itemsScanned: number;
|
|
29
|
+
/** Findings from this scanner */
|
|
30
|
+
findings: AuditFinding[];
|
|
31
|
+
/** Duration in milliseconds */
|
|
32
|
+
durationMs: number;
|
|
33
|
+
/** Whether the scanner was skipped (e.g., no files found) */
|
|
34
|
+
skipped?: boolean;
|
|
35
|
+
/** Reason for skipping */
|
|
36
|
+
skipReason?: string;
|
|
37
|
+
}
|
|
38
|
+
export type AuditGrade = 'A' | 'B' | 'C' | 'D' | 'F';
|
|
39
|
+
export interface AuditReport {
|
|
40
|
+
/** Security grade (A-F) */
|
|
41
|
+
grade: AuditGrade;
|
|
42
|
+
/** Total number of findings */
|
|
43
|
+
totalFindings: number;
|
|
44
|
+
/** Findings by severity */
|
|
45
|
+
bySeverity: Record<AuditSeverity, number>;
|
|
46
|
+
/** Results from each scanner */
|
|
47
|
+
scanners: ScannerResult[];
|
|
48
|
+
/** All findings sorted by severity */
|
|
49
|
+
findings: AuditFinding[];
|
|
50
|
+
/** Duration of the full audit in milliseconds */
|
|
51
|
+
durationMs: number;
|
|
52
|
+
/** Timestamp of the audit */
|
|
53
|
+
timestamp: string;
|
|
54
|
+
/** ShieldCortex version */
|
|
55
|
+
version: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Calculate grade from findings.
|
|
59
|
+
*
|
|
60
|
+
* A = no findings above info
|
|
61
|
+
* B = only low/info findings
|
|
62
|
+
* C = medium findings present
|
|
63
|
+
* D = high findings present
|
|
64
|
+
* F = critical findings present
|
|
65
|
+
*/
|
|
66
|
+
export declare function calculateGrade(bySeverity: Record<AuditSeverity, number>): AuditGrade;
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/audit/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAI5E,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,QAAQ,EAAE,aAAa,CAAC;IACxB,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAID,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0BAA0B;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAID,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAErD,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,+BAA+B;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAC1C,gCAAgC;IAChC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,sCAAsC;IACtC,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG,UAAU,CAMpF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Types
|
|
3
|
+
*
|
|
4
|
+
* Shared types for the `shieldcortex audit` command — a comprehensive
|
|
5
|
+
* security scanner for AI agent environments.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Calculate grade from findings.
|
|
9
|
+
*
|
|
10
|
+
* A = no findings above info
|
|
11
|
+
* B = only low/info findings
|
|
12
|
+
* C = medium findings present
|
|
13
|
+
* D = high findings present
|
|
14
|
+
* F = critical findings present
|
|
15
|
+
*/
|
|
16
|
+
export function calculateGrade(bySeverity) {
|
|
17
|
+
if (bySeverity.critical > 0)
|
|
18
|
+
return 'F';
|
|
19
|
+
if (bySeverity.high > 0)
|
|
20
|
+
return 'D';
|
|
21
|
+
if (bySeverity.medium > 0)
|
|
22
|
+
return 'C';
|
|
23
|
+
if (bySeverity.low > 0)
|
|
24
|
+
return 'B';
|
|
25
|
+
return 'A';
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/audit/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiEH;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,UAAyC;IACtE,IAAI,UAAU,CAAC,QAAQ,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACxC,IAAI,UAAU,CAAC,IAAI,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACpC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACtC,IAAI,UAAU,CAAC,GAAG,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACnC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit CLI Command
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates all security scanners and produces a comprehensive
|
|
5
|
+
* audit report of the developer's AI agent environment.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* npx shieldcortex audit # Terminal report
|
|
9
|
+
* npx shieldcortex audit --json # JSON output
|
|
10
|
+
* npx shieldcortex audit --markdown # Markdown output
|
|
11
|
+
* npx shieldcortex audit --ci # CI mode (exit code reflects grade)
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Run the full audit.
|
|
15
|
+
*/
|
|
16
|
+
export declare function handleAuditCommand(args: string[]): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/cli/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA+BH;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuGtE"}
|