Skip to content

fix(deps): resolve all npm audit vulnerabilities (39 → 0) - #220

Merged
lampajr merged 2 commits into
kiegroup:mainfrom
lampajr:super_audit
Jul 25, 2026
Merged

fix(deps): resolve all npm audit vulnerabilities (39 → 0)#220
lampajr merged 2 commits into
kiegroup:mainfrom
lampajr:super_audit

Conversation

@lampajr

@lampajr lampajr commented Jul 25, 2026

Copy link
Copy Markdown
Member

Summary

Brings npm audit from 39 vulnerabilities (31 high, 8 moderate) to 0, in two logically separate commits.

All 39 issues traced to three root packages; everything else was transitive.

Commit 1 — dev-only transitive vulns via overrides (39 → 6)

Zero-risk, no direct dependency versions changed:

  • brace-expansion5.0.8 — clears the minimatch/glob cascade across eslint, @typescript-eslint, jest, and babel tooling (~31 high).
  • undici override bumped 6.24.16.28.0 (the previous pin was itself still vulnerable, fix landed in 6.27.0) — clears the release-it chain.

Commit 2 — @octokit/rest 18 → 22 (6 → 0)

The only vulnerability affecting production/runtime code (3× ReDoS in the octokit request chain). v22 is ESM-only and uses native fetch, which required test-infra changes:

  • jest: transpile the ESM @octokit/* deps via ts-jest + whitelist them in transformIgnorePatterns so jest's CJS runtime can load them.
  • @kie/mock-github 1.1.0 → 2.0.2 (nock 14) so mocks intercept native fetch; nock 13 only hooks the http/https modules.
  • Codeberg mocks: pass explicit path params to previously no-arg endpoint mocks. Moctokit builds an anchored regex path for no-arg mocks, which nock does not prefix with Codeberg's /api/v1 base path → no-match.
  • listCommitsParams helper to work around mock-github 2.0.2 typing GET endpoints (e.g. pulls.listCommits) as params?: undefined.

Tradeoff to note for reviewers

@kie/mock-github@2.0.2 requires Node ≥24, so the CI test matrix drops Node 20/22 ([20,22,24][24]; coverage job 22 → 24). This is a test-tooling constraint only:

  • No engines constraint is added to package.json. The published dist/ is a self-contained ncc bundle, so end users on older Node are unaffected; only contributors running the test suite need Node 24.
  • The alternative (keep Node 20/22 support) was migrating the HTTP mocks from Moctokit/nock to undici's MockAgent — a larger test rewrite. Happy to go that route instead if maintaining the wider Node range is preferred.

Verification

  • npm audit0 vulnerabilities
  • npm test220/220 passing
  • npm run lint → clean
  • npm run builddist/ rebuilt and in sync (verify-dist check passes); bundle is smaller (octokit v22 is leaner)

lampajr added 2 commits July 25, 2026 10:44
Override brace-expansion to 5.0.8 (patched, clears the minimatch/glob
cascade across eslint, @typescript-eslint, jest and babel tooling) and
bump the undici override from the still-vulnerable 6.24.1 to 6.28.0.

Reduces npm audit from 39 vulnerabilities (31 high) to 6 (all moderate,
all in the @octokit/rest production chain, addressed separately).
Lint clean, 220/220 tests pass.
…lities

Bumps @octokit/rest 18 -> 22.0.1, resolving the remaining ReDoS advisories
in the octokit request chain and bringing npm audit to 0 vulnerabilities.

@octokit/rest v22 is ESM-only and uses native fetch, which required:
- jest.config: transpile the ESM @octokit/* deps via ts-jest and whitelist
  them in transformIgnorePatterns so jest's CJS runtime can load them.
- @kie/mock-github 1.1.0 -> 2.0.2 (nock 14) so mocks intercept native fetch;
  nock 13 only intercepts the http/https modules.
- Codeberg mocks: pass explicit path params to previously no-arg endpoint
  mocks. Moctokit builds an anchored regex path for no-arg mocks, which nock
  does not prefix with Codeberg's /api/v1 base path, causing no-match.
- listCommitsParams helper to work around mock-github 2.0.2 typing GET
  endpoints (e.g. pulls.listCommits) with `params?: undefined`.

mock-github 2.0.2 requires Node >=24, so the CI test matrix drops Node 20/22.
No engines constraint is added: the published dist/ is a self-contained ncc
bundle, so end users are unaffected; only contributors running tests need 24.
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
89.55% (+0.16% 🔼)
574/641
🟢 Branches 85% 272/320
🟢 Functions 87.66% 135/154
🟢 Lines
89.37% (+0.16% 🔼)
555/621

Test suite run success

220 tests passing in 18 suites.

Report generated by 🧪jest coverage report action from 20826ae

@lampajr
lampajr merged commit 84c49d5 into kiegroup:main Jul 25, 2026
5 checks passed
@lampajr
lampajr deleted the super_audit branch July 25, 2026 09:05
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