INNER CODE UNIT · JavaScript
materializeScope
JoasASantos/NeuroSploit · web/server.js:201
async function materializeScope(body, jobId) {
const scope = body.scope;
if (!scope) return undefined;
const hard = (Array.isArray(scope.hard) ? scope.hard : String(scope.hard || '').split(/[\n,;]+/)).map((x) => String(x).trim()).filter(Boolean);
if (!hard.length) return undefined; // no boundary set — nothing to enforce beyond flags
const dir = path.join(os.tmpdir(), 'neurosploit-web');
await fsp.mkdir(dir, { recursive: true });
const file = path.join(dir, `${jobId}.scope.yaml`);
await fsp.writeFile(file, buildScopeYaml(scope));
return file;
}
async function materializeCreds(body, jobId) {
if (body.creds) return body.creds; // explicit file path on disk wins
if (!body.auth && !(body.roles || []).length) return undefined;
const dir = path.join(os.tmpdir(), 'neurosploit-web');
await fsp.mkdir(dir, { recursive: true });
const file = path.join(dir, `${jobId}.creds.yaml`);