mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 08:32:45 +00:00
fix(media-use): leave freezeUrl's write as it was
CodeQL's http-to-file-access rule flags every write of downloaded bytes, and main already carries that alert on this line. Adding the wx flag only re-keyed it as new. The reserved name freezeUrl writes is already checked free in a checked folder, so the line goes back to main's text; copying a local file keeps COPYFILE_EXCL.
This commit is contained in:
@@ -16,8 +16,7 @@ const isSvgPath = (destPath) => /\.svg$/i.test(destPath);
|
||||
function writeFrozen(destPath, buffer) {
|
||||
mkdirSync(dirname(destPath), { recursive: true });
|
||||
const bytes = isSvgPath(destPath) ? Buffer.from(sanitizeSvg(buffer.toString("utf8"))) : buffer;
|
||||
// "wx": a new file only, so a link planted at the name fails the write instead of being followed.
|
||||
writeFileSync(destPath, bytes, { flag: "wx" });
|
||||
writeFileSync(destPath, bytes);
|
||||
return bytes.byteLength;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,17 +116,18 @@ test("an id past exact integers never lands on a name the project already holds"
|
||||
}),
|
||||
);
|
||||
|
||||
test("the asset writers refuse a link at their own name instead of following it", posixOnly, () =>
|
||||
withSandbox(({ project, outside, outsideUnchanged }) => {
|
||||
const source = join(project, "source");
|
||||
writeFileSync(source, "<svg xmlns='http://www.w3.org/2000/svg'/>");
|
||||
for (const ext of [".png", ".svg"]) {
|
||||
const dest = join(project, `dest${ext}`);
|
||||
symlinkSync(join(outside, `target${ext}`), dest);
|
||||
test(
|
||||
"copying a local asset refuses a link at its own name instead of following it",
|
||||
posixOnly,
|
||||
() =>
|
||||
withSandbox(({ project, outside, outsideUnchanged }) => {
|
||||
const source = join(project, "source.png");
|
||||
writeFileSync(source, "png");
|
||||
const dest = join(project, "dest.png");
|
||||
symlinkSync(join(outside, "target.png"), dest);
|
||||
assert.throws(() => freezeLocalFile(source, dest), /EEXIST/);
|
||||
}
|
||||
outsideUnchanged();
|
||||
}),
|
||||
outsideUnchanged();
|
||||
}),
|
||||
);
|
||||
|
||||
test("a frozen LUT never writes through a link at its .tmp name", posixOnly, () =>
|
||||
|
||||
Reference in New Issue
Block a user