Files
orca/config/scripts/orcad-distribution/server-bundle/orcad-windows-security.mjs
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00

64 lines
2.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { copyFileSync, existsSync } from 'node:fs'
import { createRequire } from 'node:module'
import { join } from 'node:path'
import { runProcessSync } from '@orca/process-host'
import { ORCAD_WINDOWS_SECURITY_FILENAME } from '../../../../src/shared/orcad-artifacts.ts'
import { windowsSecurityAddonOutput } from '../../native-build/windows/build-windows-security-addon.mjs'
const { PE_MACHINE, describePeMachine, readPeMachine } = createRequire(import.meta.url)(
'../../native-build/windows/windows-pe-machine.cjs'
)
// ACL addon is required: missing it makes orcad’s data-root privacy check fail closed before Windows startup.
export function stageOrcadWindowsSecurity(
root,
outputDir,
target,
host = { platform: process.platform },
compile = compileOrcadWindowsSecurity,
options = {}
) {
if (!target.startsWith('win32-')) {
return
}
const arch = target.slice('win32-'.length)
const source = windowsSecurityAddonOutput(root, arch)
if (!existsSync(source)) {
if (host.platform !== 'win32') {
throw new Error(
`Orcad ${target} requires the Windows security addon. On Windows, run: ` +
`node config/scripts/native-build/windows/build-windows-security-addon.mjs --arch=${arch}`
)
}
compile(root, arch, options)
}
const machine = readPeMachine(source)
if (machine !== PE_MACHINE[arch]) {
throw new Error(`Orcad ${target} Windows security addon has ${describePeMachine(machine)}`)
}
copyFileSync(source, join(outputDir, ORCAD_WINDOWS_SECURITY_FILENAME))
}
function compileOrcadWindowsSecurity(
root,
arch,
{ enabled = false, runtimePath, run = runProcessSync } = {}
) {
const result = run({
program: process.execPath,
args: [
join(root, 'config/scripts/native-build/windows/build-windows-security-addon.mjs'),
`--arch=${arch}`,
...(enabled && runtimePath
? ['--reuse-prepared-runtime', `--node-runtime=${runtimePath}`]
: [])
],
cwd: root,
stdio: 'inherit',
timeoutMs: null
})
if (result.code !== 0) {
throw new Error(`Windows security addon build for ${arch} failed with exit ${result.code}`)
}
}