feat(windows): define native authority boundary

This commit is contained in:
morluto
2026-07-18 04:50:24 +00:00
parent da1da3bfb8
commit a1a6b4200e
14 changed files with 3938 additions and 48 deletions
+33 -7
View File
@@ -21,6 +21,7 @@ export interface WindowsCapabilityDependencies {
probeSymlinkCreation(): Promise<WindowsCapabilityOutcome>;
probeNoFollowOpen(): WindowsCapabilityOutcome;
probePrivateAcl(): WindowsCapabilityOutcome;
probeNativeAuthority(): WindowsCapabilityOutcome;
probeUnixDomainSocket(): WindowsCapabilityOutcome;
probePty(): Promise<ProcessCaptureCapability>;
}
@@ -33,6 +34,7 @@ export interface WindowsCapabilityReport {
symlink_creation: WindowsCapabilityOutcome;
no_follow_open: WindowsCapabilityOutcome;
private_acl: WindowsCapabilityOutcome;
native_authority: WindowsCapabilityOutcome;
unix_domain_socket: WindowsCapabilityOutcome;
pty: WindowsCapabilityOutcome;
}>;
@@ -53,6 +55,7 @@ export const probeWindowsCapabilities = async (
symlink_creation: symlinkCreation,
no_follow_open: dependencies.probeNoFollowOpen(),
private_acl: dependencies.probePrivateAcl(),
native_authority: dependencies.probeNativeAuthority(),
unix_domain_socket: dependencies.probeUnixDomainSocket(),
pty: {
available: pty.available,
@@ -67,16 +70,16 @@ const systemDependencies = (): WindowsCapabilityDependencies => ({
architecture: process.arch,
probeSymlinkCreation,
probeNoFollowOpen: () =>
typeof constants.O_NOFOLLOW === "number"
? { available: true, reason: null }
: {
available: false,
reason: "O_NOFOLLOW is unavailable in this Node runtime",
},
systemNoFollowOpenCapability(process.platform, constants.O_NOFOLLOW),
probePrivateAcl: () => ({
available: false,
reason: "Windows ACL enforcement is not implemented by this REA build",
}),
probeNativeAuthority: () => ({
available: false,
reason:
"Windows native authority package is not implemented by this REA build",
}),
probeUnixDomainSocket: () =>
process.platform === "win32"
? {
@@ -87,6 +90,24 @@ const systemDependencies = (): WindowsCapabilityDependencies => ({
probePty: probeProcessCaptureCapability,
});
/** Report pathname no-follow support without treating it as Windows authority. */
export const systemNoFollowOpenCapability = (
platform: NodeJS.Platform,
noFollow: number | undefined,
): WindowsCapabilityOutcome => {
if (platform === "win32")
return {
available: false,
reason: "Windows reparse-safe handle admission is not implemented",
};
return typeof noFollow === "number"
? { available: true, reason: null }
: {
available: false,
reason: "O_NOFOLLOW is unavailable in this Node runtime",
};
};
const probeSymlinkCreation = async (): Promise<WindowsCapabilityOutcome> => {
const root = await mkdtemp(join(tmpdir(), "rea-symlink-probe-"));
const target = join(root, "target");
@@ -106,6 +127,11 @@ const probeSymlinkCreation = async (): Promise<WindowsCapabilityOutcome> => {
: "symlink creation failed",
};
} finally {
await rm(root, { recursive: true, force: true });
try {
await rm(root, { recursive: true, force: true });
} catch {
// Cleanup failure must not replace the machine-readable probe outcome.
// The probe root lives beneath the OS temporary directory and is unique.
}
}
};