Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

security: use crypto.randomUUID for temp file suffix (SonarCloud S2245)

Dylan M. Taylor887fe3a3a85e
diff --git a/apps/effectcraft-web/js/host.js b/apps/effectcraft-web/js/host.js
index 5c438550e..658a5199d 100644
--- a/apps/effectcraft-web/js/host.js
+++ b/apps/effectcraft-web/js/host.js
@@ -495,7 +495,7 @@ export async function cacheRead(name) {
export async function cacheWrite(fullName, bytes) {
const [dir, name] = await entryDir(fullName);
const canMove = typeof FileSystemHandle !== "undefined" && "move" in FileSystemHandle.prototype;
- const tmp = canMove ? `${name}.tmp.${Math.random().toString(36).slice(2)}` : name;
+ const tmp = canMove ? `${name}.tmp.${crypto.randomUUID()}` : name;
const fh = await dir.getFileHandle(tmp, { create: true });
if (fh.createSyncAccessHandle) {
const h = await fh.createSyncAccessHandle();