privacy-scan: a partial upstream path in a container's compressed bytes is left to the full check of the unpacked file
This commit is contained in:
parent
576e8a8f46
commit
6c91aad0e1
1 changed files with 20 additions and 11 deletions
|
|
@ -222,18 +222,27 @@ export function scanPath(path: string, terms: Term[], shown = basename(path), re
|
||||||
report.files++;
|
report.files++;
|
||||||
report.bytes += data.length;
|
report.bytes += data.length;
|
||||||
// the file's own bytes (names, uncompressed parts), then what is inside a container
|
// the file's own bytes (names, uncompressed parts), then what is inside a container
|
||||||
report.hits.push(...scanBuffer(shown, data, terms));
|
const own = scanBuffer(shown, data, terms);
|
||||||
const kind = kindOf(path, data.subarray(0, 1 << 20));
|
const kind = kindOf(path, data.subarray(0, 1 << 20));
|
||||||
if (kind !== 'file' && kind !== 'dir') {
|
if (kind === 'file' || kind === 'dir') { report.hits.push(...own); return report; }
|
||||||
let u: { dir: string; cleanup: () => void } | null = null;
|
let u: { dir: string; cleanup: () => void };
|
||||||
try {
|
try {
|
||||||
u = unpack(path, kind);
|
u = unpack(path, kind);
|
||||||
scanPath(u.dir, terms, `${shown}!`, report);
|
} catch (e) {
|
||||||
} catch (e) {
|
report.hits.push(...own);
|
||||||
report.errors.push((e as Error).message);
|
report.errors.push((e as Error).message);
|
||||||
} finally {
|
return report;
|
||||||
u?.cleanup();
|
}
|
||||||
}
|
try {
|
||||||
|
// An upstream path seen only in part in the compressed bytes (the rest is a back-reference) is checked in full
|
||||||
|
// in the unpacked file, so the partial match in the container's own bytes is left to that check.
|
||||||
|
report.hits.push(...own.filter(h => !(h.encoding === 'utf8' && h.what.startsWith('home folder')
|
||||||
|
&& UPSTREAM_PATHS.some(p => data.toString('latin1', h.offset, h.offset + 64).startsWith(p.split('/').slice(0, 3).join('/') + '/')))));
|
||||||
|
scanPath(u.dir, terms, `${shown}!`, report);
|
||||||
|
} catch (e) {
|
||||||
|
report.errors.push((e as Error).message);
|
||||||
|
} finally {
|
||||||
|
u.cleanup();
|
||||||
}
|
}
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue