@codepulse-oss/core 3.1.4 → 3.1.5
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/__tests__/v3.1.5-power.test.d.ts +2 -0
- package/dist/__tests__/v3.1.5-power.test.d.ts.map +1 -0
- package/dist/__tests__/v3.1.5-power.test.js +168 -0
- package/dist/__tests__/v3.1.5-power.test.js.map +1 -0
- package/dist/audit/explain-simple.d.ts +21 -0
- package/dist/audit/explain-simple.d.ts.map +1 -0
- package/dist/audit/explain-simple.js +91 -0
- package/dist/audit/explain-simple.js.map +1 -0
- package/dist/audit/ignore-manager.d.ts +10 -0
- package/dist/audit/ignore-manager.d.ts.map +1 -0
- package/dist/audit/ignore-manager.js +86 -0
- package/dist/audit/ignore-manager.js.map +1 -0
- package/dist/audit/live-accessibility.d.ts +101 -3
- package/dist/audit/live-accessibility.d.ts.map +1 -1
- package/dist/audit/live-accessibility.js +764 -257
- package/dist/audit/live-accessibility.js.map +1 -1
- package/dist/audit/seo-geo-scanner.d.ts +12 -0
- package/dist/audit/seo-geo-scanner.d.ts.map +1 -1
- package/dist/audit/seo-geo-scanner.js +150 -0
- package/dist/audit/seo-geo-scanner.js.map +1 -1
- package/dist/db/database.d.ts +93 -0
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/database.js +215 -0
- package/dist/db/database.js.map +1 -1
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +30 -0
- package/dist/db/schema.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/output/html-report-writer.d.ts +38 -0
- package/dist/output/html-report-writer.d.ts.map +1 -0
- package/dist/output/html-report-writer.js +150 -0
- package/dist/output/html-report-writer.js.map +1 -0
- package/dist/output/sarif-writer.js +1 -1
- package/dist/sast/sbom-generator.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
function escHtml(val) {
|
|
2
|
+
return String(val ?? '')
|
|
3
|
+
.replace(/&/g, '&')
|
|
4
|
+
.replace(/</g, '<')
|
|
5
|
+
.replace(/>/g, '>')
|
|
6
|
+
.replace(/"/g, '"')
|
|
7
|
+
.replace(/'/g, ''');
|
|
8
|
+
}
|
|
9
|
+
function safeJsonScript(obj) {
|
|
10
|
+
return JSON.stringify(obj).replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generates a 100% self-contained offline interactive HTML report (zero external CDN scripts/fonts).
|
|
14
|
+
*/
|
|
15
|
+
export function buildStandaloneHtmlReport(input) {
|
|
16
|
+
const isSeo = input.kind === 'seo-live';
|
|
17
|
+
const findings = isSeo ? input.result.findings : input.findings;
|
|
18
|
+
const title = input.title || (isSeo ? `CodePulse SEO, GEO & Page Vitals — ${input.result.url}` : `CodePulse Audit — ${input.repoName}`);
|
|
19
|
+
const payloadJson = safeJsonScript({
|
|
20
|
+
kind: input.kind,
|
|
21
|
+
findings: findings.map((f) => ({
|
|
22
|
+
id: f.id,
|
|
23
|
+
severity: f.severity,
|
|
24
|
+
category: f.category,
|
|
25
|
+
rule_id: f.rule_id || '',
|
|
26
|
+
title: f.title,
|
|
27
|
+
body: f.body,
|
|
28
|
+
file: f.file,
|
|
29
|
+
line: f.line_start,
|
|
30
|
+
recommendation: f.recommendation,
|
|
31
|
+
patch: f.patch_suggestion || '',
|
|
32
|
+
verified: f.evidence?.includes('Verified by Agent-2')
|
|
33
|
+
? 'Verified by Agent-2'
|
|
34
|
+
: f.status === 'verified_fixed'
|
|
35
|
+
? 'Fixed'
|
|
36
|
+
: ''
|
|
37
|
+
}))
|
|
38
|
+
});
|
|
39
|
+
const kpiBlock = isSeo
|
|
40
|
+
? `
|
|
41
|
+
<div class="kpis">
|
|
42
|
+
<div class="kpi"><span>Technical SEO</span><strong>${input.result.liveSeoScore}/100</strong></div>
|
|
43
|
+
<div class="kpi"><span>GEO AI Visibility</span><strong>${input.result.geoScore ?? input.result.liveSeoScore}/100</strong></div>
|
|
44
|
+
<div class="kpi"><span>Page Vitals</span><strong>${input.result.vitalsScore ?? 100}/100</strong></div>
|
|
45
|
+
<div class="kpi"><span>WCAG Accessibility</span><strong>${input.result.a11yScore}/100</strong></div>
|
|
46
|
+
</div>
|
|
47
|
+
${input.result.desktopVitals || input.result.mobileVitals
|
|
48
|
+
? `<div class="grid2">
|
|
49
|
+
<div class="card"><h3>Desktop Core Web Vitals (1440×900)</h3><pre>${escHtml(JSON.stringify(input.result.desktopVitals || {}, null, 2))}</pre></div>
|
|
50
|
+
<div class="card"><h3>Mobile Core Web Vitals (390×844)</h3><pre>${escHtml(JSON.stringify(input.result.mobileVitals || {}, null, 2))}</pre></div>
|
|
51
|
+
</div>`
|
|
52
|
+
: ''}`
|
|
53
|
+
: `
|
|
54
|
+
<div class="kpis">
|
|
55
|
+
<div class="kpi"><span>Verdict</span><strong>${escHtml(input.verdict.toUpperCase())}</strong></div>
|
|
56
|
+
<div class="kpi"><span>Pulse Score</span><strong>${input.pulseScore ?? '-'}</strong></div>
|
|
57
|
+
<div class="kpi"><span>Total Findings</span><strong>${findings.length}</strong></div>
|
|
58
|
+
<div class="kpi"><span>Critical / High</span><strong>${findings.filter((f) => f.severity === 'critical' || f.severity === 'high').length}</strong></div>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="card">${escHtml(input.summary)}</div>
|
|
61
|
+
${input.mermaidSvg ? `<div class="card"><h3>Architecture Diagram</h3><div class="mmd-wrap">${input.mermaidSvg}</div></div>` : ''}`;
|
|
62
|
+
return `<!DOCTYPE html>
|
|
63
|
+
<html lang="en" data-theme="dark">
|
|
64
|
+
<head>
|
|
65
|
+
<meta charset="UTF-8" />
|
|
66
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
67
|
+
<title>${escHtml(title)}</title>
|
|
68
|
+
<style>
|
|
69
|
+
:root[data-theme="dark"]{--bg:#0b0d11;--surface:#11141a;--surface2:#171b23;--border:#252c38;--text:#eceff4;--muted:#8b95a5;--accent:#5e6ad2;--red:#f85149;--amber:#d29922;--green:#2ea043;}
|
|
70
|
+
:root[data-theme="light"]{--bg:#f8f9fb;--surface:#ffffff;--surface2:#f1f3f7;--border:#dce2ec;--text:#161922;--muted:#5b6475;--accent:#4f46e5;--red:#cf222e;--amber:#9a6700;--green:#1a7f37;}
|
|
71
|
+
*{box-sizing:border-box} body{margin:0;padding:24px;font-family:system-ui,-apple-system,sans-serif;background:var(--bg);color:var(--text);line-height:1.55;font-size:13.5px}
|
|
72
|
+
.wrap{max-width:1120px;margin:0 auto;display:flex;flex-direction:column;gap:16px}
|
|
73
|
+
header{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;padding-bottom:12px;border-bottom:1px solid var(--border)}
|
|
74
|
+
h1{margin:0;font-size:20px} .muted{color:var(--muted);font-size:12px}
|
|
75
|
+
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}
|
|
76
|
+
.kpi,.card{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:14px}
|
|
77
|
+
.kpi span{display:block;color:var(--muted);font-size:11.5px;text-transform:uppercase;letter-spacing:.04em}
|
|
78
|
+
.kpi strong{font-size:24px;display:block;margin-top:4px}
|
|
79
|
+
.grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:12px}
|
|
80
|
+
.toolbar{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
|
|
81
|
+
input,select,button{font:inherit;color:var(--text);background:var(--surface2);border:1px solid var(--border);border-radius:7px;padding:7px 11px}
|
|
82
|
+
button{cursor:pointer} button.active{border-color:var(--accent);background:var(--accent);color:#fff}
|
|
83
|
+
details.finding{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:12px}
|
|
84
|
+
summary{cursor:pointer;display:flex;justify-content:space-between;align-items:center;gap:10px;font-weight:600}
|
|
85
|
+
.badge{font-size:11px;padding:2px 8px;border-radius:999px;font-weight:700;text-transform:uppercase}
|
|
86
|
+
.sev-critical,.sev-high{background:rgba(248,81,73,.16);color:var(--red)}
|
|
87
|
+
.sev-medium{background:rgba(210,153,34,.18);color:var(--amber)}
|
|
88
|
+
.sev-low{background:rgba(46,160,67,.16);color:var(--green)}
|
|
89
|
+
pre{background:var(--surface2);border:1px solid var(--border);padding:10px;border-radius:7px;overflow:auto;font-size:12px}
|
|
90
|
+
</style>
|
|
91
|
+
</head>
|
|
92
|
+
<body>
|
|
93
|
+
<div class="wrap">
|
|
94
|
+
<header>
|
|
95
|
+
<div>
|
|
96
|
+
<h1>${escHtml(title)}</h1>
|
|
97
|
+
<div class="muted">Offline Standalone Report generated by CodePulse v3.1.5 · ${new Date().toISOString()}</div>
|
|
98
|
+
</div>
|
|
99
|
+
<button type="button" id="themeBtn">Toggle Dark / Light</button>
|
|
100
|
+
</header>
|
|
101
|
+
${kpiBlock}
|
|
102
|
+
<div class="toolbar">
|
|
103
|
+
<input type="text" id="q" placeholder="Search findings by file, rule, or message..." style="flex:1;min-width:220px" />
|
|
104
|
+
<select id="sev">
|
|
105
|
+
<option value="all">All Severities</option>
|
|
106
|
+
<option value="critical">Critical</option>
|
|
107
|
+
<option value="high">High</option>
|
|
108
|
+
<option value="medium">Medium</option>
|
|
109
|
+
<option value="low">Low</option>
|
|
110
|
+
</select>
|
|
111
|
+
<span id="cnt" class="muted"></span>
|
|
112
|
+
</div>
|
|
113
|
+
<div id="list" style="display:flex;flex-direction:column;gap:10px"></div>
|
|
114
|
+
</div>
|
|
115
|
+
<script id="cp-data" type="application/json">${payloadJson}</script>
|
|
116
|
+
<script>
|
|
117
|
+
(function(){
|
|
118
|
+
const raw = JSON.parse(document.getElementById('cp-data').textContent || '{}');
|
|
119
|
+
const items = raw.findings || [];
|
|
120
|
+
const qEl = document.getElementById('q');
|
|
121
|
+
const sevEl = document.getElementById('sev');
|
|
122
|
+
const listEl = document.getElementById('list');
|
|
123
|
+
const cntEl = document.getElementById('cnt');
|
|
124
|
+
document.getElementById('themeBtn').onclick = () => {
|
|
125
|
+
const r = document.documentElement;
|
|
126
|
+
r.setAttribute('data-theme', r.getAttribute('data-theme') === 'dark' ? 'light' : 'dark');
|
|
127
|
+
};
|
|
128
|
+
function esc(s){return String(s||'').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');}
|
|
129
|
+
function render(){
|
|
130
|
+
const q = (qEl.value || '').toLowerCase();
|
|
131
|
+
const s = sevEl.value;
|
|
132
|
+
const filtered = items.filter(f => (s==='all' || f.severity===s) && (!q || (f.title+' '+f.file+' '+f.rule_id+' '+f.body).toLowerCase().includes(q)));
|
|
133
|
+
cntEl.textContent = filtered.length + ' / ' + items.length + ' shown';
|
|
134
|
+
listEl.innerHTML = filtered.length === 0 ? '<div class="card muted">No matching findings.</div>' : filtered.map((f, idx) =>
|
|
135
|
+
'<details class="finding"' + (idx < 5 ? ' open' : '') + '>' +
|
|
136
|
+
'<summary><span>' + esc(f.title) + '</span><span><span class="badge sev-' + esc(f.severity) + '">' + esc(f.severity) + '</span></span></summary>' +
|
|
137
|
+
'<div class="muted" style="margin-top:6px">' + esc(f.file) + ':' + esc(f.line) + (f.rule_id ? ' · ' + esc(f.rule_id) : '') + (f.verified ? ' · ' + esc(f.verified) : '') + '</div>' +
|
|
138
|
+
'<p>' + esc(f.body) + '</p>' +
|
|
139
|
+
'<p><strong>Fix:</strong> ' + esc(f.recommendation) + '</p>' +
|
|
140
|
+
(f.patch ? '<pre>' + esc(f.patch) + '</pre>' : '') +
|
|
141
|
+
'</details>'
|
|
142
|
+
).join('');
|
|
143
|
+
}
|
|
144
|
+
qEl.oninput = render; sevEl.onchange = render; render();
|
|
145
|
+
})();
|
|
146
|
+
</script>
|
|
147
|
+
</body>
|
|
148
|
+
</html>`;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=html-report-writer.js.map
|
|
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QACJ,CAAC,CAAC;;uDAEiD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;2DAChC,KAAK,CAAC,UAAU,IAAI,GAAG;8DACpB,QAAQ,CAAC,MAAM;+DACd,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,UAAU,IAAI,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM;;0BAEtH,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;QACxC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,wEAAwE,KAAK,CAAC,UAAU,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAEvI,OAAO;;;;;SAKA,OAAO,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA6BX,OAAO,CAAC,KAAK,CAAC;qFAC2D,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;;;;IAIzG,QAAQ;;;;;;;;;;;;;;+CAcmC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAiClD,CAAC;AACT,CAAC"}
|
|
@@ -35,7 +35,7 @@ function extractCweTags(f) {
|
|
|
35
35
|
*/
|
|
36
36
|
export function renderSarifReport(output, options = {}) {
|
|
37
37
|
const toolName = options.toolName ?? 'CodePulse';
|
|
38
|
-
const toolVersion = options.toolVersion ?? '3.1.
|
|
38
|
+
const toolVersion = options.toolVersion ?? '3.1.5';
|
|
39
39
|
const infoUri = options.informationUri ?? 'https://github.com/ymorningstar/CodePulse';
|
|
40
40
|
const ruleMap = new Map();
|
|
41
41
|
const results = [];
|
|
@@ -134,7 +134,7 @@ export async function generateProjectSbom(options) {
|
|
|
134
134
|
documentNamespace: `https://github.com/ymorningstar/CodePulse/spdx/${crypto.randomUUID()}`,
|
|
135
135
|
creationInfo: {
|
|
136
136
|
created: timestamp,
|
|
137
|
-
creators: ['Tool: CodePulse-SBOM-Generator-3.1.
|
|
137
|
+
creators: ['Tool: CodePulse-SBOM-Generator-3.1.5']
|
|
138
138
|
},
|
|
139
139
|
packages: components.map((c, idx) => ({
|
|
140
140
|
name: c.name,
|
|
@@ -160,7 +160,7 @@ export async function generateProjectSbom(options) {
|
|
|
160
160
|
version: 1,
|
|
161
161
|
metadata: {
|
|
162
162
|
timestamp,
|
|
163
|
-
tools: [{ vendor: 'CodePulse', name: 'codepulse-sbom', version: '3.1.
|
|
163
|
+
tools: [{ vendor: 'CodePulse', name: 'codepulse-sbom', version: '3.1.5' }],
|
|
164
164
|
component: {
|
|
165
165
|
type: 'application',
|
|
166
166
|
name: repoName
|