rattlecheck 0.1.0 → 0.1.1
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 +2 -2
- package/package.json +1 -1
- package/src/model.js +2 -1
- package/src/report/card-svg.js +9 -4
- package/src/report/grade.js +1 -0
- package/src/report/terminal.js +2 -2
- package/src/scan.js +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ npx rattlecheck
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
```
|
|
12
|
-
rattlecheck 0.1.
|
|
12
|
+
rattlecheck 0.1.1 rattle every door you own
|
|
13
13
|
|
|
14
14
|
┌──────────────────────────────────────────────┐
|
|
15
15
|
│ GRADE F Wide open │
|
|
@@ -54,7 +54,7 @@ Every rule in rattlecheck comes from a real incident in a production app:
|
|
|
54
54
|
|
|
55
55
|
rattlecheck doesn't grep your files. It replays every migration in order, statement by statement, the way Postgres would, so it knows the current state: a revoke from March doesn't count if the function was dropped and re-created in June, and a policy that was later dropped protects nothing.
|
|
56
56
|
|
|
57
|
-
Grades: **A** nothing open, **B** only things worth a look, **C** one high finding, **D** two or more, **F** anything critical.
|
|
57
|
+
Grades: **A** nothing open, **B** only things worth a look, **C** one high finding, **D** two or more, **F** anything critical. **N/A** means no objects were checked. Empty or comment-only migration files on their own produce exit code 3.
|
|
58
58
|
|
|
59
59
|
## For coding agents
|
|
60
60
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rattlecheck",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Rattle every door you own. Finds the open doors in your Supabase app before someone else does.",
|
|
5
5
|
"homepage": "https://github.com/chaseakub/rattlecheck#readme",
|
|
6
6
|
"repository": {
|
package/src/model.js
CHANGED
|
@@ -282,9 +282,10 @@ export function buildModel(migrations, opts = {}) {
|
|
|
282
282
|
sessionSchema = 'public'; // each migration file runs in its own session
|
|
283
283
|
localSchema = null;
|
|
284
284
|
for (const { sql: rawStmt, index } of splitStatements(source)) {
|
|
285
|
+
const head = stripComments(rawStmt).trimStart();
|
|
286
|
+
if (!head) continue;
|
|
285
287
|
coverage.statements++;
|
|
286
288
|
const line = lineAt(index);
|
|
287
|
-
const head = stripComments(rawStmt).replace(/^\s+/, '');
|
|
288
289
|
const flat = blankLiterals(head); // for keyword tests that must not see string contents
|
|
289
290
|
|
|
290
291
|
// ── SET search_path (decides where unqualified names land) ───────────
|
package/src/report/card-svg.js
CHANGED
|
@@ -8,14 +8,19 @@ const esc = (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replac
|
|
|
8
8
|
export function renderCard(report) {
|
|
9
9
|
const g = report.grade;
|
|
10
10
|
const { checked, open } = report.doors;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
let headline = open === 0 ? 'Every door locked.' : open === 1 ? '1 door open.' : `${open} doors open.`;
|
|
12
|
+
let sub =
|
|
13
13
|
open === 0
|
|
14
14
|
? `${checked.toLocaleString('en-US')} doors checked. Nothing gave.`
|
|
15
15
|
: `${checked.toLocaleString('en-US')} doors checked. Fixing ${open === 1 ? 'it' : 'them'} now.`;
|
|
16
16
|
|
|
17
|
+
if (checked === 0) {
|
|
18
|
+
headline = g.label + '.';
|
|
19
|
+
sub = 'Run the check on migrations that define tables or functions.';
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
// A row of small doors: open ones drawn ajar in the grade color.
|
|
18
|
-
const doorCount = Math.min(24,
|
|
23
|
+
const doorCount = Math.min(24, checked);
|
|
19
24
|
const openCount = Math.min(open, doorCount);
|
|
20
25
|
const doors = [];
|
|
21
26
|
for (let i = 0; i < doorCount; i++) {
|
|
@@ -36,7 +41,7 @@ export function renderCard(report) {
|
|
|
36
41
|
<text x="96" y="160" fill="#8b8b91" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Helvetica,Arial,sans-serif" font-size="24">Rattle every door you own.</text>
|
|
37
42
|
|
|
38
43
|
<circle cx="1010" cy="300" r="118" fill="none" stroke="${g.color}" stroke-width="10"/>
|
|
39
|
-
<text x="1010" y="345" text-anchor="middle" fill="${g.color}" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Helvetica,Arial,sans-serif" font-size="132" font-weight="800">${g.letter}</text>
|
|
44
|
+
<text x="1010" y="345" text-anchor="middle" fill="${g.color}" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Helvetica,Arial,sans-serif" font-size="${checked === 0 ? 86 : 132}" font-weight="800">${g.letter}</text>
|
|
40
45
|
<text x="1010" y="458" text-anchor="middle" fill="#c9c9ce" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Helvetica,Arial,sans-serif" font-size="26" font-weight="600">${esc(g.label)}</text>
|
|
41
46
|
|
|
42
47
|
<text x="96" y="318" fill="#f4f4f5" font-family="ui-sans-serif,system-ui,-apple-system,Segoe UI,Helvetica,Arial,sans-serif" font-size="76" font-weight="800">${esc(headline)}</text>
|
package/src/report/grade.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// The one place the grade is decided. Cards, badges, terminal output and the
|
|
2
2
|
// MCP server all read from here, so they cannot disagree.
|
|
3
3
|
export const GRADES = {
|
|
4
|
+
'N/A': { label: 'No objects checked', color: '#656b73' },
|
|
4
5
|
A: { label: 'Locked tight', color: '#1a9e55' },
|
|
5
6
|
B: { label: 'Mostly locked', color: '#6fa832' },
|
|
6
7
|
C: { label: 'Needs work', color: '#e0a100' },
|
package/src/report/terminal.js
CHANGED
|
@@ -14,7 +14,7 @@ function painter(useColor) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function gradeCode(letter) {
|
|
17
|
-
return { A: 32, B: 32, C: 33, D: 33, F: 31 }[letter];
|
|
17
|
+
return { A: 32, B: 32, C: 33, D: 33, F: 31, 'N/A': 90 }[letter];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function box(lines, width) {
|
|
@@ -45,7 +45,7 @@ export function renderTerminal(report, { technical = false, color = false } = {}
|
|
|
45
45
|
out.push(...card.map((l) => ` ${l}`));
|
|
46
46
|
out.push('');
|
|
47
47
|
|
|
48
|
-
if (report.findings.length === 0) {
|
|
48
|
+
if (report.findings.length === 0 && report.doors.checked > 0 && report.coverage.ok) {
|
|
49
49
|
out.push(` ${p.green('✓')} Nothing open. Every door rattlecheck knows how to check is shut.`);
|
|
50
50
|
out.push('');
|
|
51
51
|
}
|
package/src/scan.js
CHANGED
|
@@ -136,7 +136,7 @@ export async function scan({ root = '.', live = false, configPath, env = process
|
|
|
136
136
|
findings.sort((a, b) => order[a.severity] - order[b.severity] || a.rule.localeCompare(b.rule) || a.name.localeCompare(b.name));
|
|
137
137
|
|
|
138
138
|
const counts = countBySeverity(findings);
|
|
139
|
-
const letter = gradeFor(counts);
|
|
139
|
+
const letter = checked.size === 0 ? 'N/A' : gradeFor(counts);
|
|
140
140
|
const open = new Set(findings.filter((f) => OPEN_SEVERITIES.has(f.severity)).map((f) => f.object));
|
|
141
141
|
|
|
142
142
|
const coverageOk = !(migrations.length > 0 && model.coverage.statements === 0);
|