deployready 0.1.3 → 0.3.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/README.md +75 -9
- package/dist/active/accessControl.js +77 -0
- package/dist/active/accessControl.js.map +1 -0
- package/dist/active/httpAdapter.js +54 -0
- package/dist/active/httpAdapter.js.map +1 -0
- package/dist/active/jwt.js +48 -0
- package/dist/active/jwt.js.map +1 -0
- package/dist/active/requestPlan.js +78 -0
- package/dist/active/requestPlan.js.map +1 -0
- package/dist/active/runner.js +184 -0
- package/dist/active/runner.js.map +1 -0
- package/dist/active/tamper.js +94 -0
- package/dist/active/tamper.js.map +1 -0
- package/dist/active/tokenHelp.js +33 -0
- package/dist/active/tokenHelp.js.map +1 -0
- package/dist/active/types.js +3 -0
- package/dist/active/types.js.map +1 -0
- package/dist/agent/FileEditor.js +91 -17
- package/dist/agent/FileEditor.js.map +1 -1
- package/dist/agent/FixManager.js +128 -4
- package/dist/agent/FixManager.js.map +1 -1
- package/dist/agent/lineFixers.js +29 -0
- package/dist/agent/lineFixers.js.map +1 -0
- package/dist/ai/CliHandler.js +80 -0
- package/dist/ai/CliHandler.js.map +1 -0
- package/dist/ai/ModelRouter.js +42 -1
- package/dist/ai/ModelRouter.js.map +1 -1
- package/dist/ai/cli/argv.js +67 -0
- package/dist/ai/cli/argv.js.map +1 -0
- package/dist/ai/cli/env.js +46 -0
- package/dist/ai/cli/env.js.map +1 -0
- package/dist/ai/cli/errors.js +15 -0
- package/dist/ai/cli/errors.js.map +1 -0
- package/dist/ai/cli/parseOutput.js +151 -0
- package/dist/ai/cli/parseOutput.js.map +1 -0
- package/dist/ai/cli/providers.js +30 -0
- package/dist/ai/cli/providers.js.map +1 -0
- package/dist/ai/cli/ready.js +121 -0
- package/dist/ai/cli/ready.js.map +1 -0
- package/dist/ai/cli/resolve.js +108 -0
- package/dist/ai/cli/resolve.js.map +1 -0
- package/dist/ai/cli/runCli.js +265 -0
- package/dist/ai/cli/runCli.js.map +1 -0
- package/dist/ai/parseAiResponse.js +24 -11
- package/dist/ai/parseAiResponse.js.map +1 -1
- package/dist/ai/verifyAiFindings.js +106 -0
- package/dist/ai/verifyAiFindings.js.map +1 -0
- package/dist/analysis/ScoreCalculator.js +22 -2
- package/dist/analysis/ScoreCalculator.js.map +1 -1
- package/dist/analysis/SeverityScorer.js +6 -0
- package/dist/analysis/SeverityScorer.js.map +1 -1
- package/dist/analysis/VulnerabilityDetector.js +39 -7
- package/dist/analysis/VulnerabilityDetector.js.map +1 -1
- package/dist/analysis/rls.js +32 -0
- package/dist/analysis/rls.js.map +1 -0
- package/dist/analysis/rules.js +89 -1
- package/dist/analysis/rules.js.map +1 -1
- package/dist/cli/Commands.js +83 -2
- package/dist/cli/Commands.js.map +1 -1
- package/dist/cli/InteractiveShell.js +132 -33
- package/dist/cli/InteractiveShell.js.map +1 -1
- package/dist/cli/Onboarding.js +13 -1
- package/dist/cli/Onboarding.js.map +1 -1
- package/dist/cli/cliSetup.js +48 -0
- package/dist/cli/cliSetup.js.map +1 -0
- package/dist/config/ConfigManager.js +11 -0
- package/dist/config/ConfigManager.js.map +1 -1
- package/dist/core/CiGate.js +80 -13
- package/dist/core/CiGate.js.map +1 -1
- package/dist/core/Orchestrator.js +211 -15
- package/dist/core/Orchestrator.js.map +1 -1
- package/dist/core/Verifier.js +7 -1
- package/dist/core/Verifier.js.map +1 -1
- package/dist/deploy/PlatformRecommender.js +110 -0
- package/dist/deploy/PlatformRecommender.js.map +1 -0
- package/dist/dynamic/DynamicTester.js +92 -8
- package/dist/dynamic/DynamicTester.js.map +1 -1
- package/dist/dynamic/EndpointMapper.js +54 -24
- package/dist/dynamic/EndpointMapper.js.map +1 -1
- package/dist/dynamic/LocalhostDetector.js +11 -23
- package/dist/dynamic/LocalhostDetector.js.map +1 -1
- package/dist/dynamic/SecurityTester.js +55 -10
- package/dist/dynamic/SecurityTester.js.map +1 -1
- package/dist/dynamic/adminEvidence.js +47 -0
- package/dist/dynamic/adminEvidence.js.map +1 -0
- package/dist/dynamic/advertised.js +293 -0
- package/dist/dynamic/advertised.js.map +1 -0
- package/dist/dynamic/catchAll.js +57 -0
- package/dist/dynamic/catchAll.js.map +1 -0
- package/dist/dynamic/commonPaths/evidence.js +112 -0
- package/dist/dynamic/commonPaths/evidence.js.map +1 -0
- package/dist/dynamic/commonPaths/prober.js +210 -0
- package/dist/dynamic/commonPaths/prober.js.map +1 -0
- package/dist/dynamic/commonPaths/signatures.js +381 -0
- package/dist/dynamic/commonPaths/signatures.js.map +1 -0
- package/dist/parser/CodeParser.js +138 -28
- package/dist/parser/CodeParser.js.map +1 -1
- package/dist/parser/adapters/BabelAdapter.js +558 -27
- package/dist/parser/adapters/BabelAdapter.js.map +1 -1
- package/dist/parser/adapters/PythonAdapter.js +360 -14
- package/dist/parser/adapters/PythonAdapter.js.map +1 -1
- package/dist/parser/adapters/authMiddleware.js +256 -0
- package/dist/parser/adapters/authMiddleware.js.map +1 -0
- package/dist/parser/adapters/nest.js +162 -0
- package/dist/parser/adapters/nest.js.map +1 -0
- package/dist/parser/miniYaml.js +308 -0
- package/dist/parser/miniYaml.js.map +1 -0
- package/dist/parser/nextRoutes.js +204 -0
- package/dist/parser/nextRoutes.js.map +1 -0
- package/dist/parser/openapi.js +180 -0
- package/dist/parser/openapi.js.map +1 -0
- package/dist/parser/pathUtil.js +22 -0
- package/dist/parser/pathUtil.js.map +1 -0
- package/dist/ui/DeploymentGuide.js +107 -29
- package/dist/ui/DeploymentGuide.js.map +1 -1
- package/dist/ui/ExportManager.js +61 -3
- package/dist/ui/ExportManager.js.map +1 -1
- package/dist/ui/HtmlReporter.js +113 -31
- package/dist/ui/HtmlReporter.js.map +1 -1
- package/dist/ui/IssuePresenter.js +54 -5
- package/dist/ui/IssuePresenter.js.map +1 -1
- package/dist/ui/commonPathSection.js +42 -0
- package/dist/ui/commonPathSection.js.map +1 -0
- package/dist/utils/FileWalker.js +126 -17
- package/dist/utils/FileWalker.js.map +1 -1
- package/dist/utils/GitIgnore.js +162 -0
- package/dist/utils/GitIgnore.js.map +1 -0
- package/dist/utils/finding.js +5 -0
- package/dist/utils/finding.js.map +1 -1
- package/dist/utils/logger.js +4 -0
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/sanitize.js +30 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/docs/sample-config.json +2 -1
- package/package.json +12 -4
package/dist/ui/HtmlReporter.js
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HtmlReporter = void 0;
|
|
4
|
+
const PlatformRecommender_1 = require("../deploy/PlatformRecommender");
|
|
5
|
+
const ScoreCalculator_1 = require("../analysis/ScoreCalculator");
|
|
6
|
+
const commonPathSection_1 = require("./commonPathSection");
|
|
7
|
+
const SITE = 'https://www.deployready.dev/';
|
|
8
|
+
const ACCENT = '#00ff88';
|
|
4
9
|
const COLORS = {
|
|
5
10
|
critical: '#ef4444',
|
|
6
11
|
warning: '#f59e0b',
|
|
7
12
|
info: '#3b82f6',
|
|
8
13
|
};
|
|
14
|
+
const UNVERIFIED_COLOR = '#a78bfa';
|
|
15
|
+
const NOTE_COLOR = '#9ca3af';
|
|
9
16
|
class HtmlReporter {
|
|
10
17
|
static render(report) {
|
|
11
|
-
const scoreColor = report.score >= 80 ?
|
|
18
|
+
const scoreColor = report.score >= 80 ? ACCENT : report.score >= 50 ? '#f59e0b' : '#ef4444';
|
|
12
19
|
const { critical, warning, info } = report.summary;
|
|
20
|
+
const unverified = report.findings.filter(ScoreCalculator_1.isUnverified).length;
|
|
21
|
+
const notes = report.findings.filter(ScoreCalculator_1.isNote).length;
|
|
22
|
+
const deploy = renderDeploy(report);
|
|
23
|
+
const probeSection = renderCommonPaths(report);
|
|
13
24
|
return `<!DOCTYPE html>
|
|
14
25
|
<html lang="en">
|
|
15
26
|
<head>
|
|
@@ -20,7 +31,7 @@ class HtmlReporter {
|
|
|
20
31
|
</head>
|
|
21
32
|
<body>
|
|
22
33
|
<header class="topbar">
|
|
23
|
-
<
|
|
34
|
+
<a class="brand" href="${SITE}" target="_blank" rel="noopener noreferrer">⚡ <span>Deploy</span>Ready</a>
|
|
24
35
|
<div class="meta">${esc(report.stack.stack)} · ${esc(report.stack.language)} · ${report.graph.fileCount} files · ${report.graph.routes.length} routes</div>
|
|
25
36
|
</header>
|
|
26
37
|
|
|
@@ -37,25 +48,33 @@ class HtmlReporter {
|
|
|
37
48
|
${card('Critical', critical, COLORS.critical)}
|
|
38
49
|
${card('Warning', warning, COLORS.warning)}
|
|
39
50
|
${card('Info', info, COLORS.info)}
|
|
51
|
+
${unverified ? card('AI (unverified)', unverified, UNVERIFIED_COLOR) : ''}
|
|
52
|
+
${notes ? card('Notes', notes, NOTE_COLOR) : ''}
|
|
40
53
|
</div>
|
|
41
54
|
</div>
|
|
42
55
|
</section>
|
|
43
56
|
|
|
44
|
-
${report.aiSummary ? `<section class="ai"><h2>🤖 AI Summary</h2><p>${esc(report.aiSummary)}</p></section>` : ''}
|
|
57
|
+
${report.aiSummary ? `<section class="ai"><h2>🤖 AI Summary (unverified)</h2><p>${esc(report.aiSummary)}</p></section>` : ''}
|
|
58
|
+
|
|
59
|
+
${deploy}
|
|
45
60
|
|
|
46
61
|
<section class="filters">
|
|
47
|
-
<button class="f active" data-f="all">All (${report.
|
|
62
|
+
<button class="f active" data-f="all">All (${report.findings.length})</button>
|
|
48
63
|
<button class="f" data-f="critical">Critical (${critical})</button>
|
|
49
64
|
<button class="f" data-f="warning">Warning (${warning})</button>
|
|
50
65
|
<button class="f" data-f="info">Info (${info})</button>
|
|
66
|
+
${unverified ? `<button class="f" data-f="unverified">AI suggestions, unverified (${unverified})</button>` : ''}
|
|
67
|
+
${notes ? `<button class="f" data-f="note">Notes, not scored (${notes})</button>` : ''}
|
|
51
68
|
</section>
|
|
52
69
|
|
|
53
70
|
<section class="findings">
|
|
54
|
-
${report.findings.map(findingCard).join('\n') || '<p class="empty">✓ No issues found.</p>'}
|
|
71
|
+
${(0, commonPathSection_1.normalFindings)(report.findings).map(findingCard).join('\n') || (probeSection ? '' : '<p class="empty">✓ No issues found.</p>')}
|
|
55
72
|
</section>
|
|
73
|
+
|
|
74
|
+
${probeSection}
|
|
56
75
|
</main>
|
|
57
76
|
|
|
58
|
-
<footer>Generated by DeployReady · local-first production-readiness scanner</footer>
|
|
77
|
+
<footer>Generated by <a href="${SITE}" target="_blank" rel="noopener noreferrer">DeployReady</a> · local-first production-readiness scanner</footer>
|
|
59
78
|
|
|
60
79
|
<script>
|
|
61
80
|
(function(){
|
|
@@ -74,15 +93,61 @@ class HtmlReporter {
|
|
|
74
93
|
}
|
|
75
94
|
}
|
|
76
95
|
exports.HtmlReporter = HtmlReporter;
|
|
96
|
+
function renderDeploy(report) {
|
|
97
|
+
let rec;
|
|
98
|
+
try {
|
|
99
|
+
rec = PlatformRecommender_1.PlatformRecommender.recommend({ stack: report.stack, graph: report.graph });
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return '';
|
|
103
|
+
}
|
|
104
|
+
const pick = (p) => `<a class="plat" href="${esc(p.url)}" target="_blank" rel="noopener noreferrer">${esc(p.name)}${p.free ? '<span class="free">free</span>' : ''}</a>`;
|
|
105
|
+
const alts = rec.alternatives.map(pick).join(' ');
|
|
106
|
+
const split = rec.split.recommended
|
|
107
|
+
? `<p class="split">✂ <strong>Split recommended:</strong> ${esc(rec.split.reason)}${rec.split.frontend ? ` <br/>frontend → ${pick(rec.split.frontend)}` : ''}${rec.split.backend ? ` · backend → ${pick(rec.split.backend)}` : ''}</p>`
|
|
108
|
+
: '';
|
|
109
|
+
const notes = rec.notes.length
|
|
110
|
+
? `<ul class="notes">${rec.notes.map((n) => `<li>${esc(n)}</li>`).join('')}</ul>`
|
|
111
|
+
: '';
|
|
112
|
+
return `<section class="deploy">
|
|
113
|
+
<h2>🚀 Recommended deployment <span class="kind">${esc(rec.size)} ${esc(rec.kind)} app</span></h2>
|
|
114
|
+
<p class="primary">${pick(rec.primary)} <span class="why">${esc(rec.primary.reason)}</span></p>
|
|
115
|
+
${alts ? `<p class="alts"><span class="lbl">Alternatives:</span> ${alts}</p>` : ''}
|
|
116
|
+
${split}
|
|
117
|
+
${notes}
|
|
118
|
+
</section>`;
|
|
119
|
+
}
|
|
120
|
+
function renderCommonPaths(report) {
|
|
121
|
+
const cp = (0, commonPathSection_1.commonPathReport)(report);
|
|
122
|
+
if (!cp)
|
|
123
|
+
return '';
|
|
124
|
+
const guessed = (0, commonPathSection_1.guessedFindings)(report.findings);
|
|
125
|
+
const rows = cp.probed
|
|
126
|
+
.map((p) => `<tr class="o-${esc(p.outcome)}"><td><code>${esc(p.path)}</code></td><td>${p.status ?? '-'}</td><td>${esc(commonPathSection_1.OUTCOME_LABEL[p.outcome])}</td><td>${esc(p.reason)}</td></tr>`)
|
|
127
|
+
.join('\n');
|
|
128
|
+
return `<section class="probe">
|
|
129
|
+
<h2>🔎 ${esc(commonPathSection_1.COMMON_PATH_TITLE)}</h2>
|
|
130
|
+
<p class="p-meta">Target <code>${esc(cp.target)}</code> · ${esc((0, commonPathSection_1.controlLine)(cp))} · ${esc((0, commonPathSection_1.capLine)(cp))}. Guessed findings count in the summary and score at their capped severity.</p>
|
|
131
|
+
${cp.aborted ? `<p class="p-warn">Aborted: ${esc(cp.aborted)}</p>` : ''}
|
|
132
|
+
${guessed.length ? guessed.map(findingCard).join('\n') : '<p class="p-meta">No guessed path was proven exposed.</p>'}
|
|
133
|
+
<table class="paths"><thead><tr><th>Requested path</th><th>Status</th><th>Outcome</th><th>Reason</th></tr></thead><tbody>
|
|
134
|
+
${rows}
|
|
135
|
+
</tbody></table>
|
|
136
|
+
${cp.covered?.length ? `<p class="p-meta">Covered by the normal scan, not requested again: ${cp.covered.map((c) => `<code>${esc(c)}</code>`).join(', ')}</p>` : ''}
|
|
137
|
+
</section>`;
|
|
138
|
+
}
|
|
77
139
|
function card(label, n, color) {
|
|
78
140
|
return `<div class="stat"><div class="stat-n" style="color:${color}">${n}</div><div class="stat-l">${label}</div></div>`;
|
|
79
141
|
}
|
|
80
142
|
function findingCard(f) {
|
|
81
143
|
const loc = f.endpoint ?? (f.file ? `${f.file}${f.line ? `:${f.line}` : ''}` : '');
|
|
82
144
|
const refs = [f.owasp, f.cwe].filter(Boolean).map((r) => `<span class="ref">${esc(r)}</span>`).join('');
|
|
83
|
-
|
|
145
|
+
const unverified = (0, ScoreCalculator_1.isUnverified)(f);
|
|
146
|
+
const note = !unverified && (0, ScoreCalculator_1.isNote)(f);
|
|
147
|
+
const color = unverified ? UNVERIFIED_COLOR : note ? NOTE_COLOR : COLORS[f.severity];
|
|
148
|
+
return `<article class="finding" data-sev="${unverified ? 'unverified' : note ? 'note' : f.severity}" style="--c:${color}">
|
|
84
149
|
<div class="f-head">
|
|
85
|
-
<span class="badge" style="background:${
|
|
150
|
+
<span class="badge" style="background:${color}">${unverified ? 'UNVERIFIED' : note ? 'NOTE' : f.severity.toUpperCase()}</span>
|
|
86
151
|
<span class="f-title">${esc(f.title)}</span>
|
|
87
152
|
<span class="src">${esc(f.source)}</span>
|
|
88
153
|
</div>
|
|
@@ -104,37 +169,54 @@ function esc(s) {
|
|
|
104
169
|
const CSS = `
|
|
105
170
|
:root{color-scheme:dark}
|
|
106
171
|
*{box-sizing:border-box}
|
|
107
|
-
body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;background:#
|
|
108
|
-
|
|
109
|
-
.
|
|
110
|
-
.
|
|
172
|
+
body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;background:#0a0a0a;color:#f0f0f0;line-height:1.5;background-image:radial-gradient(circle,rgba(255,255,255,0.04) 1px,transparent 1px);background-size:32px 32px}
|
|
173
|
+
a{color:${ACCENT};text-decoration:none}
|
|
174
|
+
.topbar{display:flex;justify-content:space-between;align-items:center;padding:16px 28px;background:#111111;border-bottom:1px solid rgba(255,255,255,0.08)}
|
|
175
|
+
.brand{font-weight:700;font-size:20px;color:#f0f0f0;font-family:ui-monospace,"JetBrains Mono",monospace}.brand span{color:${ACCENT}}
|
|
176
|
+
.meta{color:#888;font-size:13px;font-family:ui-monospace,monospace}
|
|
111
177
|
main{max-width:980px;margin:0 auto;padding:28px}
|
|
112
178
|
.hero{display:flex;gap:32px;align-items:center;flex-wrap:wrap;margin-bottom:28px}
|
|
113
|
-
.gauge{width:160px;height:160px;border-radius:50%;background:conic-gradient(var(--c) calc(var(--p)*1%),#
|
|
114
|
-
.gauge-inner{width:124px;height:124px;border-radius:50%;background:#
|
|
115
|
-
.score{font-size:44px;font-weight:800;line-height:1}.score-label{color:#
|
|
116
|
-
.hero-side h1{margin:0 0 4px;font-size:24px}
|
|
179
|
+
.gauge{width:160px;height:160px;border-radius:50%;background:conic-gradient(var(--c) calc(var(--p)*1%),#1a1a1a 0);display:flex;align-items:center;justify-content:center;flex:0 0 auto;box-shadow:0 0 40px rgba(0,255,136,0.12)}
|
|
180
|
+
.gauge-inner{width:124px;height:124px;border-radius:50%;background:#0a0a0a;display:flex;flex-direction:column;align-items:center;justify-content:center}
|
|
181
|
+
.score{font-size:44px;font-weight:800;line-height:1;font-family:ui-monospace,monospace}.score-label{color:#888;font-size:13px}
|
|
182
|
+
.hero-side h1{margin:0 0 4px;font-size:24px;font-family:ui-monospace,"JetBrains Mono",monospace}
|
|
117
183
|
.target{margin:0;color:#cbd5e1;font-family:ui-monospace,monospace;font-size:13px;word-break:break-all}
|
|
118
|
-
.when{margin:2px 0 14px;color:#
|
|
184
|
+
.when{margin:2px 0 14px;color:#666;font-size:12px}
|
|
119
185
|
.cards{display:flex;gap:12px}
|
|
120
|
-
.stat{background:#
|
|
121
|
-
.stat-n{font-size:26px;font-weight:800}.stat-l{color:#
|
|
122
|
-
.ai{background:#
|
|
123
|
-
.ai h2{margin:0 0 6px;font-size:16px;color
|
|
186
|
+
.stat{background:#111111;border:1px solid rgba(255,255,255,0.08);border-radius:10px;padding:10px 18px;text-align:center;min-width:84px}
|
|
187
|
+
.stat-n{font-size:26px;font-weight:800;font-family:ui-monospace,monospace}.stat-l{color:#888;font-size:12px;text-transform:uppercase;letter-spacing:.04em}
|
|
188
|
+
.ai{background:#0c1f15;border:1px solid rgba(0,255,136,0.25);border-radius:12px;padding:16px 20px;margin-bottom:24px}
|
|
189
|
+
.ai h2{margin:0 0 6px;font-size:16px;color:${ACCENT}}.ai p{margin:0;color:#cbd5e1}
|
|
190
|
+
.deploy{background:#111111;border:1px solid rgba(255,255,255,0.08);border-left:3px solid ${ACCENT};border-radius:12px;padding:16px 20px;margin-bottom:24px}
|
|
191
|
+
.deploy h2{margin:0 0 10px;font-size:16px;color:#f0f0f0}
|
|
192
|
+
.deploy .kind{color:#888;font-size:12px;text-transform:uppercase;letter-spacing:.04em;margin-left:8px;font-weight:400}
|
|
193
|
+
.deploy .primary{margin:0 0 8px;font-size:15px}.deploy .why{color:#888;font-size:13px}
|
|
194
|
+
.deploy .alts{margin:8px 0;color:#888;font-size:13px}.deploy .lbl{margin-right:6px}
|
|
195
|
+
.plat{display:inline-flex;align-items:center;gap:6px;background:#1a1a1a;border:1px solid rgba(255,255,255,0.1);border-radius:999px;padding:3px 12px;margin:2px 4px 2px 0;font-size:13px;color:#f0f0f0}
|
|
196
|
+
.plat .free{background:${ACCENT};color:#0a0a0a;font-weight:700;font-size:10px;border-radius:6px;padding:1px 6px;text-transform:uppercase}
|
|
197
|
+
.deploy .split{margin:10px 0 4px;color:#f59e0b;font-size:13px}
|
|
198
|
+
.deploy .notes{margin:8px 0 0;padding-left:18px;color:#888;font-size:12px}
|
|
124
199
|
.filters{display:flex;gap:8px;margin-bottom:16px;flex-wrap:wrap}
|
|
125
|
-
.f{background:#
|
|
126
|
-
.f.active{background
|
|
127
|
-
.finding{background:#
|
|
200
|
+
.f{background:#111111;color:#cbd5e1;border:1px solid rgba(255,255,255,0.1);border-radius:999px;padding:6px 14px;font-size:13px;cursor:pointer}
|
|
201
|
+
.f.active{background:${ACCENT};color:#0a0a0a;border-color:${ACCENT};font-weight:600}
|
|
202
|
+
.finding{background:#111111;border:1px solid rgba(255,255,255,0.08);border-left:4px solid var(--c);border-radius:10px;padding:14px 18px;margin-bottom:12px}
|
|
128
203
|
.f-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
|
|
129
|
-
.badge{color:#
|
|
130
|
-
.f-title{font-weight:600}.src{margin-left:auto;color:#
|
|
204
|
+
.badge{color:#0a0a0a;font-weight:700;font-size:11px;padding:2px 8px;border-radius:6px}
|
|
205
|
+
.f-title{font-weight:600}.src{margin-left:auto;color:#666;font-size:12px;text-transform:uppercase}
|
|
131
206
|
.f-meta{margin:6px 0;display:flex;gap:8px;align-items:center;flex-wrap:wrap}
|
|
132
|
-
.f-meta code{background:#
|
|
133
|
-
.ref{background:#
|
|
207
|
+
.f-meta code{background:#0a0a0a;border:1px solid rgba(255,255,255,0.08);border-radius:6px;padding:2px 8px;font-size:12px;color:${ACCENT}}
|
|
208
|
+
.ref{background:#1a1a1a;color:#888;border-radius:6px;padding:2px 8px;font-size:11px}
|
|
134
209
|
.f-desc{margin:6px 0;color:#cbd5e1}
|
|
135
|
-
.f-ev{background:#
|
|
210
|
+
.f-ev{background:#0a0a0a;border:1px solid rgba(255,255,255,0.08);border-radius:8px;padding:8px 12px;overflow:auto;font-size:12px;color:#fca5a5;margin:8px 0}
|
|
136
211
|
.f-fix{margin:6px 0 0;color:#a7f3d0;font-size:14px}
|
|
137
|
-
.
|
|
138
|
-
|
|
212
|
+
.probe{margin-top:28px;border-top:1px solid rgba(255,255,255,0.08);padding-top:16px}
|
|
213
|
+
.probe h2{margin:0 0 6px;font-size:16px}
|
|
214
|
+
.p-meta{color:#888;font-size:13px;margin:4px 0 12px}.p-meta code{color:${ACCENT}}.p-warn{color:#f59e0b;font-size:13px}
|
|
215
|
+
.paths{width:100%;border-collapse:collapse;font-size:13px;margin-top:8px}
|
|
216
|
+
.paths th,.paths td{text-align:left;padding:6px 10px;border-bottom:1px solid rgba(255,255,255,0.08);vertical-align:top}
|
|
217
|
+
.paths th{color:#888;font-weight:600}.paths code{color:${ACCENT}}
|
|
218
|
+
.o-found td{color:#fca5a5}
|
|
219
|
+
.empty{color:${ACCENT};font-size:18px;text-align:center;padding:40px}
|
|
220
|
+
footer{text-align:center;color:#555;font-size:12px;padding:24px}
|
|
139
221
|
`;
|
|
140
222
|
//# sourceMappingURL=HtmlReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlReporter.js","sourceRoot":"","sources":["../../src/ui/HtmlReporter.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"HtmlReporter.js","sourceRoot":"","sources":["../../src/ui/HtmlReporter.ts"],"names":[],"mappings":";;;AAWA,uEAAuF;AACvF,iEAAmE;AACnE,2DAAgJ;AAEhJ,MAAM,IAAI,GAAG,8BAA8B,CAAC;AAC5C,MAAM,MAAM,GAAG,SAAS,CAAC;AAEzB,MAAM,MAAM,GAA6B;IACvC,QAAQ,EAAE,SAAS;IACnB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,SAAS;CAChB,CAAC;AACF,MAAM,gBAAgB,GAAG,SAAS,CAAC;AACnC,MAAM,UAAU,GAAG,SAAS,CAAC;AAE7B,MAAa,YAAY;IACvB,MAAM,CAAC,MAAM,CAAC,MAAkB;QAC9B,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5F,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;QACnD,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,8BAAY,CAAC,CAAC,MAA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;sBAC/C,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC;IACpC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;2CACvB,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC;WACrD,CAAC;AACZ,CAAC;AAED,mDAAmD;AACnD,SAAS,GAAG,CAAC,CAAS;IACpB,OAAO,MAAM,CAAC,CAAC,CAAC;SACb,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,GAAG,GAAG;;;;UAIF,MAAM;;4HAE4G,MAAM;;;;;;;;;;;;;;6CAcrF,MAAM;2FACwC,MAAM;;;;;;yBAMxE,MAAM;;;;;uBAKR,MAAM,+BAA+B,MAAM;;;;;;iIAM+D,MAAM;;;;;;;yEAO9D,MAAM;;;yDAGtB,MAAM;;eAEhD,MAAM;;CAEpB,CAAC"}
|
|
@@ -10,6 +10,8 @@ exports.IssuePresenter = void 0;
|
|
|
10
10
|
* findings only ever carry redacted evidence.
|
|
11
11
|
*/
|
|
12
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const ScoreCalculator_1 = require("../analysis/ScoreCalculator");
|
|
14
|
+
const commonPathSection_1 = require("./commonPathSection");
|
|
13
15
|
const BADGE = {
|
|
14
16
|
critical: chalk_1.default.red.bold('CRITICAL'),
|
|
15
17
|
warning: chalk_1.default.yellow.bold('WARNING'),
|
|
@@ -29,30 +31,77 @@ class IssuePresenter {
|
|
|
29
31
|
console.log(` Stack: ${report.stack.stack} (${report.stack.language}) · Files: ${report.graph.fileCount} · Routes: ${report.graph.routes.length}`);
|
|
30
32
|
console.log(bar + '\n');
|
|
31
33
|
if (report.aiSummary) {
|
|
32
|
-
console.log(chalk_1.default.cyan('🤖 AI Summary'));
|
|
34
|
+
console.log(chalk_1.default.cyan('🤖 AI Summary (unverified)'));
|
|
33
35
|
console.log(' ' + report.aiSummary.replace(/\n/g, '\n ') + '\n');
|
|
34
36
|
}
|
|
35
37
|
for (const sev of ['critical', 'warning', 'info']) {
|
|
36
|
-
const group = report.findings.filter((f) => f.severity === sev);
|
|
38
|
+
const group = report.findings.filter((f) => f.severity === sev && !(0, ScoreCalculator_1.isNonScored)(f) && !(0, commonPathSection_1.isGuessed)(f));
|
|
37
39
|
if (!group.length)
|
|
38
40
|
continue;
|
|
39
41
|
console.log(HEADER[sev](`${icon(sev)} ${sev.toUpperCase()} (${group.length})`));
|
|
40
42
|
group.forEach((f, i) => IssuePresenter.printFinding(f, i + 1));
|
|
41
43
|
console.log('');
|
|
42
44
|
}
|
|
43
|
-
|
|
45
|
+
const suggestions = report.findings.filter(ScoreCalculator_1.isUnverified);
|
|
46
|
+
const notes = report.findings.filter(ScoreCalculator_1.isNote);
|
|
47
|
+
if (suggestions.length) {
|
|
48
|
+
console.log(chalk_1.default.magenta.bold(`🤖 AI SUGGESTIONS (unverified, not scored) (${suggestions.length})`));
|
|
49
|
+
suggestions.forEach((f, i) => IssuePresenter.printFinding(f, i + 1));
|
|
50
|
+
console.log('');
|
|
51
|
+
}
|
|
52
|
+
if (notes.length) {
|
|
53
|
+
console.log(chalk_1.default.gray.bold(`ℹ️ NOTES (not scored) (${notes.length})`));
|
|
54
|
+
notes.forEach((f, i) => IssuePresenter.printFinding(f, i + 1));
|
|
55
|
+
console.log('');
|
|
56
|
+
}
|
|
57
|
+
IssuePresenter.printCommonPaths(report);
|
|
58
|
+
if (report.summary.total === 0 && suggestions.length === 0 && notes.length === 0) {
|
|
44
59
|
console.log(chalk_1.default.green('✓ No issues detected. Nice work — but keep validating in CI.\n'));
|
|
45
60
|
}
|
|
46
61
|
else {
|
|
47
62
|
console.log(chalk_1.default.bold(`Summary: ${report.summary.critical} critical, ${report.summary.warning} warnings, ${report.summary.info} info`) + '\n');
|
|
63
|
+
if (suggestions.length) {
|
|
64
|
+
console.log(chalk_1.default.magenta(`${suggestions.length} AI suggestions (unverified, not scored)\n`));
|
|
65
|
+
}
|
|
66
|
+
if (notes.length)
|
|
67
|
+
console.log(chalk_1.default.gray(`${notes.length} notes (not scored)\n`));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
static printCommonPaths(report) {
|
|
71
|
+
const cp = (0, commonPathSection_1.commonPathReport)(report);
|
|
72
|
+
if (!cp)
|
|
73
|
+
return;
|
|
74
|
+
const guessed = (0, commonPathSection_1.guessedFindings)(report.findings);
|
|
75
|
+
console.log(chalk_1.default.cyan.bold(`🔎 ${commonPathSection_1.COMMON_PATH_TITLE}`));
|
|
76
|
+
console.log(chalk_1.default.gray(` Target ${cp.target}; ${(0, commonPathSection_1.controlLine)(cp)}; ${(0, commonPathSection_1.capLine)(cp)}.`));
|
|
77
|
+
console.log(chalk_1.default.gray(' Guessed findings count in the summary and score at their capped severity.'));
|
|
78
|
+
if (guessed.length) {
|
|
79
|
+
console.log(` Guessed findings (${guessed.length}):`);
|
|
80
|
+
guessed.forEach((f, i) => IssuePresenter.printFinding(f, i + 1));
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
console.log(' No guessed path was proven exposed.');
|
|
84
|
+
}
|
|
85
|
+
console.log(` Requested paths (${cp.probed.length}):`);
|
|
86
|
+
for (const p of cp.probed) {
|
|
87
|
+
const label = commonPathSection_1.OUTCOME_LABEL[p.outcome].padEnd(10);
|
|
88
|
+
console.log(chalk_1.default.gray(` ${label} GET ${p.path} -> ${p.status ?? 'no response'} ${p.reason}`));
|
|
48
89
|
}
|
|
90
|
+
if (cp.covered?.length)
|
|
91
|
+
console.log(chalk_1.default.gray(` Covered by the normal scan, not requested again: ${cp.covered.join(', ')}`));
|
|
92
|
+
if (cp.aborted)
|
|
93
|
+
console.log(chalk_1.default.yellow(` Aborted: ${cp.aborted}`));
|
|
94
|
+
console.log('');
|
|
49
95
|
}
|
|
50
96
|
static printFinding(f, n) {
|
|
51
97
|
const loc = f.endpoint ?? (f.file ? `${f.file}${f.line ? `:${f.line}` : ''}` : '');
|
|
52
98
|
const refs = [f.owasp, f.cwe].filter(Boolean).join(' ');
|
|
53
99
|
console.log(` ${n}. ${f.title}${loc ? chalk_1.default.gray(` — ${loc}`) : ''}`);
|
|
54
|
-
|
|
55
|
-
|
|
100
|
+
const badge = (0, ScoreCalculator_1.isUnverified)(f) ? chalk_1.default.magenta.bold('UNVERIFIED') : (0, ScoreCalculator_1.isNote)(f) ? chalk_1.default.gray.bold('NOTE') : BADGE[f.severity];
|
|
101
|
+
if (refs || (0, ScoreCalculator_1.isUnverified)(f) || (0, ScoreCalculator_1.isNote)(f))
|
|
102
|
+
console.log(chalk_1.default.gray(` ${refs ? `${refs} · ` : ''}${badge} ${chalk_1.default.gray(`[${f.source}]`)}`));
|
|
103
|
+
if ((0, ScoreCalculator_1.isNonScored)(f) && f.description)
|
|
104
|
+
console.log(chalk_1.default.gray(` ${f.description}`));
|
|
56
105
|
if (f.evidence)
|
|
57
106
|
console.log(chalk_1.default.gray(` evidence: ${f.evidence}`));
|
|
58
107
|
console.log(chalk_1.default.gray(` fix: ${f.recommendation}`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IssuePresenter.js","sourceRoot":"","sources":["../../src/ui/IssuePresenter.ts"],"names":[],"mappings":";;;;;;AAAA;;;;GAIG;AACH,kDAA0B;
|
|
1
|
+
{"version":3,"file":"IssuePresenter.js","sourceRoot":"","sources":["../../src/ui/IssuePresenter.ts"],"names":[],"mappings":";;;;;;AAAA;;;;GAIG;AACH,kDAA0B;AAC1B,iEAAgF;AAEhF,2DAA2I;AAE3I,MAAM,KAAK,GAA6B;IACtC,QAAQ,EAAE,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC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SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5C,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,eAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7C,OAAO,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OUTCOME_LABEL = exports.COMMON_PATH_TITLE = void 0;
|
|
4
|
+
exports.isGuessed = isGuessed;
|
|
5
|
+
exports.normalFindings = normalFindings;
|
|
6
|
+
exports.guessedFindings = guessedFindings;
|
|
7
|
+
exports.commonPathReport = commonPathReport;
|
|
8
|
+
exports.controlLine = controlLine;
|
|
9
|
+
exports.capLine = capLine;
|
|
10
|
+
exports.probedLine = probedLine;
|
|
11
|
+
exports.COMMON_PATH_TITLE = 'Common-path probe (opt-in): guessed paths, lower confidence';
|
|
12
|
+
exports.OUTCOME_LABEL = {
|
|
13
|
+
found: 'found',
|
|
14
|
+
'not-found': 'not found',
|
|
15
|
+
protected: 'protected',
|
|
16
|
+
'not-proven': 'not proven',
|
|
17
|
+
error: 'error',
|
|
18
|
+
};
|
|
19
|
+
/** Guessed findings are listed in their own section, never in the normal severity lists. */
|
|
20
|
+
function isGuessed(f) {
|
|
21
|
+
return f.guessed === true;
|
|
22
|
+
}
|
|
23
|
+
function normalFindings(findings) {
|
|
24
|
+
return findings.filter((f) => !isGuessed(f));
|
|
25
|
+
}
|
|
26
|
+
function guessedFindings(findings) {
|
|
27
|
+
return findings.filter(isGuessed);
|
|
28
|
+
}
|
|
29
|
+
/** The probe section is shown only when the probe actually ran. */
|
|
30
|
+
function commonPathReport(report) {
|
|
31
|
+
return report.dynamic?.commonPaths;
|
|
32
|
+
}
|
|
33
|
+
function controlLine(cp) {
|
|
34
|
+
return `control GET ${cp.control.path} -> ${cp.control.status ?? 'no response'}`;
|
|
35
|
+
}
|
|
36
|
+
function capLine(cp) {
|
|
37
|
+
return `request cap: ${cp.cap} (including the control); ${cp.probed.length} well-known path(s) requested`;
|
|
38
|
+
}
|
|
39
|
+
function probedLine(p) {
|
|
40
|
+
return `${exports.OUTCOME_LABEL[p.outcome]}: GET ${p.path} -> ${p.status ?? 'no response'} (${p.reason})`;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=commonPathSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonPathSection.js","sourceRoot":"","sources":["../../src/ui/commonPathSection.ts"],"names":[],"mappings":";;;AAiBA,8BAEC;AAED,wCAEC;AAED,0CAEC;AAGD,4CAEC;AAED,kCAEC;AAED,0BAEC;AAED,gCAEC;AAtCY,QAAA,iBAAiB,GAAG,6DAA6D,CAAC;AAElF,QAAA,aAAa,GAAsC;IAC9D,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,WAAW;IACxB,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,YAAY;IAC1B,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,4FAA4F;AAC5F,SAAgB,SAAS,CAAC,CAA2B;IACnD,OAAO,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC;AAC5B,CAAC;AAED,SAAgB,cAAc,CAAC,QAAmB;IAChD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAgB,eAAe,CAAC,QAAmB;IACjD,OAAO,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC;AAED,mEAAmE;AACnE,SAAgB,gBAAgB,CAAC,MAAkB;IACjD,OAAO,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC;AACrC,CAAC;AAED,SAAgB,WAAW,CAAC,EAAoB;IAC9C,OAAO,eAAe,EAAE,CAAC,OAAO,CAAC,IAAI,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,aAAa,EAAE,CAAC;AACnF,CAAC;AAED,SAAgB,OAAO,CAAC,EAAoB;IAC1C,OAAO,gBAAgB,EAAE,CAAC,GAAG,6BAA6B,EAAE,CAAC,MAAM,CAAC,MAAM,+BAA+B,CAAC;AAC5G,CAAC;AAED,SAAgB,UAAU,CAAC,CAAqC;IAC9D,OAAO,GAAG,qBAAa,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,MAAM,IAAI,aAAa,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;AACpG,CAAC"}
|
package/dist/utils/FileWalker.js
CHANGED
|
@@ -34,6 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.FileWalker = void 0;
|
|
37
|
+
exports.isEnvFile = isEnvFile;
|
|
38
|
+
exports.isEnvTemplate = isEnvTemplate;
|
|
39
|
+
exports.isSpecFileName = isSpecFileName;
|
|
37
40
|
/**
|
|
38
41
|
* Recursively find source files within a project, confined to the project root.
|
|
39
42
|
*
|
|
@@ -44,6 +47,7 @@ exports.FileWalker = void 0;
|
|
|
44
47
|
*/
|
|
45
48
|
const fs = __importStar(require("fs/promises"));
|
|
46
49
|
const path = __importStar(require("path"));
|
|
50
|
+
const GitIgnore_1 = require("./GitIgnore");
|
|
47
51
|
const SKIP_DIRS = new Set([
|
|
48
52
|
'node_modules',
|
|
49
53
|
'.git',
|
|
@@ -58,12 +62,10 @@ const SKIP_DIRS = new Set([
|
|
|
58
62
|
'venv',
|
|
59
63
|
'.cache',
|
|
60
64
|
]);
|
|
61
|
-
const
|
|
65
|
+
const WORKFLOW_EXTS = new Set(['.yml', '.yaml']);
|
|
66
|
+
const SOURCE_EXTS = new Set(['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs', '.py', '.php', '.sql']);
|
|
62
67
|
/** Config-like files we want to inspect even though they aren't "source". */
|
|
63
68
|
const EXTRA_FILES = new Set([
|
|
64
|
-
'.env',
|
|
65
|
-
'.env.local',
|
|
66
|
-
'.env.production',
|
|
67
69
|
'.gitignore', // needed so the env-not-ignored check can see ignore rules
|
|
68
70
|
'package.json',
|
|
69
71
|
'requirements.txt',
|
|
@@ -72,24 +74,62 @@ const EXTRA_FILES = new Set([
|
|
|
72
74
|
'next.config.js',
|
|
73
75
|
'next.config.mjs',
|
|
74
76
|
]);
|
|
77
|
+
const ENV_TEMPLATES = new Set(['.env.example', '.env.sample', '.env.template']);
|
|
78
|
+
/** `.env` or any `.env.<suffix>` (staging, development, local, ...). */
|
|
79
|
+
function isEnvFile(name) {
|
|
80
|
+
return name === '.env' || name.startsWith('.env.');
|
|
81
|
+
}
|
|
82
|
+
/** Committed-by-design placeholder env files; not secrets, never reported as committed. */
|
|
83
|
+
function isEnvTemplate(name) {
|
|
84
|
+
return ENV_TEMPLATES.has(name);
|
|
85
|
+
}
|
|
75
86
|
const MAX_FILE_BYTES = 2 * 1024 * 1024; // 2 MB — skip larger (generated/minified) files
|
|
76
87
|
const MAX_FILES = 20000; // cap for very large monorepos; keeps the scan bounded
|
|
88
|
+
const SPEC_FILE = /^(openapi|swagger)\.(json|ya?ml)$/i;
|
|
89
|
+
/** `openapi.{json,yaml,yml}` / `swagger.{json,yaml,yml}`: the project's own API description. */
|
|
90
|
+
function isSpecFileName(name) {
|
|
91
|
+
return SPEC_FILE.test(name);
|
|
92
|
+
}
|
|
77
93
|
class FileWalker {
|
|
78
94
|
/**
|
|
79
95
|
* Walk `root` and return source + relevant config files.
|
|
80
96
|
* @throws if the path does not exist or is not a directory.
|
|
81
97
|
*/
|
|
82
98
|
static async walk(root) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
99
|
+
return (await FileWalker.walkWithStats(root)).files;
|
|
100
|
+
}
|
|
101
|
+
/** Like `walk`, also reporting how many paths were skipped because of .gitignore rules. */
|
|
102
|
+
static async walkWithStats(root) {
|
|
103
|
+
const realRoot = await FileWalker.resolveRoot(root);
|
|
104
|
+
const result = { files: [], specFiles: [], skippedSpecs: [], ignoredCount: 0 };
|
|
105
|
+
await FileWalker.walkDir(realRoot, '', realRoot, result, []);
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
/** Resolve `root` to its real directory path, with one-line errors fit to print as-is. */
|
|
109
|
+
static async resolveRoot(root) {
|
|
110
|
+
let realRoot;
|
|
111
|
+
try {
|
|
112
|
+
realRoot = await fs.realpath(path.resolve(root));
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
const code = err.code;
|
|
116
|
+
if (code === 'ENOENT' || code === 'ENOTDIR')
|
|
117
|
+
throw new Error(`Path not found: ${root}`);
|
|
118
|
+
throw new Error(`Cannot access path: ${root}${code ? ` (${code})` : ''}`);
|
|
87
119
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
120
|
+
let isDir = false;
|
|
121
|
+
try {
|
|
122
|
+
isDir = (await fs.stat(realRoot)).isDirectory();
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
throw new Error(`Cannot access path: ${root}`);
|
|
126
|
+
}
|
|
127
|
+
if (!isDir)
|
|
128
|
+
throw new Error(`Not a directory: ${root}`);
|
|
129
|
+
return realRoot;
|
|
91
130
|
}
|
|
92
|
-
static async walkDir(dir, realRoot,
|
|
131
|
+
static async walkDir(dir, relDir, realRoot, result, parentScopes) {
|
|
132
|
+
const out = result.files;
|
|
93
133
|
if (out.length >= MAX_FILES)
|
|
94
134
|
return;
|
|
95
135
|
let entries;
|
|
@@ -99,23 +139,59 @@ class FileWalker {
|
|
|
99
139
|
catch {
|
|
100
140
|
return; // Unreadable dir (permissions) — skip silently.
|
|
101
141
|
}
|
|
142
|
+
let scopes = parentScopes;
|
|
143
|
+
if (entries.some((e) => e.name === '.gitignore' && e.isFile())) {
|
|
144
|
+
const rules = await FileWalker.readIgnoreRules(path.join(dir, '.gitignore'));
|
|
145
|
+
if (rules.length > 0)
|
|
146
|
+
scopes = [...parentScopes, { base: relDir, rules }];
|
|
147
|
+
}
|
|
102
148
|
for (const entry of entries) {
|
|
103
149
|
if (out.length >= MAX_FILES)
|
|
104
150
|
return;
|
|
105
151
|
const abs = path.join(dir, entry.name);
|
|
152
|
+
const relPath = relDir ? `${relDir}/${entry.name}` : entry.name;
|
|
106
153
|
if (entry.isDirectory()) {
|
|
107
|
-
if (SKIP_DIRS.has(entry.name)
|
|
154
|
+
if (SKIP_DIRS.has(entry.name))
|
|
155
|
+
continue;
|
|
156
|
+
if (entry.name.startsWith('.git') && relPath !== '.github')
|
|
157
|
+
continue;
|
|
158
|
+
if (relDir === '.github' && entry.name !== 'workflows')
|
|
159
|
+
continue;
|
|
160
|
+
if (relDir === '.github/workflows')
|
|
108
161
|
continue;
|
|
109
|
-
|
|
162
|
+
if (relPath !== '.github' && relPath !== '.github/workflows' && (0, GitIgnore_1.isIgnored)(scopes, relPath, true)) {
|
|
163
|
+
result.ignoredCount++;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
await FileWalker.walkDir(abs, relPath, realRoot, result, scopes);
|
|
110
167
|
continue;
|
|
111
168
|
}
|
|
112
169
|
if (!entry.isFile())
|
|
113
170
|
continue; // skip sockets, devices, etc.
|
|
171
|
+
if (relDir === '.github')
|
|
172
|
+
continue;
|
|
114
173
|
const ext = path.extname(entry.name).toLowerCase();
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
174
|
+
const inWorkflows = relDir === '.github/workflows';
|
|
175
|
+
if (!inWorkflows && isSpecFileName(entry.name)) {
|
|
176
|
+
await FileWalker.collectSpec(abs, relPath, realRoot, scopes, result);
|
|
118
177
|
continue;
|
|
178
|
+
}
|
|
179
|
+
let protectedFromIgnore = inWorkflows;
|
|
180
|
+
if (inWorkflows) {
|
|
181
|
+
if (!WORKFLOW_EXTS.has(ext))
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
const isSource = SOURCE_EXTS.has(ext);
|
|
186
|
+
const isExtra = EXTRA_FILES.has(entry.name) || isEnvFile(entry.name);
|
|
187
|
+
if (!isSource && !isExtra)
|
|
188
|
+
continue;
|
|
189
|
+
protectedFromIgnore = isExtra;
|
|
190
|
+
}
|
|
191
|
+
if (!protectedFromIgnore && (0, GitIgnore_1.isIgnored)(scopes, relPath, false)) {
|
|
192
|
+
result.ignoredCount++;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
119
195
|
try {
|
|
120
196
|
// Confinement check: ensure the resolved real path stays under root.
|
|
121
197
|
const real = await fs.realpath(abs);
|
|
@@ -132,6 +208,39 @@ class FileWalker {
|
|
|
132
208
|
}
|
|
133
209
|
}
|
|
134
210
|
}
|
|
211
|
+
static async collectSpec(abs, relPath, realRoot, scopes, result) {
|
|
212
|
+
if ((0, GitIgnore_1.isIgnored)(scopes, relPath, false)) {
|
|
213
|
+
result.ignoredCount++;
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
const real = await fs.realpath(abs);
|
|
218
|
+
const rel = path.relative(realRoot, real);
|
|
219
|
+
if (rel.startsWith('..') || path.isAbsolute(rel))
|
|
220
|
+
return;
|
|
221
|
+
const size = (await fs.stat(real)).size;
|
|
222
|
+
const relOut = rel.split(path.sep).join('/');
|
|
223
|
+
if (size > MAX_FILE_BYTES) {
|
|
224
|
+
result.skippedSpecs.push({ relPath: relOut, reason: 'larger than 2 MB' });
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
result.specFiles.push({ absPath: real, relPath: relOut, size });
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
static async readIgnoreRules(file) {
|
|
234
|
+
try {
|
|
235
|
+
const st = await fs.stat(file);
|
|
236
|
+
if (st.size > MAX_FILE_BYTES)
|
|
237
|
+
return [];
|
|
238
|
+
return (0, GitIgnore_1.parseGitignore)(await fs.readFile(file, 'utf8'));
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
return [];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
135
244
|
/** Safely read a walked file's contents as UTF-8. */
|
|
136
245
|
static async read(file) {
|
|
137
246
|
return fs.readFile(file.absPath, 'utf8');
|