11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciif (!common.hasCrypto) { 61cb0ef41Sopenharmony_ci common.skip('missing crypto'); 71cb0ef41Sopenharmony_ci} 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciif (common.isPi) { 101cb0ef41Sopenharmony_ci common.skip('Too slow for Raspberry Pi devices'); 111cb0ef41Sopenharmony_ci} 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cicommon.requireNoPackageJSONAbove(); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst { debuglog } = require('util'); 161cb0ef41Sopenharmony_ciconst debug = debuglog('test'); 171cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 181cb0ef41Sopenharmony_ciconst assert = require('assert'); 191cb0ef41Sopenharmony_ciconst { spawnSync, spawn } = require('child_process'); 201cb0ef41Sopenharmony_ciconst crypto = require('crypto'); 211cb0ef41Sopenharmony_ciconst fs = require('fs'); 221cb0ef41Sopenharmony_ciconst path = require('path'); 231cb0ef41Sopenharmony_ciconst { pathToFileURL } = require('url'); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ciconst cpus = require('os').availableParallelism(); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_cifunction hash(algo, body) { 281cb0ef41Sopenharmony_ci const values = []; 291cb0ef41Sopenharmony_ci { 301cb0ef41Sopenharmony_ci const h = crypto.createHash(algo); 311cb0ef41Sopenharmony_ci h.update(body); 321cb0ef41Sopenharmony_ci values.push(`${algo}-${h.digest('base64')}`); 331cb0ef41Sopenharmony_ci } 341cb0ef41Sopenharmony_ci { 351cb0ef41Sopenharmony_ci const h = crypto.createHash(algo); 361cb0ef41Sopenharmony_ci h.update(body.replace('\n', '\r\n')); 371cb0ef41Sopenharmony_ci values.push(`${algo}-${h.digest('base64')}`); 381cb0ef41Sopenharmony_ci } 391cb0ef41Sopenharmony_ci return values; 401cb0ef41Sopenharmony_ci} 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ciconst policyPath = './policy.json'; 431cb0ef41Sopenharmony_ciconst parentBody = { 441cb0ef41Sopenharmony_ci commonjs: ` 451cb0ef41Sopenharmony_ci if (!process.env.DEP_FILE) { 461cb0ef41Sopenharmony_ci console.error( 471cb0ef41Sopenharmony_ci 'missing required DEP_FILE env to determine dependency' 481cb0ef41Sopenharmony_ci ); 491cb0ef41Sopenharmony_ci process.exit(33); 501cb0ef41Sopenharmony_ci } 511cb0ef41Sopenharmony_ci require(process.env.DEP_FILE) 521cb0ef41Sopenharmony_ci `, 531cb0ef41Sopenharmony_ci module: ` 541cb0ef41Sopenharmony_ci if (!process.env.DEP_FILE) { 551cb0ef41Sopenharmony_ci console.error( 561cb0ef41Sopenharmony_ci 'missing required DEP_FILE env to determine dependency' 571cb0ef41Sopenharmony_ci ); 581cb0ef41Sopenharmony_ci process.exit(33); 591cb0ef41Sopenharmony_ci } 601cb0ef41Sopenharmony_ci import(process.env.DEP_FILE) 611cb0ef41Sopenharmony_ci `, 621cb0ef41Sopenharmony_ci}; 631cb0ef41Sopenharmony_ciconst workerSpawningBody = ` 641cb0ef41Sopenharmony_ci const path = require('path'); 651cb0ef41Sopenharmony_ci const { Worker } = require('worker_threads'); 661cb0ef41Sopenharmony_ci if (!process.env.PARENT_FILE) { 671cb0ef41Sopenharmony_ci console.error( 681cb0ef41Sopenharmony_ci 'missing required PARENT_FILE env to determine worker entry point' 691cb0ef41Sopenharmony_ci ); 701cb0ef41Sopenharmony_ci process.exit(33); 711cb0ef41Sopenharmony_ci } 721cb0ef41Sopenharmony_ci if (!process.env.DELETABLE_POLICY_FILE) { 731cb0ef41Sopenharmony_ci console.error( 741cb0ef41Sopenharmony_ci 'missing required DELETABLE_POLICY_FILE env to check reloading' 751cb0ef41Sopenharmony_ci ); 761cb0ef41Sopenharmony_ci process.exit(33); 771cb0ef41Sopenharmony_ci } 781cb0ef41Sopenharmony_ci const w = new Worker(path.resolve(process.env.PARENT_FILE)); 791cb0ef41Sopenharmony_ci w.on('exit', (status) => process.exit(status === 0 ? 0 : 1)); 801cb0ef41Sopenharmony_ci`; 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_cilet nextTestId = 1; 831cb0ef41Sopenharmony_cifunction newTestId() { 841cb0ef41Sopenharmony_ci return nextTestId++; 851cb0ef41Sopenharmony_ci} 861cb0ef41Sopenharmony_citmpdir.refresh(); 871cb0ef41Sopenharmony_cicommon.requireNoPackageJSONAbove(tmpdir.path); 881cb0ef41Sopenharmony_ci 891cb0ef41Sopenharmony_cilet spawned = 0; 901cb0ef41Sopenharmony_ciconst toSpawn = []; 911cb0ef41Sopenharmony_cifunction queueSpawn(opts) { 921cb0ef41Sopenharmony_ci toSpawn.push(opts); 931cb0ef41Sopenharmony_ci drainQueue(); 941cb0ef41Sopenharmony_ci} 951cb0ef41Sopenharmony_ci 961cb0ef41Sopenharmony_cifunction drainQueue() { 971cb0ef41Sopenharmony_ci if (spawned > cpus) { 981cb0ef41Sopenharmony_ci return; 991cb0ef41Sopenharmony_ci } 1001cb0ef41Sopenharmony_ci if (toSpawn.length) { 1011cb0ef41Sopenharmony_ci const config = toSpawn.shift(); 1021cb0ef41Sopenharmony_ci const { 1031cb0ef41Sopenharmony_ci shouldSucceed, 1041cb0ef41Sopenharmony_ci preloads, 1051cb0ef41Sopenharmony_ci entryPath, 1061cb0ef41Sopenharmony_ci onError, 1071cb0ef41Sopenharmony_ci resources, 1081cb0ef41Sopenharmony_ci parentPath, 1091cb0ef41Sopenharmony_ci depPath, 1101cb0ef41Sopenharmony_ci } = config; 1111cb0ef41Sopenharmony_ci const testId = newTestId(); 1121cb0ef41Sopenharmony_ci const configDirPath = path.join( 1131cb0ef41Sopenharmony_ci tmpdir.path, 1141cb0ef41Sopenharmony_ci `test-policy-integrity-permutation-${testId}`, 1151cb0ef41Sopenharmony_ci ); 1161cb0ef41Sopenharmony_ci const tmpPolicyPath = path.join( 1171cb0ef41Sopenharmony_ci tmpdir.path, 1181cb0ef41Sopenharmony_ci `deletable-policy-${testId}.json`, 1191cb0ef41Sopenharmony_ci ); 1201cb0ef41Sopenharmony_ci 1211cb0ef41Sopenharmony_ci fs.rmSync(configDirPath, { maxRetries: 3, recursive: true, force: true }); 1221cb0ef41Sopenharmony_ci fs.mkdirSync(configDirPath, { recursive: true }); 1231cb0ef41Sopenharmony_ci const manifest = { 1241cb0ef41Sopenharmony_ci onerror: onError, 1251cb0ef41Sopenharmony_ci resources: {}, 1261cb0ef41Sopenharmony_ci }; 1271cb0ef41Sopenharmony_ci const manifestPath = path.join(configDirPath, policyPath); 1281cb0ef41Sopenharmony_ci for (const [resourcePath, { body, integrities }] of Object.entries( 1291cb0ef41Sopenharmony_ci resources, 1301cb0ef41Sopenharmony_ci )) { 1311cb0ef41Sopenharmony_ci const filePath = path.join(configDirPath, resourcePath); 1321cb0ef41Sopenharmony_ci if (integrities !== null) { 1331cb0ef41Sopenharmony_ci manifest.resources[pathToFileURL(filePath).href] = { 1341cb0ef41Sopenharmony_ci integrity: integrities.join(' '), 1351cb0ef41Sopenharmony_ci dependencies: true, 1361cb0ef41Sopenharmony_ci }; 1371cb0ef41Sopenharmony_ci } 1381cb0ef41Sopenharmony_ci fs.writeFileSync(filePath, body, 'utf8'); 1391cb0ef41Sopenharmony_ci } 1401cb0ef41Sopenharmony_ci const manifestBody = JSON.stringify(manifest); 1411cb0ef41Sopenharmony_ci fs.writeFileSync(manifestPath, manifestBody); 1421cb0ef41Sopenharmony_ci 1431cb0ef41Sopenharmony_ci fs.writeFileSync(tmpPolicyPath, manifestBody); 1441cb0ef41Sopenharmony_ci 1451cb0ef41Sopenharmony_ci const spawnArgs = [ 1461cb0ef41Sopenharmony_ci process.execPath, 1471cb0ef41Sopenharmony_ci [ 1481cb0ef41Sopenharmony_ci '--unhandled-rejections=strict', 1491cb0ef41Sopenharmony_ci '--experimental-policy', 1501cb0ef41Sopenharmony_ci tmpPolicyPath, 1511cb0ef41Sopenharmony_ci ...preloads.flatMap((m) => ['-r', m]), 1521cb0ef41Sopenharmony_ci entryPath, 1531cb0ef41Sopenharmony_ci '--', 1541cb0ef41Sopenharmony_ci testId, 1551cb0ef41Sopenharmony_ci configDirPath, 1561cb0ef41Sopenharmony_ci ], 1571cb0ef41Sopenharmony_ci { 1581cb0ef41Sopenharmony_ci env: { 1591cb0ef41Sopenharmony_ci ...process.env, 1601cb0ef41Sopenharmony_ci DELETABLE_POLICY_FILE: tmpPolicyPath, 1611cb0ef41Sopenharmony_ci PARENT_FILE: parentPath, 1621cb0ef41Sopenharmony_ci DEP_FILE: depPath, 1631cb0ef41Sopenharmony_ci }, 1641cb0ef41Sopenharmony_ci cwd: configDirPath, 1651cb0ef41Sopenharmony_ci stdio: 'pipe', 1661cb0ef41Sopenharmony_ci }, 1671cb0ef41Sopenharmony_ci ]; 1681cb0ef41Sopenharmony_ci spawned++; 1691cb0ef41Sopenharmony_ci const stdout = []; 1701cb0ef41Sopenharmony_ci const stderr = []; 1711cb0ef41Sopenharmony_ci const child = spawn(...spawnArgs); 1721cb0ef41Sopenharmony_ci child.stdout.on('data', (d) => stdout.push(d)); 1731cb0ef41Sopenharmony_ci child.stderr.on('data', (d) => stderr.push(d)); 1741cb0ef41Sopenharmony_ci child.on('exit', (status, signal) => { 1751cb0ef41Sopenharmony_ci spawned--; 1761cb0ef41Sopenharmony_ci try { 1771cb0ef41Sopenharmony_ci if (shouldSucceed) { 1781cb0ef41Sopenharmony_ci assert.strictEqual(status, 0); 1791cb0ef41Sopenharmony_ci } else { 1801cb0ef41Sopenharmony_ci assert.notStrictEqual(status, 0); 1811cb0ef41Sopenharmony_ci } 1821cb0ef41Sopenharmony_ci } catch (e) { 1831cb0ef41Sopenharmony_ci console.log( 1841cb0ef41Sopenharmony_ci 'permutation', 1851cb0ef41Sopenharmony_ci testId, 1861cb0ef41Sopenharmony_ci 'failed', 1871cb0ef41Sopenharmony_ci ); 1881cb0ef41Sopenharmony_ci console.dir( 1891cb0ef41Sopenharmony_ci { config, manifest }, 1901cb0ef41Sopenharmony_ci { depth: null }, 1911cb0ef41Sopenharmony_ci ); 1921cb0ef41Sopenharmony_ci console.log('exit code:', status, 'signal:', signal); 1931cb0ef41Sopenharmony_ci console.log(`stdout: ${Buffer.concat(stdout)}`); 1941cb0ef41Sopenharmony_ci console.log(`stderr: ${Buffer.concat(stderr)}`); 1951cb0ef41Sopenharmony_ci throw e; 1961cb0ef41Sopenharmony_ci } 1971cb0ef41Sopenharmony_ci fs.rmSync(configDirPath, { maxRetries: 3, recursive: true, force: true }); 1981cb0ef41Sopenharmony_ci drainQueue(); 1991cb0ef41Sopenharmony_ci }); 2001cb0ef41Sopenharmony_ci } 2011cb0ef41Sopenharmony_ci} 2021cb0ef41Sopenharmony_ci 2031cb0ef41Sopenharmony_ci{ 2041cb0ef41Sopenharmony_ci const { status } = spawnSync( 2051cb0ef41Sopenharmony_ci process.execPath, 2061cb0ef41Sopenharmony_ci ['--experimental-policy', policyPath, '--experimental-policy', policyPath], 2071cb0ef41Sopenharmony_ci { 2081cb0ef41Sopenharmony_ci stdio: 'pipe', 2091cb0ef41Sopenharmony_ci }, 2101cb0ef41Sopenharmony_ci ); 2111cb0ef41Sopenharmony_ci assert.notStrictEqual(status, 0, 'Should not allow multiple policies'); 2121cb0ef41Sopenharmony_ci} 2131cb0ef41Sopenharmony_ci{ 2141cb0ef41Sopenharmony_ci const enoentFilepath = path.join(tmpdir.path, 'enoent'); 2151cb0ef41Sopenharmony_ci try { 2161cb0ef41Sopenharmony_ci fs.unlinkSync(enoentFilepath); 2171cb0ef41Sopenharmony_ci } catch { 2181cb0ef41Sopenharmony_ci // Continue regardless of error. 2191cb0ef41Sopenharmony_ci } 2201cb0ef41Sopenharmony_ci const { status } = spawnSync( 2211cb0ef41Sopenharmony_ci process.execPath, 2221cb0ef41Sopenharmony_ci ['--experimental-policy', enoentFilepath, '-e', ''], 2231cb0ef41Sopenharmony_ci { 2241cb0ef41Sopenharmony_ci stdio: 'pipe', 2251cb0ef41Sopenharmony_ci }, 2261cb0ef41Sopenharmony_ci ); 2271cb0ef41Sopenharmony_ci assert.notStrictEqual(status, 0, 'Should not allow missing policies'); 2281cb0ef41Sopenharmony_ci} 2291cb0ef41Sopenharmony_ci 2301cb0ef41Sopenharmony_ci/** 2311cb0ef41Sopenharmony_ci * @template {Record<string, Array<string | string[] | boolean>>} T 2321cb0ef41Sopenharmony_ci * @param {T} configurations 2331cb0ef41Sopenharmony_ci * @param {object} path 2341cb0ef41Sopenharmony_ci * @returns {Array<{[key: keyof T]: T[keyof configurations]}>} 2351cb0ef41Sopenharmony_ci */ 2361cb0ef41Sopenharmony_cifunction permutations(configurations, path = {}) { 2371cb0ef41Sopenharmony_ci const keys = Object.keys(configurations); 2381cb0ef41Sopenharmony_ci if (keys.length === 0) { 2391cb0ef41Sopenharmony_ci return path; 2401cb0ef41Sopenharmony_ci } 2411cb0ef41Sopenharmony_ci const config = keys[0]; 2421cb0ef41Sopenharmony_ci const { [config]: values, ...otherConfigs } = configurations; 2431cb0ef41Sopenharmony_ci return values.flatMap((value) => { 2441cb0ef41Sopenharmony_ci return permutations(otherConfigs, { ...path, [config]: value }); 2451cb0ef41Sopenharmony_ci }); 2461cb0ef41Sopenharmony_ci} 2471cb0ef41Sopenharmony_ciconst tests = new Set(); 2481cb0ef41Sopenharmony_cifunction fileExtensionFormat(extension) { 2491cb0ef41Sopenharmony_ci if (extension === '.js') { 2501cb0ef41Sopenharmony_ci return 'module'; 2511cb0ef41Sopenharmony_ci } else if (extension === '.mjs') { 2521cb0ef41Sopenharmony_ci return 'module'; 2531cb0ef41Sopenharmony_ci } else if (extension === '.cjs') { 2541cb0ef41Sopenharmony_ci return 'commonjs'; 2551cb0ef41Sopenharmony_ci } 2561cb0ef41Sopenharmony_ci throw new Error('unknown format ' + extension); 2571cb0ef41Sopenharmony_ci} 2581cb0ef41Sopenharmony_cifor (const permutation of permutations({ 2591cb0ef41Sopenharmony_ci preloads: [[], ['parent'], ['dep']], 2601cb0ef41Sopenharmony_ci onError: ['log', 'exit'], 2611cb0ef41Sopenharmony_ci parentExtension: ['.js', '.mjs', '.cjs'], 2621cb0ef41Sopenharmony_ci parentIntegrity: ['match', 'invalid', 'missing'], 2631cb0ef41Sopenharmony_ci depExtension: ['.js', '.mjs', '.cjs'], 2641cb0ef41Sopenharmony_ci depIntegrity: ['match', 'invalid', 'missing'], 2651cb0ef41Sopenharmony_ci packageIntegrity: ['match', 'invalid', 'missing'], 2661cb0ef41Sopenharmony_ci})) { 2671cb0ef41Sopenharmony_ci let shouldSucceed = true; 2681cb0ef41Sopenharmony_ci const parentPath = `./parent${permutation.parentExtension}`; 2691cb0ef41Sopenharmony_ci const parentFormat = fileExtensionFormat(permutation.parentExtension); 2701cb0ef41Sopenharmony_ci const depFormat = fileExtensionFormat(permutation.depExtension); 2711cb0ef41Sopenharmony_ci 2721cb0ef41Sopenharmony_ci // non-sensical attempt to require ESM 2731cb0ef41Sopenharmony_ci if (depFormat === 'module' && parentFormat === 'commonjs') { 2741cb0ef41Sopenharmony_ci continue; 2751cb0ef41Sopenharmony_ci } 2761cb0ef41Sopenharmony_ci const depPath = `./dep${permutation.depExtension}`; 2771cb0ef41Sopenharmony_ci const workerSpawnerPath = './worker-spawner.cjs'; 2781cb0ef41Sopenharmony_ci const packageJSON = { 2791cb0ef41Sopenharmony_ci main: workerSpawnerPath, 2801cb0ef41Sopenharmony_ci type: 'module', 2811cb0ef41Sopenharmony_ci }; 2821cb0ef41Sopenharmony_ci 2831cb0ef41Sopenharmony_ci const resources = { 2841cb0ef41Sopenharmony_ci [depPath]: { 2851cb0ef41Sopenharmony_ci body: '', 2861cb0ef41Sopenharmony_ci integrities: hash('sha256', ''), 2871cb0ef41Sopenharmony_ci }, 2881cb0ef41Sopenharmony_ci }; 2891cb0ef41Sopenharmony_ci if (permutation.depIntegrity === 'invalid') { 2901cb0ef41Sopenharmony_ci resources[depPath].body += '\n// INVALID INTEGRITY'; 2911cb0ef41Sopenharmony_ci shouldSucceed = false; 2921cb0ef41Sopenharmony_ci } else if (permutation.depIntegrity === 'missing') { 2931cb0ef41Sopenharmony_ci resources[depPath].integrities = null; 2941cb0ef41Sopenharmony_ci shouldSucceed = false; 2951cb0ef41Sopenharmony_ci } else if (permutation.depIntegrity !== 'match') { 2961cb0ef41Sopenharmony_ci throw new Error('unreachable'); 2971cb0ef41Sopenharmony_ci } 2981cb0ef41Sopenharmony_ci if (parentFormat !== 'commonjs') { 2991cb0ef41Sopenharmony_ci permutation.preloads = permutation.preloads.filter((_) => _ !== 'parent'); 3001cb0ef41Sopenharmony_ci } 3011cb0ef41Sopenharmony_ci 3021cb0ef41Sopenharmony_ci resources[parentPath] = { 3031cb0ef41Sopenharmony_ci body: parentBody[parentFormat], 3041cb0ef41Sopenharmony_ci integrities: hash('sha256', parentBody[parentFormat]), 3051cb0ef41Sopenharmony_ci }; 3061cb0ef41Sopenharmony_ci if (permutation.parentIntegrity === 'invalid') { 3071cb0ef41Sopenharmony_ci resources[parentPath].body += '\n// INVALID INTEGRITY'; 3081cb0ef41Sopenharmony_ci shouldSucceed = false; 3091cb0ef41Sopenharmony_ci } else if (permutation.parentIntegrity === 'missing') { 3101cb0ef41Sopenharmony_ci resources[parentPath].integrities = null; 3111cb0ef41Sopenharmony_ci shouldSucceed = false; 3121cb0ef41Sopenharmony_ci } else if (permutation.parentIntegrity !== 'match') { 3131cb0ef41Sopenharmony_ci throw new Error('unreachable'); 3141cb0ef41Sopenharmony_ci } 3151cb0ef41Sopenharmony_ci 3161cb0ef41Sopenharmony_ci resources[workerSpawnerPath] = { 3171cb0ef41Sopenharmony_ci body: workerSpawningBody, 3181cb0ef41Sopenharmony_ci integrities: hash('sha256', workerSpawningBody), 3191cb0ef41Sopenharmony_ci }; 3201cb0ef41Sopenharmony_ci 3211cb0ef41Sopenharmony_ci let packageBody = JSON.stringify(packageJSON, null, 2); 3221cb0ef41Sopenharmony_ci let packageIntegrities = hash('sha256', packageBody); 3231cb0ef41Sopenharmony_ci if ( 3241cb0ef41Sopenharmony_ci permutation.parentExtension !== '.js' || 3251cb0ef41Sopenharmony_ci permutation.depExtension !== '.js' 3261cb0ef41Sopenharmony_ci ) { 3271cb0ef41Sopenharmony_ci // NO PACKAGE LOOKUP 3281cb0ef41Sopenharmony_ci continue; 3291cb0ef41Sopenharmony_ci } 3301cb0ef41Sopenharmony_ci if (permutation.packageIntegrity === 'invalid') { 3311cb0ef41Sopenharmony_ci packageJSON['//'] = 'INVALID INTEGRITY'; 3321cb0ef41Sopenharmony_ci packageBody = JSON.stringify(packageJSON, null, 2); 3331cb0ef41Sopenharmony_ci shouldSucceed = false; 3341cb0ef41Sopenharmony_ci } else if (permutation.packageIntegrity === 'missing') { 3351cb0ef41Sopenharmony_ci packageIntegrities = []; 3361cb0ef41Sopenharmony_ci shouldSucceed = false; 3371cb0ef41Sopenharmony_ci } else if (permutation.packageIntegrity !== 'match') { 3381cb0ef41Sopenharmony_ci throw new Error('unreachable'); 3391cb0ef41Sopenharmony_ci } 3401cb0ef41Sopenharmony_ci resources['./package.json'] = { 3411cb0ef41Sopenharmony_ci body: packageBody, 3421cb0ef41Sopenharmony_ci integrities: packageIntegrities, 3431cb0ef41Sopenharmony_ci }; 3441cb0ef41Sopenharmony_ci 3451cb0ef41Sopenharmony_ci if (permutation.onError === 'log') { 3461cb0ef41Sopenharmony_ci shouldSucceed = true; 3471cb0ef41Sopenharmony_ci } 3481cb0ef41Sopenharmony_ci tests.add( 3491cb0ef41Sopenharmony_ci JSON.stringify({ 3501cb0ef41Sopenharmony_ci onError: permutation.onError, 3511cb0ef41Sopenharmony_ci shouldSucceed, 3521cb0ef41Sopenharmony_ci entryPath: workerSpawnerPath, 3531cb0ef41Sopenharmony_ci preloads: permutation.preloads 3541cb0ef41Sopenharmony_ci .map((_) => { 3551cb0ef41Sopenharmony_ci return { 3561cb0ef41Sopenharmony_ci '': '', 3571cb0ef41Sopenharmony_ci 'parent': parentFormat === 'commonjs' ? parentPath : '', 3581cb0ef41Sopenharmony_ci 'dep': depFormat === 'commonjs' ? depPath : '', 3591cb0ef41Sopenharmony_ci }[_]; 3601cb0ef41Sopenharmony_ci }) 3611cb0ef41Sopenharmony_ci .filter(Boolean), 3621cb0ef41Sopenharmony_ci parentPath, 3631cb0ef41Sopenharmony_ci depPath, 3641cb0ef41Sopenharmony_ci resources, 3651cb0ef41Sopenharmony_ci }), 3661cb0ef41Sopenharmony_ci ); 3671cb0ef41Sopenharmony_ci} 3681cb0ef41Sopenharmony_cidebug(`spawning ${tests.size} policy integrity permutations`); 3691cb0ef41Sopenharmony_ci 3701cb0ef41Sopenharmony_cifor (const config of tests) { 3711cb0ef41Sopenharmony_ci const parsed = JSON.parse(config); 3721cb0ef41Sopenharmony_ci queueSpawn(parsed); 3731cb0ef41Sopenharmony_ci} 374