Files
kevinveenbirkenbachandClaude Opus 5.5 403ba7e9a7 fix(web-app-fusiondirectory): draw the gallery's wrong password from crypto
js/insecure-randomness on PR #625 (test-design.js:46): the login-error view built its wrong password from Math.random; it now uses randomUUID from node:crypto. The new test fails on the old value.

🎯 Fix: 97 %
💥 Break: 2 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: ~100 %
🏆 Score: 95
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 17:10:56 +00:00

31 lines
1.1 KiB
JavaScript

const fs = require("node:fs");
const vm = require("node:vm");
const STUB_MODULE = new Proxy({}, { get: () => () => undefined });
/**
* Loads a CommonJS file into its own context and hands out functions it does not export.
*
* Args:
* file: absolute path of the file.
* names: names of its top-level functions to return.
* modules: module per `require` request; every other request gets a module whose exports are no-op functions.
* globals: the context's global object, e.g. the `document` and `getComputedStyle` its `page.evaluate` callbacks read; later changes to it are seen by those callbacks.
*
* Returns:
* An object holding each named function.
*/
function loadInternals(file, names, modules, globals) {
const module = { exports: {} };
Object.assign(globals, {
exports: module.exports,
module,
process,
require: (request) => (request in modules ? modules[request] : STUB_MODULE),
});
vm.createContext(globals);
return vm.runInContext(`${fs.readFileSync(file, "utf8")}\n;({ ${names.join(", ")} });`, globals, { filename: file });
}
module.exports = { loadInternals };