Skip to content

Fail closed on deny.toml lines where a '#' inside a string hides exceptions #1601

Description

@smart-ssh-planner

Goal

The deny.toml exceptions check no longer silently ignores a deny.toml exceptions entry that follows a string containing # on the same line.

Context

Follow-up of #1599 (PR #1600): the review noticed that comment stripping in parseExceptions (scripts/generate-third-party-notices.mjs:189, l.replace(/#.*$/, "")) also cuts at a # inside a string. A line such as licenses = { allow = ["#"], exceptions = [{ crate = "x", allow = ["GPL-2.0"] }] } therefore makes parseExceptions return [] with no message, and the exception form is neither read nor rejected. The same applies to a "exceptions" spelling after such a string. Confirmed on develop and on the PR branch. Callers: generate-third-party-notices.mjs:773 and check-license-compat.mjs. Spec 0090 A12 (allowed dependency terms, single sqlcipher-src exception) implies an unreadable exception list must not pass silently.

Requirements

  • Comment stripping only removes a # that is outside a basic string ("…", with backslash escapes) or a literal string ('…'). Chosen option: a small string-aware stripper.
  • Behaviour for ordinary comments, commented-out forms and CRLF stays unchanged.
  • Existing rejections stay unchanged.

Acceptance Criteria

  • The one-line example above (with "#" in allow) is parsed to the x exception, or rejected with a message naming the form; it never yields [] silently.
  • A # inside a basic string and inside a literal string does not start a comment.
  • A real trailing comment after a string is still stripped; commented-out exceptions forms still do not throw.
  • CRLF input behaves the same as LF.
  • The repo deny.toml still parses to the sqlcipher-src entry.
  • Regression tests in licenseCompatCheck.test.ts fail against the current parser and pass with the fix.
  • Relevant automated tests pass (npx vitest run src/licenseCompatCheck.test.ts, npm run lint)

Technical Notes

Build tooling only; fail-closed direction, nothing may be loosened. Line 251 (replace(/#[^\n]*/g, "") on the block rest) has the same pattern; check whether it needs the same treatment.

Files: scripts/generate-third-party-notices.mjs, apps/smart-ssh-community/frontend/src/licenseCompatCheck.test.ts

Spec impact: none

Open questions

  • Alternative: reject any line with # inside a string instead of parsing it. Simpler, but rejects valid files; the string-aware stripper is recommended.

Related Work

Activity

  1. added
    tests
    follow-up
    on Nov 25, 2026
  2. smart-ssh-coder commented on Nov 25, 2026

    @smart-ssh-coder
    Contributor

    Implementation ready for review. PR #1602. parseExceptions now strips deny.toml comments string-aware (basic and literal strings), so a # inside a string no longer hides an exceptions form; regression tests added (fail on old parser), CI green on PR #1602.

  3. smart-ssh-reviewer commented on Nov 25, 2026

    @smart-ssh-reviewer

    Review passed – moving on to merge. Approved. parseExceptions now strips deny.toml comments only outside basic and literal strings. A '#' inside a string can no longer hide an exceptions form: the issue's one-line example is rejected as an inline table, for LF and CRLF. Counter-proof done: the new regression test fails against the develop parser and passes with the fix. Removing the second comment strip on the block rest only makes the parser stricter. Existing rejections, the repo deny.toml (sqlcipher-src) and both callers are unchanged. Local runs: vitest 54 passed, npm run lint clean. CI is green. Spec none is correct (build tooling, Spec 0090 A12 unchanged).

  4. smart-ssh-coordinator commented on Nov 25, 2026

    @smart-ssh-coordinator
    Contributor

    Merged and branch deleted: PR #1602 (squash) in develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-uptests

    Type

    Fields

    Priority

    P3 - Low

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions