@patrickdk77/archive-defuse 0.2.0 → 0.2.1
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/dist/tar.js +4 -4
- package/package.json +1 -1
package/dist/tar.js
CHANGED
|
@@ -133,7 +133,7 @@ class TarArchive {
|
|
|
133
133
|
const reader = new io_1.Reader(source, size);
|
|
134
134
|
const notes = [];
|
|
135
135
|
const entries = [];
|
|
136
|
-
let
|
|
136
|
+
let globalRecords = [];
|
|
137
137
|
let pending = { pax: [] };
|
|
138
138
|
let pos = 0;
|
|
139
139
|
let total = 0;
|
|
@@ -203,7 +203,7 @@ class TarArchive {
|
|
|
203
203
|
if (typeflag === 'g') {
|
|
204
204
|
// Later global records replace earlier ones of the same key.
|
|
205
205
|
const keys = new Set(parsed.records.map(r => r.key));
|
|
206
|
-
|
|
206
|
+
globalRecords = [...globalRecords.filter(r => !keys.has(r.key)), ...parsed.records];
|
|
207
207
|
const c = parsed.records.find(r => r.key === 'comment');
|
|
208
208
|
if (c)
|
|
209
209
|
comment = c.value.toString('utf8');
|
|
@@ -230,7 +230,7 @@ class TarArchive {
|
|
|
230
230
|
continue;
|
|
231
231
|
}
|
|
232
232
|
// The records that apply: global ones, then this entry's own, the later winning.
|
|
233
|
-
const records = [...
|
|
233
|
+
const records = [...globalRecords.filter(g => !pending.pax.some(r => r.key === g.key)), ...pending.pax];
|
|
234
234
|
const last = (key) => {
|
|
235
235
|
let found;
|
|
236
236
|
for (const r of records)
|
|
@@ -315,7 +315,7 @@ class TarArchive {
|
|
|
315
315
|
devmajor: posix || ustar === 'ustar ' ? num(329, 8, 'devmajor') : 0,
|
|
316
316
|
devminor: posix || ustar === 'ustar ' ? num(337, 8, 'devminor') : 0,
|
|
317
317
|
// Global records apply to every entry after them, so each entry keeps its own copy. A global comment is the archive's.
|
|
318
|
-
pax: records.filter(r => !isStructural(r.key) && !(r.key === 'comment' &&
|
|
318
|
+
pax: records.filter(r => !isStructural(r.key) && !(r.key === 'comment' && globalRecords.includes(r))),
|
|
319
319
|
};
|
|
320
320
|
if (kind === 'symlink' || kind === 'hardlink')
|
|
321
321
|
e.linkTarget = linkTarget;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patrickdk77/archive-defuse",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Sanitize zip, tar, gzip, bzip2, zstd, Brotli, cab, 7z, xz and lzma archives. Detects path traversal, links out of the tree, device files, duplicate names, overlapping entries, hidden and prepended data, encrypted entries and compression bombs, hands every entry to file plugins, scores the risk, and writes a defused archive in the same format with no runtime dependencies.",
|
|
5
5
|
"license": "MIT AND Apache-2.0",
|
|
6
6
|
"author": "patrickdk77",
|