Commit 38447ef
chore(security): replace SheetJS xlsx with exceljs (#2945)
## Summary
Resolves the only outstanding **high/critical** Dependabot security
alerts in the repository, both against the SheetJS `xlsx` package:
| Advisory | Severity | Issue |
| --- | --- | --- |
|
[GHSA-4r6h-8v6p-xvw6](GHSA-4r6h-8v6p-xvw6)
| High (CVSS 7.8) | Prototype Pollution in SheetJS |
|
[GHSA-5pgg-2g8v-p4x9](GHSA-5pgg-2g8v-p4x9)
| High (CVSS 7.5) | SheetJS Regular Expression Denial of Service (ReDoS)
|
### Why a version bump can't fix this
Both advisories are recorded with `introduced: 0` and **no fixed
version** in the npm ecosystem. SheetJS stopped publishing to the npm
registry after `0.18.5`; patched builds live only on the SheetJS CDN.
The repo already pinned the CDN-hosted, patched `xlsx@0.20.3`, but
Dependabot/GHSA still flag it because there is no registry release that
clears the advisory range. The only durable remediation is to stop
depending on `xlsx`.
### Change
- **`apps/api/src/lib/file-extract.ts`** — migrate knowledge-base
spreadsheet extraction from `xlsx` to the actively-maintained
[`exceljs`](https://www.npmjs.com/package/exceljs) (no open
high/critical advisories). Each worksheet is converted to CSV with
standard field quoting (commas, quotes, and newlines are escaped).
- **`apps/api/package.json` / `pnpm-lock.yaml`** — drop `xlsx`, add
`exceljs@4.4.0`.
- **`apps/playground/.../projects-page-client.tsx`** — stop advertising
legacy binary `.xls` in the upload picker.
- **`file-extract.spec.ts`** — build fixtures with `exceljs`; add a
CSV-quoting case and a case asserting unreadable spreadsheet data is
rejected.
### Behavior note
`exceljs` reads modern `.xlsx` but cannot parse the legacy binary `.xls`
(BIFF) format. `.xlsx` extraction is unchanged. Legacy `.xls` uploads
(rare; Excel has defaulted to `.xlsx` since 2007) are no longer
advertised in the picker and are rejected cleanly by the existing upload
error path rather than being indexed as garbage.
## Verification
- `osv-scanner` on the updated lockfile: **0 high/critical** remaining
(previously 2).
- `pnpm format` — clean
- `turbo run build` (full monorepo) — passes
- `apps/api` unit tests (`file-extract.spec.ts`) — 6/6 pass; `tsc
--noEmit` clean
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---
_Generated by [Claude
Code](https://claude.ai/code/session_015JboNg5ryVipY8M6nzJykR)_
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Improved spreadsheet upload handling for modern `.xlsx` files,
including workbooks with multiple sheets (combined output with sheet
names).
* **Bug Fixes**
* CSV generation now properly escapes fields (commas, quotes, and
newlines).
* Invalid/unreadable spreadsheet inputs are rejected instead of
returning incorrect results.
* **Chores**
* Updated the supported upload formats by removing legacy `.xls` from
the upload flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Claude <noreply@anthropic.com>1 parent af9cf38 commit 38447ef
5 files changed
Lines changed: 566 additions & 118 deletions
File tree
- apps
- api
- src/lib
- playground/src/components/playground
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
55 | | - | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | | - | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
6 | 16 | | |
7 | 17 | | |
8 | 18 | | |
| |||
14 | 24 | | |
15 | 25 | | |
16 | 26 | | |
17 | | - | |
18 | | - | |
| 27 | + | |
19 | 28 | | |
20 | 29 | | |
21 | 30 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | | - | |
| 45 | + | |
43 | 46 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | 47 | | |
50 | 48 | | |
51 | | - | |
52 | | - | |
| 49 | + | |
| 50 | + | |
53 | 51 | | |
54 | 52 | | |
55 | | - | |
56 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
57 | 64 | | |
58 | 65 | | |
59 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | | - | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
23 | 45 | | |
24 | 46 | | |
25 | 47 | | |
| |||
39 | 61 | | |
40 | 62 | | |
41 | 63 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
47 | 72 | | |
48 | 73 | | |
49 | 74 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
0 commit comments