Split The code is public; the app answers only to the crew.

A cookie jar and four HTML dumps are committed on `main`: `.scout-tmp/` goes, and a test keeps it out #125

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/cs:scout/98-a-cookie-jar-and-four-html-dumps-are-com → main 1 commit fork

  • Merged. scout/98-a-cookie-jar-and-four-html-dumps-are-com was merged into main as 2ae91e4.

Review

Sign in to review this change.
7 files changed +70 −21
.gitignore +2
@@ -4,3 +4,5 @@ node_modules/
44 *.db-shm
55 static/app.*.js
66 .checkdata/
7 .scout-tmp/
8 cookies*.txt
.scout-tmp/cookies2.txt deleted −5
@@ -1,5 +0,0 @@
1 # Netscape HTTP Cookie File
2 # https://curl.se/docs/http-cookies.html
3 # This file was generated by libcurl! Edit at your own risk.
4
5 #HttpOnly_127.0.0.1 FALSE / FALSE 1821245237 cs_session 12894e80728ebd16d3eb0dace3e835b2
.scout-tmp/out1.html deleted −5
@@ -1,5 +0,0 @@
1 <h2>Leaderboard</h2>
2 <p class="you">You are playing as <b>guest a247</b>. <a href="/__forge/signin?to=%2F" rel="noreferrer">Sign in on the forge</a> to put your matches on the board under your name.</p>
3 <table><thead><tr><th>#</th><th>player</th><th>matches</th><th>kills</th><th>K/D</th><th>HS</th><th>wins</th></tr></thead><tbody><tr><td>1</td><td>guest a247 <span class="tag">guest</span></td><td>1</td><td>9</td><td>2.25</td><td>33%</td><td>0</td></tr></tbody></table>
4 <h3>Recent matches</h3>
5 <ul class="recent"><li><b>guest a247 <span class="tag">guest</span></b> 3–2 <span>9k 4d · 1200 damage · abandoned</span> <time>2026-09-18 05:26:55</time></li></ul>↵
.scout-tmp/out2.html deleted −1
@@ -1,1 +0,0 @@
1 not yours↵
.scout-tmp/out3.html deleted −5
@@ -1,5 +0,0 @@
1 <h2>Leaderboard</h2>
2 <p class="you">You are playing as <b>guest 1289</b>. <a href="/__forge/signin?to=%2F" rel="noreferrer">Sign in on the forge</a> to put your matches on the board under your name.</p>
3 <table><thead><tr><th>#</th><th>player</th><th>matches</th><th>kills</th><th>K/D</th><th>HS</th><th>wins</th></tr></thead><tbody><tr><td>1</td><td>guest 1289 <span class="tag">guest</span></td><td>1</td><td>9</td><td>2.25</td><td>33%</td><td>0</td></tr></tbody></table>
4 <h3>Recent matches</h3>
5 <ul class="recent"><li><b>guest 1289 <span class="tag">guest</span></b> 3–2 <span>9k 4d · 1200 damage · abandoned</span> <time>2026-09-18 05:27:17</time></li></ul>↵
.scout-tmp/out4.html deleted −5
@@ -1,5 +0,0 @@
1 <h2>Leaderboard</h2>
2 <p class="you">You are playing as <b>guest 1289</b>. <a href="/__forge/signin?to=%2F" rel="noreferrer">Sign in on the forge</a> to put your matches on the board under your name.</p>
3 <table><thead><tr><th>#</th><th>player</th><th>matches</th><th>kills</th><th>K/D</th><th>HS</th><th>wins</th></tr></thead><tbody><tr><td>1</td><td>guest 1289 <span class="tag">guest</span></td><td>1</td><td>9</td><td>2.25</td><td>33%</td><td>0</td></tr></tbody></table>
4 <h3>Recent matches</h3>
5 <ul class="recent"><li><b>guest 1289 <span class="tag">guest</span></b> 3–2 <span>9k 4d · 1200 damage · abandoned</span> <time>2026-09-18 05:27:17</time></li></ul>↵
src/tree.test.ts added +68
@@ -0,0 +1,68 @@
1 /**
2 * `.scout-tmp/` held a live session cookie and four rendered pages once
3 * (issue #98): scratch a builder meant to throw away, merged by mistake.
4 * `.gitignore` keeps it from happening again; this walks the tree the way
5 * a clean checkout would look — skipping `.git` and `node_modules`, since
6 * `git ls-files` isn't available to a test — and fails the same way CI
7 * would if either shape came back: a Netscape cookie jar, or a directory
8 * named for one of the scratch patterns `.gitignore` already lists.
9 */
10
11 import { expect, test } from "bun:test";
12 import { closeSync, openSync, readdirSync, readFileSync, readSync } from "node:fs";
13 import { join } from "node:path";
14
15 const root = join(import.meta.dir, "..");
16 const SKIP_DIRS = new Set([".git", "node_modules"]);
17 const COOKIE_JAR_HEADER = "# Netscape HTTP Cookie File";
18
19 const gitignore = readFileSync(join(root, ".gitignore"), "utf8");
20 const lines = gitignore
21 .split("\n")
22 .map((line) => line.trim())
23 .filter((line) => line.length > 0 && !line.startsWith("#"));
24
25 const scratchDirNames = new Set(
26 lines.filter((line) => line.endsWith("/")).map((line) => line.slice(0, -1)),
27 );
28 const filePatterns = lines
29 .filter((line) => !line.endsWith("/") && line.includes("*"))
30 .map((line) => new RegExp(`^${line.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`));
31
32 /** Just enough of the file to know its first line, not the whole thing. */
33 const firstLine = (path: string): string => {
34 const fd = openSync(path, "r");
35 try {
36 const buffer = Buffer.alloc(256);
37 const read = readSync(fd, buffer, 0, buffer.length, 0);
38 return buffer.toString("utf8", 0, read).split("\n")[0] ?? "";
39 } finally {
40 closeSync(fd);
41 }
42 };
43
44 const violations: string[] = [];
45
46 const walk = (dir: string): void => {
47 for (const entry of readdirSync(dir, { withFileTypes: true })) {
48 if (SKIP_DIRS.has(entry.name)) continue;
49 const path = join(dir, entry.name);
50 const relative = path.slice(root.length + 1);
51 if (entry.isDirectory()) {
52 if (scratchDirNames.has(entry.name)) violations.push(`${relative}/ is a scratch directory .gitignore already refuses`);
53 walk(path);
54 } else if (entry.isFile()) {
55 if (filePatterns.some((pattern) => pattern.test(entry.name))) {
56 violations.push(`${relative} matches a scratch pattern .gitignore already refuses`);
57 } else if (firstLine(path).trim() === COOKIE_JAR_HEADER) {
58 violations.push(`${relative} is a Netscape cookie jar`);
59 }
60 }
61 }
62 };
63
64 test("the repository holds no cookie jar and no scratch directory", () => {
65 violations.length = 0;
66 walk(root);
67 expect(violations).toEqual([]);
68 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs