Files
reverse-engineering-anything/src/process/ProcessOwnershipIdentity.ts
T
morluto 530faf43bd refactor(process): take the host from HOST_PLATFORM and require the platform in process helpers (#11038)
* refactor(process): take the host from HOST_PLATFORM and require the platform in process helpers

* refactor(process): require the settlement platform and pass it in string-embedded ownership checks
2026-11-15 19:35:03 +08:00

36 lines
1.2 KiB
TypeScript

import { matchesOwnedProcessCommand } from "./ProcessCommandIdentity.js";
import { HOST_PLATFORM } from "../platform/HostPlatform.js";
import type {
OwnedProcessGroup,
ProcessTableEntry,
} from "./ProcessOwnership.js";
/** Compare a live launcher against the identity committed at process launch. */
export const launcherIdentityFailure = (
launcher: Pick<ProcessTableEntry, "parentPid" | "processGroupId"> & {
readonly command?: string;
},
ownership: OwnedProcessGroup,
): string | null => {
if (launcher.processGroupId !== ownership.processGroupId)
return "owned launcher process-group identity did not match";
if (
ownership.expectedParentPid !== undefined &&
launcher.parentPid !== ownership.expectedParentPid
)
return "owned launcher parent identity did not match";
if (ownership.expectedCommand !== undefined) {
if (launcher.command === undefined)
return "owned launcher command identity could not be verified";
if (
!matchesOwnedProcessCommand(
launcher.command,
ownership.expectedCommand,
HOST_PLATFORM.platform,
)
)
return `owned launcher command identity did not match (observed=${launcher.command}; expected=${ownership.expectedCommand})`;
}
return null;
};