Public: anyone can read this; the crew can change it.

Plugin config: a line too long to read stays as the file has it #17782

opened this

Sentinel asked for changes (review 01m8wxf0dkr8fc7s1rsj9tvf0s)

sold/leaf-editor-7 → main 1 commit 1 thread · 1 unresolved

Review

Sign in to review this change.
6 files changed +196 −24
docs/features/game-plugin-config.md +1
@@ -15,5 +15,6 @@ so a change is a commit, previewed first and undone by a revert (#17699).
1515 - **Why a commit should restart the server, and what is not yet proven:** compose does not recreate a container whose `content:` changed (measured for the sleepers' AutoStopper config, `src/games/sleep.ts`) and does recreate one whose environment changed (the same measurement). A changed label is expected to recreate it too, since compose hashes the whole service, so each commit also sets the service's `forge.config` label to a hash of its files. **That the label does it, that the image reads an inline `content:` mount at start and that `SYNC_SKIP_NEWER_IN_DESTINATION=false` makes it replace the server's copy have not been tried on a real container.** The plan and the page therefore say "should restart", and what a person sees after the first commit on a box is the test: if the file is not in `/data/plugins` after the next check-in, `power` `recreate` on the service does it by hand, and the how-to is to be corrected.
1616 - **Compose reads `${…}` in `content:`:** the forge writes a literal `$` as `$$`, and reads it back as `$`.
1717 - **Secrets:** a key that names one (`api-key`, `dbPassword`), a file that is one (`forwarding.secret`, a private key block) and a value written out are refused, and so is a password inside a URL under any key (`mysql://user:pass@host/db`, `jdbc:…;password=…`, `?token=…`); the page and the plan name the line, never the value. Write `${CFG_NAME}` in the file instead: the images fill it from the container's environment while copying (yml, json, toml, properties), and the value belongs in the box's sealed `.env`.
18 - **A line too long to read** (over 4,000 characters, and what is indented under it) is not looked at for a secret. A file that has one is still edited: every door shows `‹kept: line 12 of <commit>, too long to read here›` in its place, and a save puts the file's own line back, byte for byte. Adding or changing such a line is refused, in words of its own. A revert may bring one back.
1819
1920 What the box holds is not read back: the agent sends no config files, so the page cannot say a server's copy differs from the repository's. That needs the agent to send `files: [{ service, path, sha256, text? }]` in each sync, and is a pull of its own.
src/core/secret_text.ts +22 −2
@@ -109,6 +109,22 @@ function inlineEnd(line: string, from: number): number {
109109 /** Told each secret in the clear, a text at a time: its key and the value as written. */
110110 type Found = (key: string, value: string) => void;
111111
112 /** The lines (from 0) the scan does not read: each over `MAX_LINE`, and what stands under it, indented more. */
113 export function unreadLines(lines: readonly string[]): Set<number> {
114 const out = new Set<number>();
115 let under: number | undefined;
116 lines.forEach((line, at) => {
117 if (line.length > MAX_LINE) under = indentOf(line);
118 else if (under === undefined || line.trim() === "") return;
119 else if (indentOf(line) <= under) {
120 under = undefined;
121 return;
122 }
123 out.add(at);
124 });
125 return out;
126 }
127
112128 /** Where a `value:` key stands in its line, and the secret's name beside it (`name: DB_PASSWORD`). */
113129 type Named = ReadonlyMap<number, string>;
114130 const NONE: Named = new Map();
@@ -233,11 +249,11 @@ function scan(text: string, found: Found, placeholders: boolean): string[] {
233249 let pem = false;
234250 const all = text.split("\n");
235251 const pairs = namedValues(all);
252 const unread = unreadLines(all);
236253 return all.map((line, at) => {
237254 if (line.length > MAX_LINE) {
238255 found(TOO_LONG, line);
239 // What it may have opened goes on below it, indented more.
240 open = { key: TOO_LONG, indent: indentOf(line), until: "indent", whole: true };
256 open = undefined;
241257 return MASK;
242258 }
243259 const named = pairs.get(at) ?? NONE;
@@ -246,6 +262,10 @@ function scan(text: string, found: Found, placeholders: boolean): string[] {
246262 pem = !/-----END [A-Z ]*PRIVATE KEY-----/.test(line);
247263 return `${line.slice(0, indentOf(line))}${MASK}`;
248264 }
265 if (unread.has(at)) {
266 found(TOO_LONG, line.trim());
267 return `${line.slice(0, indentOf(line))}${/^\s*-\s/.test(line) ? "- " : ""}${MASK}`;
268 }
249269 if (open !== undefined) {
250270 const o = open;
251271 const hide = (value = line.trim()): string => {
src/games/plugin_config.ts +85 −17
@@ -32,7 +32,7 @@
3232 */
3333
3434 import type { App } from "../app.ts";
35 import { hideSecrets, MASK, MAX_LINE, maskUrl, PRIVATE_BLOCK, secretKey, secretLiterals } from "../core/secret_text.ts";
35 import { hideSecrets, MASK, MAX_LINE, maskUrl, PRIVATE_BLOCK, secretKey, secretLiterals, TOO_LONG, unreadLines } from "../core/secret_text.ts";
3636 import type { User } from "../core/users.ts";
3737 import { lineDiff, type DiffLine } from "../web/render/json-doc.ts";
3838 import { commitCompose, composeHistory, readCompose, readRepoFile, setServiceEnv, setServiceLabels, setServiceListItem, setTopEntry } from "./compose.ts";
@@ -115,21 +115,74 @@ export const secretFile = (file: string, text: string): boolean => secretKey(fil
115115 const WHERE = "the image fills a `${CFG_NAME}` placeholder from the server's environment at start; the value belongs in the box's sealed .env, named in the file and never written in it";
116116
117117 /** The lines (from 1) that carry a password inside a URL, under any key. */
118 const urlSecretLines = (text: string): number[] => text.split("\n").flatMap((l, n) => (maskUrl(l) === l ? [] : [n + 1]));
118 const urlSecretLines = (text: string): number[] => text.split("\n").flatMap((l, n) => (l.length > MAX_LINE || maskUrl(l) === l ? [] : [n + 1]));
119119
120 /** Why `text` may not be committed as `file`; undefined when it may. */
121 function textProblem(file: string, text: string): string | undefined {
122 // The image fills only `${CFG_…}`: another placeholder would reach the plugin as written.
123 const strict = text.replace(/\$\{(?!CFG_[A-Za-z0-9_]+\})/g, "$.{");
120 /** The image fills only `${CFG_…}`: another placeholder would reach the plugin as written. */
121 const strictly = (text: string): string => text.replace(/\$\{(?!CFG_[A-Za-z0-9_]+\})/g, "$.{");
122
123 /** The first line (from 1) of `text` that is not read for a secret and that `had` does not hold as it is. */
124 function newUnread(text: string, had: string): number | undefined {
125 const left = new Map<string, number>();
126 const old = had.split("\n");
127 for (const n of unreadLines(old)) left.set(old[n]!, (left.get(old[n]!) ?? 0) + 1);
128 const lines = text.split("\n");
129 for (const n of unreadLines(lines)) {
130 const more = left.get(lines[n]!) ?? 0;
131 if (more === 0) return n + 1;
132 left.set(lines[n]!, more - 1);
133 }
134 return undefined;
135 }
136
137 /**
138 * What stands in a shown text for a line too long to read: its number in the file at a commit. No
139 * hash of it, which would let a guess at a short value be tried.
140 */
141 const KEPT_LINE = /^\s*‹kept: line (\d{1,6}) of ([0-9a-f]{12}), too long to read here›\s*$/;
142 const KEPT_LOST = "stands for a line too long to read here, and no such line is in this file. Open the file again.";
143
144 /** A file's text as every door shows and edits it: secrets hidden, and each unread line named, so a save can put it back. */
145 function shownText(content: string, sha: string): string {
146 const lines = content.split("\n");
147 const shown = hideSecrets(content).split("\n");
148 // A text hidden whole has no lines to name.
149 if (shown.length !== lines.length) return shown.join("\n");
150 for (const n of unreadLines(lines)) shown[n] = `${/^\s*/.exec(shown[n]!)![0]}‹kept: line ${String(n + 1)} of ${sha.slice(0, 12)}, too long to read here›`;
151 return shown.join("\n");
152 }
153
154 /** `text` with the file's own lines back where it names them, byte for byte. */
155 async function withKept(text: string, at: (sha: string) => Promise<string | undefined>): Promise<Result<string>> {
156 const files = new Map<string, readonly string[]>();
157 const lines = text.split("\n");
158 for (const [i, line] of lines.entries()) {
159 const m = KEPT_LINE.exec(line);
160 if (m === null) {
161 if (line.includes("‹kept: line ")) return { ok: false, error: `Line ${String(i + 1)} ${KEPT_LOST}` };
162 continue;
163 }
164 if (!files.has(m[2]!)) files.set(m[2]!, (await at(m[2]!))?.split("\n") ?? []);

High (DoS): this loop expands every marker line to the file's own line, and fetches a commit per distinct sha, before the size cap in textProblem runs. Cap the marker count and distinct shas, and stop expanding once the running size passes MAX_BYTES. Do both before the first git read.

165 const old = files.get(m[2]!)!;
166 const n = Number(m[1]) - 1;
167 if (!unreadLines(old).has(n)) return { ok: false, error: `Line ${String(i + 1)} ${KEPT_LOST}` };
168 lines[i] = old[n]!;
169 }
170 return { ok: true, value: lines.join("\n") };
171 }
172
173 /** Why `text` may not be committed as `file` over `had`; undefined when it may. */
174 function textProblem(file: string, text: string, had: string): string | undefined {
175 const strict = strictly(text);
124176 if (text.includes("\0")) return "A config file is text; this one has a NUL byte.";
125177 if (new TextEncoder().encode(text).length > MAX_BYTES)
126178 return `A config file here is at most ${String(MAX_BYTES / 1024)} KiB, because it lives in the compose file a person reads.`;
127 const long = text.split("\n").findIndex((l) => l.length > MAX_LINE);
128 if (long >= 0) return `Line ${String(long + 1)} is longer than ${MAX_LINE.toLocaleString("en")} characters, too long to look for a secret in it: break it up.`;
179 const long = newUnread(strict, strictly(had));
180 if (long !== undefined)
181 return `Line ${String(long)} is new or changed, and it is too long to read here (over ${MAX_LINE.toLocaleString("en")} characters, or under such a line): break it up. One the file has already stays as it is.`;
129182 if (text.includes(MASK))
130183 return `This text still has ${MASK} where a secret was hidden; committing it would write that over the real value. Put a \${CFG_NAME} placeholder there.`;
131184 if (secretFile(file, text)) return `${file} is a secret as a whole, and the repository is no place for one: keep it on the box (a secret file is named in git, never held there).`;
132 const keys = secretLiterals(strict);
185 const keys = secretLiterals(strict).filter((k) => k !== TOO_LONG);
133186 if (keys.length > 0)
134187 return `${keys.join(", ")} looks like a secret, and the repository is no place for one. Write \${CFG_${keys[0]!.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}} in the file: ${WHERE}.`;
135188 const urls = urlSecretLines(strict);
@@ -232,7 +285,7 @@ export async function configsOf(app: App, box: GameBox, service: string): Promis
232285 file: m.file,
233286 plugin: pluginOf(m.file),
234287 ref: { repo: box.repo, branch: box.branch, path: box.path, at: `configs.${m.name}.content` },
235 text: hideSecrets(m.content),
288 text: shownText(m.content, compose.sha),
236289 }));
237290 const plugins = [...new Set(files.map((f) => f.plugin))].sort().map((plugin) => ({ plugin, files: files.filter((f) => f.plugin === plugin) }));
238291 return { ok: true, value: { sha: compose.sha, plugins } };
@@ -254,15 +307,30 @@ export function restartWords(app: App, box: GameBox, service: string): string {
254307
255308 /**
256309 * Preview `content` (null removes the file) as `file` on a service: the diff, the restart, who is
257 * online, and the refusal when a secret is in it.
310 * online, and the refusal when a secret is in it. `reverts`: the text is the file's own, from its
311 * history, long lines too.
258312 */
259 export async function planConfig(app: App, box: GameBox, service: string, file: string, content: string | null): Promise<Result<ConfigPlan>> {
260 const text = content === null ? null : content.replaceAll("\r\n", "\n").replace(/\n*$/, "\n");
261 const bad = fileProblem(file) ?? (text === null ? undefined : textProblem(file, text));
262 if (bad !== undefined) return { ok: false, error: bad };
313 export async function planConfig(app: App, box: GameBox, service: string, file: string, content: string | null, reverts = false): Promise<Result<ConfigPlan>> {
314 const misnamed = fileProblem(file);
315 if (misnamed !== undefined) return { ok: false, error: misnamed };
263316 const compose = await readCompose(app, box);
264317 if (compose === undefined) return { ok: false, error: `No ${box.path} on ${box.repo}@${box.branch}.` };
265 const before = configMounts(compose.text, service).find((m) => m.file === file)?.content;
318 const inText = (all: string): string | undefined => configMounts(all, service).find((m) => m.file === file)?.content;
319 const before = inText(compose.text);
320 let text = content === null ? null : content.replaceAll("\r\n", "\n").replace(/\n*$/, "\n");
321 if (text !== null) {
322 if (!reverts) {
323 // The commit the text was opened at; a line that has left the file since is refused below.
324 const whole = await withKept(text, async (sha) => {
325 const all = compose.sha.startsWith(sha) ? compose.text : await readRepoFile(app, box, sha, box.path);
326 return all === undefined ? undefined : inText(all);
327 });
328 if (!whole.ok) return whole;
329 text = whole.value;
330 }
331 const bad = textProblem(file, text, reverts ? text : (before ?? ""));
332 if (bad !== undefined) return { ok: false, error: bad };
333 }
266334 if (before === undefined && text === null) return { ok: false, error: `${file} is not in the repository; there is nothing to remove.` };
267335 if (before === text) return { ok: false, error: `${file} already says that.` };
268336 try {
@@ -304,7 +372,7 @@ export async function planRevertConfig(app: App, box: GameBox, service: string,
304372 const old = await readRepoFile(app, box, c, box.path);
305373 const was = old === undefined ? undefined : configMounts(old, service).find((m) => m.file === file)?.content;
306374 if (was === now) continue;
307 const planned = await planConfig(app, box, service, file, was ?? null);
375 const planned = await planConfig(app, box, service, file, was ?? null, true);
308376 return planned.ok ? { ok: true, value: { ...planned.value, message: `games: ${service} config: revert ${file}` } } : planned;
309377 }
310378 return { ok: false, error: `${file} has no earlier version to go back to.` };
src/web/render/config-secrets.ts +4 −2
@@ -5,7 +5,7 @@
55 * the clear is refused, and so is a kept one moved under a key that would show it.
66 */
77
8 import { hiddenValue, hideSecrets, literalSecret, MASK, maskUrl, PRIVATE_BLOCK, secretKey, severalSecrets } from "../../core/secret_text.ts";
8 import { hiddenValue, hideSecrets, literalSecret, MASK, MAX_LINE, maskUrl, PRIVATE_BLOCK, secretKey, severalSecrets } from "../../core/secret_text.ts";
99 import { pointer, type Json } from "./json-doc.ts";
1010 import { isJsonNumber } from "./json-schema.ts";
1111
@@ -15,6 +15,7 @@ export const isKept = (v: Json): boolean => v.t === "string" && KEPT.test(v.v);
1515
1616 export const KEPT_HINT = "Kept as it is in the file, and not shown. It is in this repository's history: seal it and change it.";
1717 export const NEW_SECRET = "This looks like a secret, and the repository is no place for one. Write a placeholder such as ${NAME} and seal the value. If it is not a secret, edit the file as text.";
18 export const NEW_LONG = "This has a line too long to read here, so nothing can look for a secret in it. Break it up, or edit the file as text.";
1819 export const KEPT_LOST = "This stands for a value the file no longer has here. Open the file again.";
1920 export const KEPT_MOVED = "This stands for a secret, and its new key would show it. Put it back under its own key.";
2021 export const KEPT_CHANGED = "changed since you opened it, and it keeps a secret the form does not hold. Open it again to change it.";
@@ -85,7 +86,8 @@ export function keepDoc(doc: Json, original: Json): { doc: Json; errors: Map<str
8586 });
8687 const now = secretLeaves(real);
8788 for (const p of back) if (!now.has(p)) errors.set(p, KEPT_MOVED);
88 for (const p of secretLeaves(real, true).keys()) if (!back.has(p) && !errors.has(p)) errors.set(p, NEW_SECRET);
89 for (const [p, v] of secretLeaves(real, true))
90 if (!back.has(p) && !errors.has(p)) errors.set(p, v.t === "string" && v.v.split("\n").some((l) => l.length > MAX_LINE) ? NEW_LONG : NEW_SECRET);
8991 return { doc: real, errors };
9092 }
9193
test/config-secrets.test.ts +2 −1
@@ -2,7 +2,7 @@
22
33 import { describe, expect, test } from "bun:test";
44 import { addedSecrets, hideSecrets, MAX_LINE, secretKey, secretLiterals } from "../src/core/secret_text.ts";
5 import { hideDoc, hideText, isKept, keepDoc, KEPT_MOVED, KEPT_LOST, NEW_SECRET, secretLeaves } from "../src/web/render/config-secrets.ts";
5 import { hideDoc, hideText, isKept, keepDoc, KEPT_MOVED, KEPT_LOST, NEW_LONG, NEW_SECRET, secretLeaves } from "../src/web/render/config-secrets.ts";
66 import { formRows } from "../src/tui/screens/config_rows.ts";
77 import { configFields } from "../src/web/render/config-form.ts";
88 import { parseConfig } from "../src/web/render/config-format.ts";
@@ -167,6 +167,7 @@ describe("the form", () => {
167167 const at = (p: string, v: string) => [...keepDoc(updateAt(hideDoc(doc), p, () => str(v)), doc).errors];
168168 expect(at(PASS, "${RCON_PASSWORD}")).toEqual([]);
169169 expect(at(PASS, "another-one")).toEqual([[PASS, NEW_SECRET]]);
170 expect(at(PASS, "x".repeat(MAX_LINE + 1))).toEqual([[PASS, NEW_LONG]]);
170171 expect(at("/services/mc/environment/HOST", `‹kept: ${PASS}›`)).toEqual([["/services/mc/environment/HOST", KEPT_MOVED]]);
171172 expect(at(PASS, "‹kept: /no/where›")).toEqual([[PASS, KEPT_LOST]]);
172173 expect(at(PASS, "‹kept: /port›")).toEqual([[PASS, KEPT_LOST]]);
test/game-plugin-config.test.ts +82 −2
@@ -11,10 +11,11 @@ import { commitToBranch, createRepo } from "../src/actions/repos.ts";
1111 import { createApp, type App } from "../src/app.ts";
1212 import { createToken } from "../src/core/tokens.ts";
1313 import { forgeHttp } from "../src/http/server.ts";
14 import { getRepo } from "../src/core/repos.ts";
1415 import { createUser, getUserByName, type User } from "../src/core/users.ts";
1516 import { readCompose, serviceEnv, serviceLabels } from "../src/games/compose.ts";
1617 import { hideSecrets, secretKey, secretLiterals } from "../src/core/secret_text.ts";
17 import { commitConfig, configMounts, configsOf, fileProblem, planConfig, planRevertConfig } from "../src/games/plugin_config.ts";
18 import { commitConfig, configMounts, configsOf, fileProblem, planConfig, planRevertConfig, withConfig } from "../src/games/plugin_config.ts";
1819 import { boxNamed, createGameBox, type GameBox } from "../src/games/store.ts";
1920 import { quietLogs } from "./helpers/globals.ts";
2021
@@ -101,7 +102,8 @@ describe("which files and which secrets", () => {
101102 const pair = await planConfig(app, box, "hub", HUB, "env:\n - value: hunter2\n name: DB_PASSWORD\n");
102103 expect(!pair.ok && pair.error).toContain("${CFG_DB_PASSWORD}");
103104 const long = await planConfig(app, box, "hub", HUB, `a: 1\nb: ${"x".repeat(4_000)}\n`);
104 expect(!long.ok && long.error).toContain("Line 2 is longer than 4,000 characters");
105 expect(!long.ok && long.error).toContain("Line 2 is new or changed, and it is too long to read here");
106 expect(!long.ok && long.error).not.toContain("looks like a secret");
105107 const aliased = await planConfig(app, box, "hub", HUB, "x: &x hunter2\ntoken: *x\n");
106108 expect(aliased.ok).toBe(false);
107109 expect(hideSecrets("x: &x hunter2\ntoken: *x\n")).not.toContain("hunter2");
@@ -124,6 +126,84 @@ describe("which files and which secrets", () => {
124126 });
125127 });
126128
129 test("a hidden line deleted by hand is a removal like any other: shown masked, and saved without it", async () => {
130 const FILE = "plugins/Old/config.yml";
131 const repo = getRepo(app.db, "alice", "mc-network")!;
132 const text = withConfig(await compose(), "hub", FILE, "motd: hi\npassword: hunter2\nend: 1\n");
133 const done = await commitToBranch(app, alice, repo, { message: "old", files: [{ path: "net/docker-compose.yml", content: text }] });
134 expect(done.ok).toBe(true);
135 const got = await configsOf(app, box, "hub");
136 const shown = got.ok ? got.value.plugins.flatMap((p) => p.files).find((f) => f.file === FILE)!.text : "";
137 expect(shown).toBe("motd: hi\npassword: ‹hidden›\nend: 1\n");
138 const plan = await save("hub", FILE, shown.replace("password: ‹hidden›\n", ""));
139 expect(plan.diff.filter((l) => l.op !== " ").map((l) => `${l.op}${l.text}`)).toEqual(["-password: ‹hidden›"]);
140 expect(configMounts(await compose(), "hub").find((m) => m.file === FILE)?.content).toBe("motd: hi\nend: 1\n");
141 await save("hub", FILE, null);
142 });
143
144 describe("a line too long to read", () => {
145 const FILE = "plugins/Heads/config.yml";
146 const long = `head: "${"QUJD".repeat(2_000)}"`;
147 const had = `motd: hi\nheads:\n ${long}\n under: it\nend: 1\n`;
148 const shown = async () => {
149 const got = await configsOf(app, box, "hub");
150 if (!got.ok) throw new Error(got.error);
151 return got.value.plugins.flatMap((p) => p.files).find((f) => f.file === FILE)!.text;
152 };
153 const held = async () => configMounts(await compose(), "hub").find((m) => m.file === FILE)?.content;
154 beforeAll(async () => {
155 // As a file written by hand in the repository: the editor takes no new one.
156 const text = withConfig(await compose(), "hub", FILE, had);
157 const repo = getRepo(app.db, "alice", "mc-network")!;
158 const done = await commitToBranch(app, alice, repo, { message: "heads", files: [{ path: "net/docker-compose.yml", content: text }] });
159 if (!done.ok) throw new Error(JSON.stringify(done.error));
160 });
161
162 test("another line changes, and it stays byte for byte, from the shown text or from its own", async () => {
163 const text = await shown();
164 expect(text).not.toContain("QUJD");
165 expect(text).not.toContain("under: it");
166 expect(text).toMatch(/^motd: hi\nheads:\n‹kept: line 3 of [0-9a-f]{12}, too long to read here›\n {4}‹kept: line 4 of [0-9a-f]{12}, too long to read here›\nend: 1\n$/);
167 const plan = await save("hub", FILE, text.replace("motd: hi", "motd: there"));
168 expect(plan.diff.filter((l) => l.op !== " ").map((l) => `${l.op}${l.text}`)).toEqual(["+motd: there", "-motd: hi"]);
169 expect(JSON.stringify(plan.diff)).not.toContain("QUJD");
170 expect(await held()).toBe(had.replace("motd: hi", "motd: there"));
171 // The text opened before that commit names the same line still.
172 await save("hub", FILE, text.replace("end: 1", "end: 2"));
173 expect(await held()).toBe(had.replace("end: 1", "end: 2"));
174 await save("hub", FILE, had);
175 expect(await held()).toBe(had);
176 });
177
178 test("changed by one character, doubled, or with a new line under it, it is refused in words of its own", async () => {
179 for (const text of [had.replace("QUJD", "QUJE"), had.replace("end: 1", ` ${long}`), had.replace("under: it", "under: is"), had.replace("end: 1", "end: 1\n" + long)]) {
180 const got = await planConfig(app, box, "hub", FILE, text);
181 expect(!got.ok && got.error).toContain("too long to read here");
182 expect(!got.ok && got.error).not.toContain("looks like a secret");
183 expect(!got.ok && got.error).not.toContain("QUJ");
184 }
185 // The rest of the file is read as any other.
186 const secret = await planConfig(app, box, "hub", FILE, had.replace("end: 1", "password: hunter2"));
187 expect(!secret.ok && secret.error).toContain("${CFG_PASSWORD}");
188 });
189
190 test("a name that stands for no such line is refused, never written", async () => {
191 const text = await shown();
192 for (const bad of [text.replace("line 3", "line 1"), text.replace("line 3", "line 99"), text.replace(/of [0-9a-f]{12}/, `of ${"0".repeat(12)}`), text.replace("‹kept", "x: ‹kept")]) {
193 const got = await planConfig(app, box, "hub", FILE, bad);
194 expect(!got.ok && got.error).toContain("no such line is in this file");
195 }
196 const masked = await planConfig(app, box, "hub", FILE, had.replace(long, "‹hidden›"));
197 expect(masked.ok).toBe(false);
198 });
199
200 test("a file with such a line is removed, and the revert puts it back", async () => {
201 await save("hub", FILE, null);
202 const back = await planRevertConfig(app, box, "hub", FILE);
203 expect(back.ok && back.value.content).toBe(had);
204 });
205 });
206
127207 describe("a change, previewed and committed", () => {
128208 test("the preview names the diff, the restart and who is online, and changes nothing", async () => {
129209 const before = await compose();

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs