-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudit.html
More file actions
354 lines (329 loc) · 14.1 KB
/
audit.html
File metadata and controls
354 lines (329 loc) · 14.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>GitHub Actions audit, in your browser - depmedic</title>
<meta name="description" content="Paste a GitHub Actions workflow, get an instant cost and security audit. No signup, no upload. Runs entirely in your browser. Same engine as ci-doctor on npm." />
<link rel="canonical" href="https://depmedicdev-byte.github.io/audit.html" />
<meta name="theme-color" content="#0b0d10" />
<meta property="og:title" content="GitHub Actions audit, in your browser" />
<meta property="og:description" content="Paste a workflow, see what is leaking money and what is risky. 100% client-side." />
<meta property="og:url" content="https://depmedicdev-byte.github.io/audit.html" />
<meta property="og:type" content="website" />
<meta property="og:image" content="https://depmedicdev-byte.github.io/og/audit.png" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="https://depmedicdev-byte.github.io/og/audit.png" />
<style>
:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
background: #0b0d10; color: #e6e8eb;
font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
-webkit-font-smoothing: antialiased;
}
a { color: #6cb6ff; text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 920px; margin: 0 auto; padding: 40px 20px 80px; }
h1 { font-size: 28px; margin: 0 0 6px; letter-spacing: -0.01em; }
.nav { color: #9aa3ad; font-size: 14px; margin: 0 0 16px; }
.nav a { color: #9aa3ad; }
.lead { color: #b6bec7; margin: 0 0 24px; max-width: 64ch; }
h2 { font-size: 16px; color: #c9d1d9; margin: 24px 0 10px; letter-spacing: 0.02em; text-transform: uppercase; }
textarea {
width: 100%; min-height: 220px;
background: #0b0d10; color: #e6e8eb;
border: 1px solid #2a3744; border-radius: 8px; padding: 14px 16px;
font: 13px/1.55 ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
resize: vertical;
}
textarea.drop { border-color: #6cb6ff; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 20px; }
button {
background: #2a3744; color: #e6e8eb; border: 1px solid #3a4754;
padding: 9px 16px; border-radius: 6px; font: inherit; cursor: pointer;
}
button.primary { background: #2d5a7a; border-color: #3a6e94; }
button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.summary {
background: #11151b; border: 1px solid #1e242c; border-radius: 8px;
padding: 14px 18px; margin: 0 0 14px; display: none;
}
.summary .total { font-size: 22px; font-weight: 600; }
.summary .breakdown { color: #9aa3ad; font-size: 14px; margin-top: 4px; }
.summary.green { background: linear-gradient(135deg, #11151b, #122016); border-color: #2a4732; }
.summary.green .total { color: #9ce29c; }
.findings { display: none; }
.finding {
background: #11151b; border: 1px solid #1e242c; border-radius: 8px;
padding: 12px 16px; margin-bottom: 10px;
}
.finding .head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.finding .sev { font-size: 11px; padding: 2px 8px; border-radius: 999px; letter-spacing: 0.04em; text-transform: uppercase; }
.finding .sev.error { background: #4a1e1e; color: #ffb8b8; }
.finding .sev.warn { background: #4a3a1e; color: #ffd9a3; }
.finding .sev.info { background: #1e3a4a; color: #a3d4ff; }
.finding .ruleid { color: #9aa3ad; font-family: ui-monospace, monospace; font-size: 13px; }
.finding .loc { color: #6f7882; font-size: 13px; }
.finding .msg { margin-top: 6px; color: #d6dadf; font-size: 14px; }
.finding details { margin-top: 8px; }
.finding summary { color: #9aa3ad; font-size: 13px; cursor: pointer; }
.finding pre {
background: #0b0d10; border: 1px solid #1e242c; border-radius: 6px;
padding: 10px 12px; margin-top: 8px;
font: 13px/1.5 ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
overflow: auto;
}
.cta {
background: linear-gradient(135deg, #16202b, #1e2a38);
border: 1px solid #3a4754; border-radius: 12px;
padding: 22px 24px; margin: 28px 0;
display: none; flex-wrap: wrap; align-items: center; gap: 14px;
}
.cta.show { display: flex; }
.cta .text { flex: 1 1 320px; }
.cta h3 { margin: 0 0 6px; font-size: 17px; }
.cta p { margin: 0; color: #b6bec7; font-size: 14px; }
.cta .btn {
display: inline-block; padding: 10px 18px; border-radius: 8px;
background: #2a3744; color: #e6e8eb; font-weight: 500;
border: 1px solid #3a4754;
}
.cta .btn:hover { text-decoration: none; background: #3a4754; }
.footnote { color: #6f7882; font-size: 13px; margin: 28px 0 0; border-top: 1px solid #1e242c; padding-top: 14px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: #1e242c; color: #9aa3ad; font-size: 12px; vertical-align: middle; margin-left: 6px; }
</style>
</head>
<body>
<main>
<p class="nav"><a href="/">depmedic</a> / audit</p>
<h1>GitHub Actions audit, in your browser <span class="badge">no upload</span></h1>
<p class="lead">
Paste or drop a workflow YAML. The audit runs entirely in your browser
— same engine as the
<a href="https://www.npmjs.com/package/ci-doctor">ci-doctor</a> CLI on npm.
Catches missing concurrency, missing timeouts, expensive runners, unpinned
actions, missing permissions, wide triggers, no cache hint, and more.
Nothing leaves this page.
</p>
<textarea id="src" placeholder="# Paste your .github/workflows/<file>.yml here, or drop a file onto the box.
name: ci
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm test"></textarea>
<div class="controls">
<button class="primary" id="auditBtn">Audit workflow</button>
<button id="sampleBtn">Load a known-bad example</button>
<button id="shareBtn" title="Copy a link that reproduces this audit">Copy share link</button>
<button id="clearBtn">Clear</button>
<span style="flex:1"></span>
<span style="color:#6f7882;font-size:13px;align-self:center;">Engine: ci-doctor <span id="ver">--</span></span>
</div>
<div class="summary" id="summary"></div>
<div class="findings" id="findings"></div>
<div class="cta" id="cta">
<div class="text">
<h3 id="ctaH">Want the patterns that close all of these?</h3>
<p id="ctaP">
The <strong>Cut Your CI Bill</strong> cookbook covers all 30 of the
patterns this engine looks for, plus 5 paste-ready hardened workflow
templates. Companion to ci-doctor. $19, one-time, MIT-licensed templates.
</p>
</div>
<a class="btn" href="https://buy.polar.sh/polar_cl_E2HGFeAVxJ64gU0Tv0qGwAueuxvhuq6A0pjhE4BWTyD" rel="noopener">Get the cookbook</a>
</div>
<h2>Want the dollar number too?</h2>
<p>
This page tells you what is wrong. To see <em>what it costs</em>, paste
the same workflow into <a href="/budget.html">budget</a> — matrix
expansion, real GitHub-hosted runner pricing, monthly projection.
</p>
<h2>Or run the audit in CI</h2>
<pre style="background:#11151b;border:1px solid #1e242c;border-radius:6px;padding:12px 14px;font:13px/1.55 ui-monospace,monospace;"><code>npx ci-doctor # audit
npx ci-doctor --fix # apply safe fixes in place
npx ci-doctor --sarif > out.sarif # for GitHub Code Scanning</code></pre>
<p class="footnote">
This audit page runs in your browser using a 119 KB bundle of the same
rules engine that ships in <code>ci-doctor</code> on npm. Source on
<a href="https://github.com/depmedicdev-byte/ci-doctor">GitHub</a>. MIT.
</p>
</main>
<script src="./ci-doctor.bundle.js"></script>
<script>
const SAMPLE = `name: ci
on:
push:
pull_request:
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci && npm test
- uses: actions/upload-artifact@v4
with:
name: build
path: dist/
`;
const SEV_RANK = { error: 0, warn: 1, info: 2 };
const COST = new Set(['missing-concurrency','missing-timeout','missing-cache','expensive-runner','matrix-overcommit','artifact-no-retention','fetch-depth-zero','wide-trigger']);
const SEC = new Set(['missing-permissions','pinned-action-sha','unsafe-checkout','script-injection']);
const $ = (id) => document.getElementById(id);
function fmtSummary(findings) {
const s = { error: 0, warn: 0, info: 0 };
for (const f of findings) s[f.severity] = (s[f.severity] || 0) + 1;
return s;
}
function render(findings) {
const sum = $('summary');
const list = $('findings');
const cta = $('cta');
list.innerHTML = '';
if (!findings.length) {
sum.style.display = 'block';
sum.className = 'summary green';
sum.innerHTML = '<div class="total">No findings.</div><div class="breakdown">Workflow looks clean against the ci-doctor rule set.</div>';
list.style.display = 'none';
cta.classList.remove('show');
return;
}
const s = fmtSummary(findings);
sum.style.display = 'block';
sum.className = 'summary';
sum.innerHTML = '<div class="total">' + findings.length + ' finding' + (findings.length === 1 ? '' : 's') + '</div>' +
'<div class="breakdown">error ' + s.error + ' · warn ' + s.warn + ' · info ' + s.info + '</div>';
findings.sort((a, b) => (SEV_RANK[a.severity] - SEV_RANK[b.severity]) || (a.line - b.line));
for (const f of findings) {
const el = document.createElement('div');
el.className = 'finding';
const head = document.createElement('div');
head.className = 'head';
head.innerHTML = '<span class="sev ' + f.severity + '">' + f.severity + '</span>' +
'<span class="ruleid">' + f.ruleId + '</span>' +
'<span class="loc">' + (f.filename || 'workflow.yml') + ':' + f.line + ':' + f.column + '</span>';
el.appendChild(head);
const msg = document.createElement('div');
msg.className = 'msg';
msg.textContent = f.message;
el.appendChild(msg);
if (f.suggestion) {
const det = document.createElement('details');
const sm = document.createElement('summary');
sm.textContent = 'Suggested fix';
det.appendChild(sm);
const pre = document.createElement('pre');
pre.textContent = f.suggestion;
det.appendChild(pre);
el.appendChild(det);
}
list.appendChild(el);
}
list.style.display = 'block';
const costCount = findings.filter((f) => COST.has(f.ruleId)).length;
const ctaH = $('ctaH');
const ctaP = $('ctaP');
if (costCount >= 3) {
ctaH.textContent = 'You have ' + costCount + ' cost-class findings.';
ctaP.innerHTML = 'The <strong>Cut Your CI Bill</strong> cookbook ships the exact patterns that close every one of these, plus 5 hardened workflow templates. $19, one-time, MIT-licensed templates.';
} else {
ctaH.textContent = 'Want the patterns that close all of these?';
ctaP.innerHTML = 'The <strong>Cut Your CI Bill</strong> cookbook covers all 30 patterns this engine looks for, plus 5 paste-ready hardened workflow templates. $19, one-time, MIT-licensed templates.';
}
cta.classList.add('show');
}
function runAudit() {
const src = $('src').value;
if (!src.trim()) return;
try {
const findings = window.ciDoctor.auditWorkflow(src, 'workflow.yml');
render(findings);
} catch (err) {
$('summary').style.display = 'block';
$('summary').className = 'summary';
$('summary').innerHTML = '<div class="total">Parse error</div><div class="breakdown">' + (err && err.message ? err.message : String(err)) + '</div>';
$('findings').style.display = 'none';
$('cta').classList.remove('show');
}
}
$('auditBtn').addEventListener('click', runAudit);
$('sampleBtn').addEventListener('click', () => { $('src').value = SAMPLE; runAudit(); });
$('clearBtn').addEventListener('click', () => {
$('src').value = '';
$('summary').style.display = 'none';
$('findings').style.display = 'none';
$('cta').classList.remove('show');
history.replaceState(null, '', location.pathname);
});
$('shareBtn').addEventListener('click', async () => {
const v = $('src').value;
if (!v.trim()) return;
let payload;
try {
const bytes = new TextEncoder().encode(v);
let bin = '';
for (let i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]);
payload = btoa(bin).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
} catch (e) {
payload = encodeURIComponent(v);
}
const url = location.origin + location.pathname + '#y=' + payload;
history.replaceState(null, '', url);
try {
await navigator.clipboard.writeText(url);
const btn = $('shareBtn');
const old = btn.textContent;
btn.textContent = 'Copied. Link in address bar.';
setTimeout(() => { btn.textContent = old; }, 2200);
} catch (e) {
prompt('Share link (copy):', url);
}
});
$('src').addEventListener('keydown', (e) => {
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') runAudit();
});
(function loadFromHash() {
const m = location.hash.match(/y=([A-Za-z0-9_\-]+)/);
if (!m) return;
try {
let b64 = m[1].replace(/-/g, '+').replace(/_/g, '/');
while (b64.length % 4) b64 += '=';
const bin = atob(b64);
const bytes = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
$('src').value = new TextDecoder().decode(bytes);
runAudit();
} catch (e) { /* ignore */ }
})();
const ta = $('src');
ta.addEventListener('dragover', (e) => { e.preventDefault(); ta.classList.add('drop'); });
ta.addEventListener('dragleave', () => ta.classList.remove('drop'));
ta.addEventListener('drop', (e) => {
e.preventDefault();
ta.classList.remove('drop');
const file = e.dataTransfer.files[0];
if (!file) return;
const r = new FileReader();
r.onload = () => { ta.value = r.result; runAudit(); };
r.readAsText(file);
});
if (window.ciDoctor && window.ciDoctor.rules) {
$('ver').textContent = window.ciDoctor.rules.length + ' rules';
}
</script>
</body>
</html>