Skip to content

fix(security): linear-time email redaction and read-only CI token - #31

Merged
BenKalsky merged 2 commits into
mainfrom
fix/codeql-alerts
Oct 27, 2026
Merged

BenKalsky merged 2 commits into
mainfrom
fix/codeql-alerts

Conversation

@BenKalsky

Copy link
Copy Markdown
Member

Fixes the two open CodeQL alerts (digitizer-tasks#192).

  • js/polynomial-redos (src/index.ts):
    • Problem: the email pattern in redactSensitiveText restarted at every offset of a long run of [\w.+-] with no @, so input from the library's callers could take quadratic time. 50,000 + characters took about 1.6 s.
    • Fix: a lookbehind (?<![\w.+-]) anchors each match at the start of a run. Matches and output are unchanged.
    • Test: a regression test redacts an email in free text and bounds the hostile input to 500 ms.
  • actions/missing-workflow-permissions: CI now runs with permissions: contents: read.

Local: pnpm typecheck clean, pnpm test 38/38.

🤖 Generated with Claude Code

redactSensitiveText's email pattern restarted at every offset of a long run
with no '@' (CodeQL js/polynomial-redos): 50,000 '+' took ~1.6 s. A lookbehind
now anchors each match at the start of a run. Regression test included.
CI gets permissions: contents: read (actions/missing-workflow-permissions).

Closes Digitizers/digitizer-tasks#192 (with the PR merged).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@BenKalsky

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T12:05:30.803827Z a041e6f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d2e03237a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/index.ts Outdated
.replace(/[\w.+-]+@[\w.-]+/g, "[REDACTED]")
// The lookbehind anchors each match at the start of a run, so a long run of
// local-part characters with no "@" is scanned once instead of once per offset.
.replace(/(?<![\w.+-])[\w.+-]+@[\w.-]+/g, "[REDACTED]")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve redaction of adjacent email matches

When free text contains addresses joined by +, such as first@example.com+second@example.com, the first match consumes first@example.com, but the new lookbehind prevents the next match from starting because its preceding character belongs to the consumed domain. The result is [REDACTED]+second@example.com, whereas the previous pattern redacted both addresses. This also exposes the second address through redactSumitPayload when it appears in diagnostic text. Preserve matching at the end of a previously consumed match while retaining the linear-time behavior.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a041e6f: dropped the lookbehind and capped the local part at 64 characters (RFC 5321) instead. first@example.invalid+second@example.invalid now gives [REDACTED][REDACTED], and the test covers it. 50,000 + now take ~9 ms, 200,000 a ~32 ms. One trade-off: a local part longer than 64 characters keeps its first characters visible; real addresses can't exceed 64.

The lookbehind stopped a second address from matching right after the first
one's domain (first@a.com+second@b.com left the second unredacted; Codex P2).
A {1,64} bound on the local part (RFC 5321 limit) keeps the scan linear and
redacts adjacent addresses. Test covers the adjacent case.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@BenKalsky

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: a041e6f04c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@BenKalsky
BenKalsky merged commit 69ed664 into main Oct 27, 2026
4 checks passed
@BenKalsky
BenKalsky deleted the fix/codeql-alerts branch October 27, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant