Skip to content

Added trim override#27676

Merged
9larsons merged 1 commit intomainfrom
security/trim-override
May 5, 2026
Merged

Added trim override#27676
9larsons merged 1 commit intomainfrom
security/trim-override

Conversation

@9larsons
Copy link
Copy Markdown
Contributor

@9larsons 9larsons commented May 5, 2026

Why

GHSA-w5p7-h5w8-2hfq (high, ReDoS in trim's whitespace pattern, fixed in 0.0.3) reaches the tree via remark@11 → remark-parse@7 → trim@0.0.1. remark-parse@7 is locked into trim@0.0.1 by its declared range, so the only way to clear the advisory short of replacing remark is a transitive override.

It's worth noting that bumping @tryghost/url-utils from 5.1.2 to 5.2.3 doesn't help here — both versions transit the same remark@11 → remark-parse@7 chain to land on the same trim@0.0.1. The override is the cleanest fix until a future @tryghost/url-utils (or @tryghost/kg-default-cards) release adopts a newer remark major.

^0.0.3 keeps the override inside the same pre-1.0 line so the trim() function signature stays identical for the remark callers consuming it; pinning into 1.x would technically be available but introduces a major-version boundary for a transitive dependency that doesn't otherwise need to move.

Test plan

  • pnpm install — lockfile updates cleanly; trim resolves to 0.0.3 from inside ghost/core
  • pnpm audit — total findings 59 → 58, unique GHSAs 47 → 46; the trim advisory is cleared
  • pnpm test — 6283/6283 ghost/core unit tests pass (the one comments-ui editor markdown flake reproduces on clean main and is unrelated)
  • CI confirms the same delta against the canonical environment

- GHSA-w5p7-h5w8-2hfq (high, ReDoS in trim's whitespace pattern, fixed in
  0.0.3) reaches the tree via remark@11 → remark-parse@7 → trim@0.0.1.
  remark-parse@7 is locked into trim@0.0.1 by its declared range
- Both @tryghost/url-utils@5.1.2 (ghost/core direct) and 5.2.3 (via
  @tryghost/kg-default-cards@10.3.1) traverse the same remark chain, so
  bumping url-utils alone wouldn't reach trim — a transitive override is
  the right tool
- ^0.0.3 keeps the override inside the same pre-1.0 line so the function
  signature trim() stays identical for all upstream remark callers
- Verified: pnpm audit drops 47 → 46 unique GHSAs (59 → 58 findings); trim
  resolves to 0.0.3; pnpm test passes (6283/6283 ghost/core; one
  pre-existing comments-ui editor markdown flake reproduces on clean main
  and is unrelated)
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

Walkthrough

The change modifies the package.json file by adding a new entry to the pnpm.overrides configuration. Specifically, it introduces an override for the trim package that forces versions below 0.0.3 to resolve to ^0.0.3. The new override entry is inserted between existing override entries for the tmp and undici packages. No other package.json fields or scripts are affected by this change.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Added trim override' directly and accurately describes the main change—adding a pnpm.overrides entry for trim@<0.0.3.
Description check ✅ Passed The description is directly related to the changeset, explaining the security advisory, why the override is necessary, the chosen version range, and comprehensive test results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch security/trim-override

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
package.json (2)

100-100: 💤 Low value

^0.0.3 effectively pins to exactly 0.0.3, not the full pre-1.0 range

The PR description states the range "keeps the override within the pre-1.0 line," but for 0.0.Z packages, the caret locks the version entirely — no updates are allowed. Specifically, the npm semver spec defines ^0.0.3 as >=0.0.3 <0.0.4, not >=0.0.3 <1.0.0.

In practice this is harmless: trim's latest published version is 1.0.1 and there is no 0.0.4, so both ranges resolve to the same 0.0.3. The security fix is valid. If the intent genuinely is to allow any compatible pre-1.0 patch that might land, consider making it explicit:

♻️ Optional — express the pre-1.0 intent more clearly
-      "trim@<0.0.3": "^0.0.3",
+      "trim@<0.0.3": ">=0.0.3 <1.0.0",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` at line 100, The trim override entry "trim@<0.0.3": "^0.0.3"
currently pins to >=0.0.3 <0.0.4 (caret in 0.0.Z locks patch), so if your intent
is to allow wider pre-1.0 updates change the version range for the "trim@<0.0.3"
entry to an explicit range such as ">=0.0.3 <0.1.0" (to allow any 0.0.x → 0.0.*
patches within 0.1.0) or ">=0.0.3 <1.0.0" (if you intended any pre-1.0 release),
and update the package.json dependency key accordingly.

100-100: 💤 Low value

^0.0.3 pins to exactly 0.0.3, not the full pre-1.0 range

The PR description says this keeps "the override within the pre-1.0 line," but under npm semver, ^0.0.3 expands to >=0.0.3 <0.0.4, locking to the patch slot only. Since trim progressed directly from 0.0.3 to 1.0.0 with no intermediate patches, both interpretations resolve to the same version today, so the override works correctly. If intent is to permit any compatible fix in the 0.x line, consider:

-      "trim@<0.0.3": "^0.0.3",
+      "trim@<0.0.3": ">=0.0.3 <1.0.0",

Either way, the vulnerability is fixed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` at line 100, The dependency override "trim@<0.0.3": "^0.0.3" in
package.json uses ^ with a 0.0.x version which only allows patch upgrades
(>=0.0.3 <0.0.4); update the override to allow the full 0.x range by replacing
the version spec with a semver range like ">=0.0.3 <1.0.0" (or another explicit
0.x range you intend) so the override covers all compatible 0.x fixes for the
trim package.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@package.json`:
- Line 100: The trim override entry "trim@<0.0.3": "^0.0.3" currently pins to
>=0.0.3 <0.0.4 (caret in 0.0.Z locks patch), so if your intent is to allow wider
pre-1.0 updates change the version range for the "trim@<0.0.3" entry to an
explicit range such as ">=0.0.3 <0.1.0" (to allow any 0.0.x → 0.0.* patches
within 0.1.0) or ">=0.0.3 <1.0.0" (if you intended any pre-1.0 release), and
update the package.json dependency key accordingly.
- Line 100: The dependency override "trim@<0.0.3": "^0.0.3" in package.json uses
^ with a 0.0.x version which only allows patch upgrades (>=0.0.3 <0.0.4); update
the override to allow the full 0.x range by replacing the version spec with a
semver range like ">=0.0.3 <1.0.0" (or another explicit 0.x range you intend) so
the override covers all compatible 0.x fixes for the trim package.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e11bf61c-9946-4967-8038-48366730f1b3

📥 Commits

Reviewing files that changed from the base of the PR and between 06bf5a7 and c6df241.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • package.json

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.19%. Comparing base (06bf5a7) to head (c6df241).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #27676   +/-   ##
=======================================
  Coverage   73.19%   73.19%           
=======================================
  Files        1561     1561           
  Lines      127072   127072           
  Branches    15397    15396    -1     
=======================================
+ Hits        93012    93013    +1     
  Misses      33101    33101           
+ Partials      959      958    -1     
Flag Coverage Δ
admin-tests 49.88% <ø> (+0.01%) ⬆️
e2e-tests 73.19% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@9larsons 9larsons enabled auto-merge (squash) May 5, 2026 17:13
@9larsons 9larsons merged commit 45490b5 into main May 5, 2026
46 checks passed
@9larsons 9larsons deleted the security/trim-override branch May 5, 2026 17:24
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