xlvane 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -6
- package/dist/cli.js +125 -45
- package/dist/index.d.ts +33 -11
- package/dist/index.js +3 -3
- package/dist/{node-files-CDb6TyZb.js → node-files-SVg17pky.js} +2 -2
- package/dist/node.d.ts +1 -1
- package/dist/node.js +3 -3
- package/dist/{options-Ba1iWD-Z.js → options-Cxt-LJE4.js} +8107 -6923
- package/dist/{rows-IWKIxHt9.js → rows-DltZ-hiW.js} +1116 -396
- package/dist/{stream-write-BGuUjlXo.js → stream-write-D573ewpr.js} +112 -16
- package/dist/{stream-write-BVaFkgwO.d.ts → stream-write-XnCyLdOy.d.ts} +354 -8
- package/docs/cli-json/inspect.schema.json +76 -0
- package/docs/errors.md +33 -12
- package/docs/exceljs-compat.md +32 -12
- package/docs/inspect-json.md +4 -0
- package/docs/migrate-from-exceljs.md +131 -0
- package/docs/xlsx-cves.md +88 -0
- package/llms-full.txt +422 -32
- package/package.json +1 -1
- package/skills/xlvane/SKILL.md +14 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# How to fix the CVEs in the `xlsx` package from npm
|
|
2
|
+
|
|
3
|
+
xlvane is not affiliated with SheetJS or with the ExcelJS project. Their names are used only to identify the packages this page is about; the facts below are quoted from the cited advisories and registry data, and the fixes SheetJS publishes are listed first.
|
|
4
|
+
|
|
5
|
+
The `xlsx` package on npm is the SheetJS Community Edition. Its latest version on npm is 0.18.5, published on 2022-03-24, and two published advisories cover that version. The fixed versions are distributed by SheetJS outside npm. This page lists the facts with their sources and two ways to deal with them: the fixed SheetJS version, or moving to xlvane. The sources were read on 2026-11-03.
|
|
6
|
+
|
|
7
|
+
## The advisories
|
|
8
|
+
|
|
9
|
+
| CVE | GitHub advisory | What | Affected | Fixed in |
|
|
10
|
+
|---|---|---|---|---|
|
|
11
|
+
| CVE-2023-30533 | [GHSA-4r6h-8v6p-xvw6](https://github.com/advisories/GHSA-4r6h-8v6p-xvw6) | Prototype pollution when reading specially crafted files (CWE-1321) | SheetJS CE through 0.19.2, including every version of `xlsx` on npm | 0.19.3 |
|
|
12
|
+
| CVE-2024-22363 | [GHSA-5pgg-2g8v-p4x9](https://github.com/advisories/GHSA-5pgg-2g8v-p4x9) | Regular expression denial of service, ReDoS (CWE-1333) | SheetJS CE before 0.20.2, including every version of `xlsx` on npm | 0.20.2 |
|
|
13
|
+
|
|
14
|
+
- GitHub rates both advisories "high" (CVSS 3.1 base scores 7.8 for CVE-2023-30533 and 7.5 for CVE-2024-22363, as listed by the npm registry's advisory data).
|
|
15
|
+
- GHSA-4r6h-8v6p-xvw6 says: "Workflows that do not read arbitrary files (for example, exporting data to spreadsheet files) are unaffected."
|
|
16
|
+
- Both GitHub advisories say: "A non-vulnerable version cannot be found via npm", and that the fixed version (0.19.3, and 0.20.2) "can be downloaded via https://cdn.sheetjs.com/".
|
|
17
|
+
- The CVE records (published 2023-04-24 and 2024-04-05) give the same affected and fixed versions and link to SheetJS's own advisories, `https://cdn.sheetjs.com/advisories/CVE-2023-30533` and `https://cdn.sheetjs.com/advisories/CVE-2024-22363`.
|
|
18
|
+
|
|
19
|
+
### Sources
|
|
20
|
+
|
|
21
|
+
| Source | Version | What it gives |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| https://registry.npmjs.org/xlsx | registry document, 2026-11-03 | `dist-tags.latest` `0.18.5`; `time["0.18.5"]` `2022-03-24T14:23:09.623Z` |
|
|
24
|
+
| `POST https://registry.npmjs.org/-/npm/v1/security/advisories/bulk` with `{"xlsx":["0.18.5"]}` | answer of 2026-11-03 | both advisories for 0.18.5: GHSA-4r6h-8v6p-xvw6, `vulnerable_versions` `<0.19.3`, CVSS 7.8; GHSA-5pgg-2g8v-p4x9, `<0.20.2`, CVSS 7.5; severity "high" |
|
|
25
|
+
| GitHub Advisory Database, `advisories/github-reviewed/2023/04/GHSA-4r6h-8v6p-xvw6/GHSA-4r6h-8v6p-xvw6.json` | github/advisory-database commit `887dcb68f13a7d9be8bf3d604c2e32fc3d6960e8` | alias CVE-2023-30533, details, `last_known_affected_version_range` `< 0.19.3`, CWE-1321 |
|
|
26
|
+
| GitHub Advisory Database, `advisories/github-reviewed/2024/04/GHSA-5pgg-2g8v-p4x9/GHSA-5pgg-2g8v-p4x9.json` | same commit | alias CVE-2024-22363, details, `< 0.20.2`, CWE-1333 |
|
|
27
|
+
| CVE records `cves/2023/30xxx/CVE-2023-30533.json` and `cves/2024/22xxx/CVE-2024-22363.json` | CVEProject/cvelistV5 commit `cc01a172ea2819376e943af6fb3d73336eacea6b` | descriptions ("SheetJS Community Edition before 0.19.3 allows Prototype Pollution via a crafted file"; for CVE-2024-22363, SheetJS Community Edition before 0.20.2 and ReDoS), publication dates, references |
|
|
28
|
+
| `README.md` of github.com/SheetJS/sheetjs, branch `github` | commit `3f44ddd99c704d7ca35ea76fef7b8af2d2d435cb` | the source repository moved to https://git.sheetjs.com/sheetjs/sheetjs; "Scripts and NodeJS modules are available at https://cdn.sheetjs.com" |
|
|
29
|
+
|
|
30
|
+
The advisory files and CVE records were read through raw.githubusercontent.com at the commits given. The GitHub advisory web pages, the SheetJS sites (sheetjs.com, docs.sheetjs.com, cdn.sheetjs.com, git.sheetjs.com) and other advisory sites could not be reached from the environment where this page was written, so they are linked but not quoted.
|
|
31
|
+
|
|
32
|
+
## Route 1: the fixed SheetJS Community Edition
|
|
33
|
+
|
|
34
|
+
The fixed versions of the Community Edition (0.19.3 and later) are distributed by SheetJS from its own site, not from npm: the advisories name https://cdn.sheetjs.com/ for both fixes. The SheetJS README points to its documentation at https://docs.sheetjs.com and says "Scripts and NodeJS modules are available at https://cdn.sheetjs.com". Install the fixed version as the SheetJS documentation describes; this page does not copy an install command, because that documentation could not be read when the page was written. This route keeps the SheetJS API; check the SheetJS changelog (https://git.sheetjs.com/sheetjs/sheetjs/src/branch/master/CHANGELOG.md, linked from the CVE-2023-30533 record) for changes between 0.18.5 and the version you install.
|
|
35
|
+
|
|
36
|
+
## Route 2: move to xlvane
|
|
37
|
+
|
|
38
|
+
xlvane is a different library with a different API; it is not a drop-in replacement for `xlsx`. A package with a SheetJS-compatible API, `@xlvane/xlsx-compat`, is planned as a later phase ([ROADMAP.md](https://github.com/DevXord/xlvane/blob/main/ROADMAP.md)); it does not exist yet.
|
|
39
|
+
|
|
40
|
+
Facts about the package (npm registry, 2026-11-03; [docs/facts/comparison.md](https://github.com/DevXord/xlvane/blob/main/docs/facts/comparison.md)):
|
|
41
|
+
|
|
42
|
+
- `xlvane` is installed from npm (`npm install xlvane`), under the MIT license, with one runtime dependency, `fflate`.
|
|
43
|
+
- Versions from 1.0.1 are published from GitHub Actions with npm provenance ([SECURITY.md](https://github.com/DevXord/xlvane/blob/main/SECURITY.md#supported-versions)).
|
|
44
|
+
- It reads XLSX, XLSM, XLTX and XLTM, writes XLSX, and converts to and from CSV and JSON. It does not read legacy `.xls`, XLSB, ODS, Numbers or the other formats SheetJS supports, does not open encrypted workbooks, and does not calculate formulas.
|
|
45
|
+
- How it treats input files from untrusted sources (ZIP and XML limits, prototype pollution, amplification by small files, CSV formula injection) is described in [SECURITY.md](https://github.com/DevXord/xlvane/blob/main/SECURITY.md#what-the-library-defends-against).
|
|
46
|
+
|
|
47
|
+
### Equivalent calls
|
|
48
|
+
|
|
49
|
+
The SheetJS names are those of the `xlsx` 0.18.5 README ("Interface"). xlvane's functions take the file's bytes (`Uint8Array` or `ArrayBuffer`) or a workbook already read; `xlvane/node` adds file helpers for Node.js.
|
|
50
|
+
|
|
51
|
+
| SheetJS (`xlsx` 0.18.5) | xlvane |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `XLSX.read(data)` | `readWorkbook(bytes)` |
|
|
54
|
+
| `XLSX.readFile(path)` | `await readWorkbookFile(path)` from `xlvane/node` |
|
|
55
|
+
| `workbook.SheetNames` | `workbook.sheets.map((sheet) => sheet.name)` |
|
|
56
|
+
| `XLSX.utils.sheet_to_json(worksheet)` | `readTable(bytes, { sheet }).rows`, or `toJSON(bytes, { sheet }).rows` for JSON-ready values |
|
|
57
|
+
| `XLSX.utils.sheet_to_csv(worksheet)` | `toCSV(bytes, { sheet })` |
|
|
58
|
+
| `XLSX.utils.json_to_sheet(rows)`, `book_new`, `book_append_sheet`, `XLSX.write(...)` | `writeTable(rows, { sheet })` or `fromJSON(rows)`, which return the `.xlsx` file as a `Uint8Array` |
|
|
59
|
+
| `XLSX.writeFile(workbook, path)` | `writeFile(path, writeTable(rows))` with `node:fs/promises`, or `writeWorkbookFile(workbook, path)` from `xlvane/node` for a workbook built with `createWorkbook` |
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { readTable, toCSV, toJSON, writeTable } from 'xlvane';
|
|
63
|
+
import { readWorkbookFile } from 'xlvane/node';
|
|
64
|
+
import { writeFile } from 'node:fs/promises';
|
|
65
|
+
|
|
66
|
+
const workbook = await readWorkbookFile('orders.xlsx');
|
|
67
|
+
console.log(workbook.sheets.map((sheet) => sheet.name)); // like workbook.SheetNames
|
|
68
|
+
|
|
69
|
+
// Rows as objects keyed by the header row (detected like inspect(); `header: 1` takes row 1).
|
|
70
|
+
const { rows } = readTable(workbook, { sheet: 'Orders' });
|
|
71
|
+
// The same rows with dates as ISO text, ready for JSON.stringify.
|
|
72
|
+
const json = toJSON(workbook, { sheet: 'Orders' }).rows;
|
|
73
|
+
// CSV; text that starts like a formula gets a leading ' (formulaInjection: 'off' turns this off).
|
|
74
|
+
const csv = toCSV(workbook, { sheet: 'Orders' });
|
|
75
|
+
|
|
76
|
+
// A new .xlsx file from objects: bold header, frozen first row, filter, fitted widths.
|
|
77
|
+
const bytes = writeTable(rows, { sheet: 'Orders' });
|
|
78
|
+
await writeFile('orders-copy.xlsx', bytes);
|
|
79
|
+
console.log(json.length, csv.length);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Differences to expect:
|
|
83
|
+
|
|
84
|
+
- `readTable` finds the header row the way `inspect()` does (`header: 'auto'`), or takes `header: 3` (a 1-based row) or `header: false` (keys are the column letters). It returns `Date` objects for date cells; `toJSON` and `toCSV` give ISO 8601 text.
|
|
85
|
+
- Unknown sheet names and damaged files throw an `XlvError` with a stable `XLV_E_*` code, a location and a hint ([docs/errors.md](https://github.com/DevXord/xlvane/blob/main/docs/errors.md)).
|
|
86
|
+
- Read limits (cells, decompressed bytes, XML size) apply by default and can be raised per call: `readWorkbook(bytes, { limits: { maxCells: 50_000_000 } })`. The defaults are in the [package README](https://github.com/DevXord/xlvane/blob/main/packages/xlvane/README.md#untrusted-input-and-limits).
|
|
87
|
+
|
|
88
|
+
The full API is described in the [package README](https://github.com/DevXord/xlvane/blob/main/packages/xlvane/README.md) (also in `node_modules/xlvane/README.md` after installing).
|