-
Notifications
You must be signed in to change notification settings - Fork 0
fix(security): clear CodeQL self-gate (complete sanitization, no double-escaping, atomic FS ops) #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix(security): clear CodeQL self-gate (complete sanitization, no double-escaping, atomic FS ops) #39
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # CodeQL analysis scope for tg-cli. | ||
| # | ||
| # The security gate analyzes the SHIPPED product surface — the `tg` / `tg-ctl` | ||
| # binaries built from `features/` plus the workflow files. `scripts/` holds | ||
| # one-off developer asset-generators (emoji/sticker set builders) that are run | ||
| # BY HAND, never bundled into the released CLIs, and never process untrusted | ||
| # input. CodeQL's js/file-access-to-http there ("an outbound request URL/body | ||
| # depends on local file data") is true and intentional: they read a bot token / | ||
| # prompt from a local config file and call an HTTP API with it. That is the job, | ||
| # not a vulnerability — and it is out of scope for a gate meant to protect the | ||
| # product. | ||
| # | ||
| # Why a directory `paths-ignore` and not a query-level exclude: `query-filters` | ||
| # match on query METADATA only (id/tags/kind), with no per-path scoping, so | ||
| # excluding `js/file-access-to-http` by id would also blind the gate to that | ||
| # class in shipped `features/` code. Scoping by PATH keeps every query — this one | ||
| # included — fully enforced on the product surface; only the by-hand `scripts/` | ||
| # dir is out of scope. Tradeoff: a FUTURE script is not auto-analyzed; given the | ||
| # dir is three hand-run generators, that is acceptable. Move a script into | ||
| # `features/` (or import it from shipped code) and it is gated again. | ||
| # | ||
| # This is a SCOPE decision (which code the gate guards), not a per-finding | ||
| # suppression of a real bug in shipped code. | ||
| paths-ignore: | ||
| - scripts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // --- Regex utilities (pure) --- | ||
| // | ||
| // escapeRegExp turns an arbitrary string into a literal that is safe to splice | ||
| // into a `new RegExp(...)` source. It escapes the FULL set of ECMAScript regex | ||
| // metacharacters — not just one or two — so building a pattern from external or | ||
| // structured tokens can never let a stray `.`, `\`, `(`, `[`, etc. change the | ||
| // pattern's meaning. A partial escaper (e.g. one that handles `-` but leaves | ||
| // `\` untouched) is what CodeQL flags as js/incomplete-sanitization; this is the | ||
| // single, complete source of truth both render/rich and install-skill use. | ||
| export function escapeRegExp(s: string): string { | ||
| return s.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&"); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
~/.claude/settings.jsonexists but cannot be read as a normal file (for example it is a directory, has bad permissions, or a transient read error occurs),readTextIfExists()rethrows before the existing parse/error guard runs. The previous implementation had the read inside thetryand returnedfalse, conservatively skipping the hook; this change now abortsinstall-skillafter it may already have written other files. Move this read back under the guard or catch non-ENOENT errors here and returnfalse.Useful? React with 👍 / 👎.