From 98b4113464388aaf035e4e2622748f2605fa9bb8 Mon Sep 17 00:00:00 2001 From: "smart-ssh-coder[bot]" <338317697+smart-ssh-coder[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 18:02:16 +0000 Subject: [PATCH 1/2] fix(ci): reject escaped quoted keys in deny.toml exceptions (#1599) Co-Authored-By: Claude Sonnet 5.5 --- .../frontend/src/licenseCompatCheck.test.ts | 23 ++++++---- scripts/generate-third-party-notices.mjs | 42 +++++++++++++++++++ 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/apps/smart-ssh-community/frontend/src/licenseCompatCheck.test.ts b/apps/smart-ssh-community/frontend/src/licenseCompatCheck.test.ts index 43c00364e..e7c89b0bb 100644 --- a/apps/smart-ssh-community/frontend/src/licenseCompatCheck.test.ts +++ b/apps/smart-ssh-community/frontend/src/licenseCompatCheck.test.ts @@ -143,6 +143,10 @@ describe("check-license-compat", () => { ["quoted exceptions", "licenses.'exceptions' = [{ crate = \"x\", allow = [\"GPL-2.0\"] }]\n", /quoted key/], ["spaced dots", 'licenses . "exceptions" = [{ crate = "x", allow = ["GPL-2.0"] }]\n', /quoted key/], ["inline table", 'licenses = { exceptions = [{ crate = "x", allow = ["GPL-2.0"] }] }\n', /inline table/], + ["escaped exceptions key", 'licenses."exc\\u0065ptions" = [{ crate = "x", allow = ["GPL-2.0"] }]\n', /quoted key with escape sequence/], + ["escaped exceptions key with quoted licenses", '"licenses"."exc\\u0065ptions" = [{ crate = "x", allow = ["GPL-2.0"] }]\n', /quoted key with escape sequence/], + ["escaped array of tables", '[[licenses."exc\\u0065ptions"]]\ncrate = "x"\n', /quoted key with escape sequence/], + ["escaped key in inline table", 'licenses = { "exc\\u0065ptions" = [{ crate = "x", allow = ["GPL-2.0"] }] }\n', /quoted key with escape sequence/], ]; it.each(FORMS)("rejects %s, also with comment and CRLF", (_n, body, re) => { @@ -158,18 +162,21 @@ describe("check-license-compat", () => { } }); - it( - "check-license-compat exits non-zero naming the form", - () => { - for (const [, body, re] of FORMS) { - const bad = spawnSync(process.execPath, [SCRIPT, raw(body)], { encoding: "utf8" }); - expect(bad.status).not.toBe(0); - expect(bad.stderr).toMatch(re); - } + it.each(FORMS)( + "check-license-compat exits non-zero naming the form: %s", + (_n, body, re) => { + const bad = spawnSync(process.execPath, [SCRIPT, raw(body)], { encoding: "utf8" }); + expect(bad.status).not.toBe(0); + expect(bad.stderr).toMatch(re); }, 30_000, ); + it("accepts a value string containing a backslash", () => { + const body = 'exceptions = [\n { crate = "x", allow = ["MIT"] },\n]\nnote = "a\\\\b \\u0041"\n'; + expect(parseExceptions(raw(body))).toEqual([{ crate: "x", allow: ["MIT"] }]); + }); + it("returns the sqlcipher-src entry of the repo deny.toml", () => { expect(parseExceptions(path.resolve(__dirname, "../../../../deny.toml"))).toEqual([ { crate: "sqlcipher-src", allow: ["blessing", "WTFPL"] }, diff --git a/scripts/generate-third-party-notices.mjs b/scripts/generate-third-party-notices.mjs index d0c65d7bd..aece22d3e 100644 --- a/scripts/generate-third-party-notices.mjs +++ b/scripts/generate-third-party-notices.mjs @@ -144,6 +144,41 @@ function parseAllowList(licensesFilePath) { return entries; } +// True when a basic-string key ("…" containing a backslash) appears in key +// position: before `=`/`.` or, in a table header, before `]`/`.`. Value +// strings with backslashes are not keys and stay accepted. Fail closed: +// escaped spellings are not decoded, just rejected. +function hasEscapedQuotedKey(line) { + const isHeader = /^\s*\[/.test(line); + let i = 0; + while (i < line.length) { + const c = line[i]; + if (c === "'") { + const e = line.indexOf("'", i + 1); + if (e < 0) return false; + i = e + 1; + } else if (c === '"') { + let j = i + 1; + let escaped = false; + while (j < line.length && line[j] !== '"') { + if (line[j] === "\\") { + escaped = true; + j++; + } + j++; + } + if (escaped) { + const next = line.slice(j + 1).match(/^\s*(.)/)?.[1]; + if (next === "=" || next === "." || (isHeader && next === "]")) return true; + } + i = j + 1; + } else { + i++; + } + } + return false; +} + // Per-Crate-Ausnahmen aus `[licenses] exceptions = [{ crate, allow }]` // (ADR 0135). cargo-about kennt sie als `[] accepted = [...]`. function parseExceptions(licensesFilePath) { @@ -158,6 +193,13 @@ function parseExceptions(licensesFilePath) { // General rule: any line using `exceptions` as a key (bare or quoted) other // than the supported `exceptions = [` block is rejected, so future spellings // fail closed too. + for (const line of content.split("\n")) { + if (hasEscapedQuotedKey(line)) { + fail( + `Nicht unterstützte Schreibweise der Ausnahmen in ${licensesFilePath} (quoted key with escape sequence): ${line.trim()} — bitte den Block "exceptions = [ … ]" unter [licenses] verwenden.`, + ); + } + } const keyRe = /(^|[\s.{,\[])(["']?)exceptions\2\s*(=|\]|\.|$)/; for (const line of content.split("\n")) { if (/^[ \t]*exceptions[ \t]*=[ \t]*\[/.test(line)) continue; From 3d43e9816803347f5347acc7cf8f91c272e079b2 Mon Sep 17 00:00:00 2001 From: "smart-ssh-coder[bot]" <338317697+smart-ssh-coder[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 18:33:38 +0000 Subject: [PATCH 2/2] ci: retrigger checks (#1599) Co-Authored-By: Claude Sonnet 5.5