fix(evidence): retain unreadable PE and Darwin process facts

Distinguish absent CLI directories from unreadable directory counts and truncated slots while preserving known PE headers and readable CLI data.

Retain environment-entry coverage in the Darwin parser and classify restricted empty, unavailable and ambiguous environments at the native boundary. Keep cleanup fail-closed; code-signing flags do not establish ownership.

Validation: 116 managed source tests, 13 ownership tests, native Swift parser probe and two live Darwin run-token tests; build, static checks and docs checks pass. Restricted-flag cases use parser fixtures; no real restricted capture is claimed. Related to #2035.
This commit is contained in:
morluto
2026-10-12 11:59:23 +08:00
parent d0249282c6
commit 4a4d36f881
9 changed files with 426 additions and 84 deletions
+7 -6
View File
@@ -138,7 +138,10 @@ describe("opaque process neighbors during cleanup", () => {
expect(signalGroup).not.toHaveBeenCalledWith(900, "SIGKILL");
});
it("fails closed for an unrelated unreadable candidate the OS should expose", async () => {
it.each([
"environment_unavailable",
"restricted_process_environment_withheld",
])("fails closed for an unrelated candidate with %s", async (diagnostic) => {
const processes = [
{ pid: 100, parentPid: 1, processGroupId: 100, command: "capture" },
{
@@ -171,7 +174,7 @@ describe("opaque process neighbors during cleanup", () => {
pid === 900
? {
state: "unavailable" as const,
reason: "environment_unavailable",
reason: diagnostic,
}
: { state: "readable" as const, runId: "run-token" },
]),
@@ -191,13 +194,11 @@ describe("opaque process neighbors during cleanup", () => {
expect(result).toMatchObject({
cleaned: false,
reason: expect.stringContaining("environment_unavailable=1"),
reason: expect.stringContaining(`${diagnostic}=1`),
});
if (result.cleaned)
throw new Error("Expected unknown ownership to fail closed");
expect(result.reason).toContain(
"live candidates 900=environment_unavailable",
);
expect(result.reason).toContain(`live candidates 900=${diagnostic}`);
expect(result.reason).not.toContain("unowned");
expect(result.reason).not.toContain("run-token");
expect(signalGroup.mock.calls).toEqual([[100, "SIGKILL"]]);
+2
View File
@@ -642,6 +642,8 @@ const cleanupValidationFailure = (
const sanitizedTokenReadFailure = (diagnostic: string | undefined): string => {
if (diagnostic === "environment_unavailable") return diagnostic;
if (diagnostic === "platform_binary_environment_withheld") return diagnostic;
if (diagnostic === "restricted_process_environment_withheld")
return diagnostic;
const environmentErrno = /^(EACCES|EPERM|ENOENT|ESRCH):/u.exec(
diagnostic ?? "",
);