Repository navigation
fix(license): reject array-of-tables and dotted deny.toml exceptions - #1596
smart-ssh-coordinator[bot] merged 3 commits into
Conversation
…1595) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Review
Verdict: changes requested
Review level: normal
Blocking
-
scripts/generate-third-party-notices.mjs:158-159— the array-of-tables alternative requires end-of-line right after]](…\bexceptions\s*\]\]|…)$). Comments are stripped before the match but the whitespace in front of them stays, so a header with a trailing comment or a trailing space is not recognised and the old silent[]comes back. Both are valid TOML, and cargo-deny accepts them. Reproduced:[[licenses.exceptions]] # GPL crate+crate = "x"/allow = ["GPL-2.0"]→parseExceptionsreturns[], andnode scripts/check-license-compat.mjs <file>exits 0.[[licenses.exceptions]](trailing space), same entry →[], exit 0.
This breaks AC 1 ("A deny.toml with the array-of-tables form makes
parseExceptionsthrow") and AC 4 (non-zero exit), and it is the same class of gap as the previous review on PR #1591 (a valid spelling silently skipped). Suggested fix: allow trailing horizontal whitespace before$(e.g.\]\][ \t]*in that alternative, or drop the anchor for that branch). Add a regression test with a trailing comment on the header that fails without the fix.
Non-blocking
apps/smart-ssh-community/frontend/src/licenseCompatCheck.test.ts:131-133—expect(bad.stderr).toContain("exceptions")is weak: any failure message that mentions the word passes. Asserting on the form (array of tables/dotted key) or the offending header would tie the assertion to AC 4's "with the message".- Quoted-key spellings (
[[licenses."exceptions"]],"licenses".exceptions = […]) and a top-level inline table (licenses = { exceptions = […] }) still return[](executed, see below). The issue does not name them, so this is not blocking. If you touch the regex anyway, it is cheap to cover them too.
Verified
- counter-proof: restored
scripts/generate-third-party-notices.mjsfromorigin/develop;rejects the array-of-tables form…,rejects the dotted-key formandcheck-license-compat exits non-zero for both alternative formsfailed (3 failed / 24 passed). With the PR version all 27 passed (executed:git checkout origin/develop -- scripts/generate-third-party-notices.mjs && npx vitest run src/licenseCompatCheck.test.ts, then restored). - edge cases (executed: small node script calling
parseExceptions, plusnode scripts/check-license-compat.mjs <file>):[[ licenses.exceptions ]]→ throws, ok- indented header → throws, ok
licenses . exceptions = […]→ throws, ok- CRLF line endings → exit 1 with the message, ok
- commented-out header / dotted key →
[], ok - header with trailing comment →
[], exit 0 → finding - header with trailing space →
[], exit 0 → finding - quoted keys / inline table →
[](outside the issue, non-blocking)
- repo
deny.toml:node scripts/check-license-compat.mjs→ exit 0 (executed). - callers checked:
parseExceptions(generator,check-license-compat.mjs, test). The signature is unchanged, and.d.mtsneeds no change (read). - tests run locally:
npx vitest run src/licenseCompatCheck.test.ts→ 27 passed;npm run lint→ exit 0 (executed). - files read: 2/2 logic files.
- CI: all checks green (
gh pr checks 1596). - UI: not a UI change.
- data: not touched.
Timing analysis
- 1 test file analysed.
licenseCompatCheck.test.ts:126-134runs twospawnSyncnode processes in one test. Under heavy load this could get close to the 15 s test timeout (possible, non-blocking; the existing test at 144-147 has the same pattern). Splitting it withit.eachper form would halve that. No other timing dependency.
Spec
- visible behaviour changed: none for app users. The build tooling now fails closed on two more
deny.tomlspellings. - spec searched:
rg -il 'exceptions|ausnahme' docs/specs/, and read the A12 lines in 0090. Spec 0090 A12 already says every allowed license must be GPL-3.0-compatible, enforced bycheck-license-compat. This PR fixes a hole in that enforcement. - verdict: not needed, because the PR fixes already specified behaviour (0090 A12). No changelog fragment is needed for internal tooling.
Security checks
- Build tooling only; no filter, redaction, credential or execution path is touched. The fail-closed direction is respected (rejection, not parsing). The gap above is a fail-open on one form.
Threat model: no changeis fine for build tooling. - Public boundary: title, body and commit are in English, with no internals.
Follow-ups
- Quoted-key and inline-table spellings of the
deny.tomlexceptions still parse as "no exceptions" (no existing issue).
#1595) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Review
Verdict: changes requested
Review level: normal
Blocking
-
scripts/generate-third-party-notices.mjs:154together with:158-159: the header fix works for LF files. With CRLF line endings, a header with a trailing comment still returns[]. The comment stripl.replace(/#.*$/, "")runs per line aftersplit("\n"), so each line still ends in\r. In JavaScript.does not match\r, and$without themflag only matches at the end of the string. So/#.*$/does not match a line such as[[licenses.exceptions]] # note\r, and the comment stays in place. The array-of-tables regex then sees#after]]and does not match. Reproduced (executed):- a file with CRLF endings containing
[[licenses.exceptions]] # n/crate = "x"/allow = ["GPL-2.0"]→parseExceptionsreturns[], andnode scripts/check-license-compat.mjs <file>exits 0. - the same file with LF endings → exit 1 (fixed in de0b2d9).
- CRLF without a comment → exit 1, which is fine because
$withmalso matches before\r.
This is realistic.
.gitattributesforces LF only for*.rs, sodeny.tomlis checked out with CRLF on Windows (core.autocrlf=true), andnpm run lint(which runscheck-license-compat) runs on the Windows CI job. This is the same fail-open as in the last round, which breaks AC 1 and AC 4. It also affects the leftover check inside the block: a commented-out entry on a CRLF line is not stripped there either. Suggested fix: split on/\r?\n/, or strip with/#[^\n]*///#.*$/m. Add a regression test with a CRLF header that has a trailing comment and that fails without the fix. - a file with CRLF endings containing
Non-blocking
licenseCompatCheck.test.ts: the spawn test still asserts onlytoContain("exceptions")(carried over from the last round, not addressed).
Verified
- counter-proof: I restored
scripts/generate-third-party-notices.mjsfrom 929ced2.rejects headers with a trailing comment or whitespacethen failed (1 failed). With HEAD the whole file passes, 28 tests (executed:npx vitest run src/licenseCompatCheck.test.ts [-t 'trailing comment'], then restored;git statusclean). - edge cases (executed:
node scripts/check-license-compat.mjs <file>and a directparseExceptionscall):- LF header +
# comment→ exit 1, ok - LF header + trailing spaces/tab → exit 1, ok
- CRLF header, no comment → exit 1, ok
- CRLF header +
# comment→[], exit 0 → finding - dotted key with trailing comment → exit 1, ok
- commented-out header → exit 0, ok
- LF header +
- repo
deny.toml:node scripts/check-license-compat.mjs→ exit 0 (executed). - callers checked:
parseExceptions(generator,check-license-compat.mjs, test). Unchanged since the last round (read). - tests run locally:
npx vitest run src/licenseCompatCheck.test.ts→ 28 passed (executed). - files read: 2/2 logic files (delta 929ced2..de0b2d9).
- CI: all checks green (
gh pr checks 1596). - UI: not a UI change.
- data: not touched.
Timing analysis
- 1 test file analysed (the new test in the delta): it is synchronous with no timers or async, so no timing dependency was found.
Spec
- visible behaviour changed: none for app users (build tooling).
- spec searched (round 1:
rg -il 'exceptions|ausnahme' docs/specs/): 0090 A12 already covers the behaviour. - verdict: not needed, because the PR fixes already specified behaviour (0090 A12).
Security checks
- Build tooling only. The fail-closed direction is respected, except for the CRLF fail-open above.
- Public boundary: the new commit message is in English and contains no internals.
Previous findings
- trailing comment / trailing whitespace on the array-of-tables header → fixed in de0b2d9 for LF files. It is still open for CRLF files (see Blocking).
- weak
toContain("exceptions")assertion (non-blocking) → still open. - quoted-key / inline-table spellings (follow-up) → still open, stays a follow-up.
Follow-ups
- Quoted-key and inline-table spellings of the
deny.tomlexceptions still parse as "no exceptions" (no existing issue;follow-up-pendingis already set).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Review point 1 (CRLF |
There was a problem hiding this comment.
Review
Verdict: approved
Review level: normal
Blocking
None.
Non-blocking
apps/smart-ssh-community/frontend/src/licenseCompatCheck.test.ts:124,142: the newspawnSynctests start Node child processes under Vitest's default 5 s timeout. On a slow runner this could be tight. An explicit per-test timeout would make it robust (possible, not observed).- Carried over from round 1: assert on the form name (
array of tables/dotted key) in the spawn test instead of onlyexceptions. Quoted-key ("licenses".exceptions) and inline-table (licenses = { exceptions = [...] }) spellings still return[]silently.
Verified
- counter-proof: I reverted the CRLF fix to
.split("\n").rejects a CRLF header with a trailing commentthen failed and passed again once the fix was back (executed:npx vitest run src/licenseCompatCheck.test.ts -t CRLF). Against theorigin/developparser, 5 of the new tests fail. The sixth, the commented-out header test, passes on both versions, which is expected (executed). - tests run locally:
npx vitest run src/licenseCompatCheck.test.ts→ 29 passed (executed).npm run lint→ exit 0 (executed).node scripts/check-license-compat.mjson the repo deny.toml → exit 0 (executed). - edge cases (executed:
check-license-compat.mjson temp deny.toml files with CRLF line endings throughout):[[licenses.exceptions]]CRLF → exit 1.[[ licenses.exceptions ]] # c→ exit 1.licenses.exceptions=[…]CRLF → exit 1.licenses . exceptions = [multi-line → exit 1. Commented-out header CRLF → exit 0. Block form with CRLF → parsed, GPL-2.0 is reported. - callers checked:
parseExceptions(3 call sites:check-license-compat.mjs:34, generator:720, test) → ok. Stripping\ronly normalises input for the later block parsing. - files read: 2/2 logic files (full diff)
- UI: not a UI change
- data: not touched
- CI: all checks green on f32410e (read:
gh pr checks 1596)
Timing analysis
- 1 test file analysed:
licenseCompatCheck.test.ts:124,142—spawnSyncwith no explicit test timeout, possible → non-blocking. Nothing else depends on timing.
Spec
- visible behaviour changed: none. This is build tooling: the compat check now fails closed on spellings it cannot read.
- spec searched (
rg -il 'deny.toml|exceptions|Ausnahme' docs/specs/), spec covering it: 0090 A12 (license compatibility gate), 0099 - verdict: not needed. The PR fixes already specified behaviour: a declared exception must not be skipped silently.
Security checks
- No runtime code and no security-critical path. Changes are fail-closed only, and no check is loosened: the existing block parsing is unchanged apart from CRLF normalisation. Threat model note present and correct. No external requests.
Previous findings (follow-up round only)
- Round 1: header with a trailing comment or whitespace → fixed in de0b2d9 (verified then).
- Round 2: CRLF header with a trailing comment → fixed in f32410e (split on
/\r?\n/, regression test red without the fix, green with it).
Follow-ups
- Reject the quoted-key and inline-table spellings of
licenses.exceptionsas well. No open issue yet; the issue carriesfollow-up-pending. - Add an explicit timeout to the spawn-based tests in
licenseCompatCheck.test.ts.
Closes #1595
Summary
parseExceptionsnow throws (exit 1 via the existing error path) when deny.toml declares exceptions as[[licenses.exceptions]]orlicenses.exceptions = [...], telling the user to use theexceptions = [ … ]block. Comments are stripped first, so commented-out forms are ignored.Acceptance Criteria
licenseCompatCheck.test.ts:rejects the array-of-tables form, naming the form)rejects the dotted-key form)ignores a commented-out array-of-tables header)check-license-compat exits non-zero for both alternative forms, existing...for an unparseable entrycovers exit 0)Tests
Counter-proof: with the parser change stashed, the 3 new throwing tests fail.
Assumptions
Rejection regex matches any
[[...exceptions]]header andlicenses.exceptions =.Spec: none (build tooling, fail-closed hardening)
Threat model: no change – build tooling only
Changelog: no fragment (internal tooling)
Manual test steps
None.
Follow-ups
None.
🤖 Generated with Claude Code