@preventive/deptree 1.5.3 → 1.5.4
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/npm.d.ts +2 -2
- package/package.json +1 -1
- package/src/npm/package.js +7 -2
package/npm.d.ts
CHANGED
|
@@ -252,8 +252,8 @@ export interface NpmLazyTree extends NpmTree {
|
|
|
252
252
|
*
|
|
253
253
|
* And held to what npm's lockfiles and the registry always hold: each tarball gzipped, under one directory,
|
|
254
254
|
* named as tar reads it (no `\`, at most 1024 segments), with nothing in its own node_modules, no setuid,
|
|
255
|
-
* setgid or sticky bit, no link name on a file, no global pax header
|
|
256
|
-
* header, and the lockfile's sha512. On macOS, two names in a directory differing only in case or
|
|
255
|
+
* setgid or sticky bit, no link name on a file, no global pax header but one of a comment alone (as git
|
|
256
|
+
* archive writes its commit), no pax size ahead of another extended header, and the lockfile's sha512. On macOS, two names in a directory differing only in case or
|
|
257
257
|
* normalization are refused. Each package's `resolved` has to be the registry's own tarball URL, a scope's
|
|
258
258
|
* `/` as `%2f` or not, or that on yarn's mirror. Ranges are read with the semver of the npm beside node.
|
|
259
259
|
*
|
package/package.json
CHANGED
package/src/npm/package.js
CHANGED
|
@@ -19,6 +19,11 @@ export function registryTarball({ name, version, resolution }, where) {
|
|
|
19
19
|
|
|
20
20
|
const FILES = new Set(['file', 'contiguous-file'])
|
|
21
21
|
|
|
22
|
+
// One global header of a `comment` alone, as git archive writes its commit: tar's releases keep it on each entry
|
|
23
|
+
// and extract by nothing of it. They split a value at a newline into records, and merge a global header into the
|
|
24
|
+
// one before, which the archive reader replaces, so a second ahead of one entry would hide what the first sets.
|
|
25
|
+
const isCommentOnly = (globalPax, extended) => extended.filter(({ kind }) => kind === 'global').length <= 1 && globalPax.entries().every(([key, value]) => key === 'comment' && !value.includes('\n'))
|
|
26
|
+
|
|
22
27
|
// tar up to 7.5.15 (npm 10.9.8, 11.16 and before) reads a pax size into each header after the pax one up
|
|
23
28
|
// to its entry, so a long name, long link or global header between them, and all after, reads otherwise
|
|
24
29
|
function checkPaxSizes(entries, where) {
|
|
@@ -33,12 +38,12 @@ function unpack(entries, where) {
|
|
|
33
38
|
const files = new Map()
|
|
34
39
|
const ignores = new Set()
|
|
35
40
|
let top
|
|
36
|
-
for (const { storedName, storedLinkname, type, mode, data, globalPax } of entries) {
|
|
41
|
+
for (const { storedName, storedLinkname, type, mode, data, globalPax, extended } of entries) {
|
|
37
42
|
const segments = storedName.replace(/(?<=.)\/$/u, '').split('/')
|
|
38
43
|
if (segments.length > 1024 || /[\\\0]/u.test(storedName) || segments.some((segment) => segment === '' || segment === '.' || segment === '..')) {
|
|
39
44
|
throw new DeptreeError(`${quote(storedName)} is a name tar reads otherwise`, where)
|
|
40
45
|
}
|
|
41
|
-
if (globalPax
|
|
46
|
+
if (!isCommentOnly(globalPax, extended)) throw new DeptreeError(`${quote(storedName)} has a pax header tar's releases read otherwise`, where)
|
|
42
47
|
if (top !== undefined && segments[0] !== top) throw new DeptreeError('the tarball has entries under more than one directory', where)
|
|
43
48
|
top = segments[0]
|
|
44
49
|
if (!FILES.has(type)) continue
|