Files
reverse-engineering-anything/src/process/LinuxProcessStatus.test.ts
T
morluto 4af71a45f9 fix(process): reconcile native lifetime and selective Linux UID facts
Settle absent and zombie candidates before retaining baseline or token-read failures. Preserve fail-closed behavior for live and unknown generations, and stop retrying exited candidates.

Bind Linux effective UID to stat-bracketed status reads only for unreadable-token candidates, preserving partial identity facts and avoiding full-table UID enrichment.
2026-10-20 00:05:22 +08:00

22 lines
695 B
TypeScript

import { expect, it } from "vitest";
import { parseLinuxProcessEffectiveUid } from "./LinuxProcessStatus.js";
it("parses the effective UID from the single native status Uid row", () => {
expect(
parseLinuxProcessEffectiveUid(
"Name:\tworker\nUid:\t1000\t1001\t1002\t1003\nGid:\t20\t20\t20\t20\n",
),
).toBe(1001);
});
it.each([
"Name:\tworker\n",
"Uid:\t1000\t1001\t1002\n",
"Uid:\t1000\t1001\t1002\t1003\nUid:\t1000\t1001\t1002\t1003\n",
"Uid:\t1000\t-1\t1002\t1003\n",
"Uid:\t1000\t9007199254740992\t1002\t1003\n",
])("does not infer an effective UID from malformed status: %s", (status) => {
expect(parseLinuxProcessEffectiveUid(status)).toBeUndefined();
});