fix: parse qa parent pid strictly

This commit is contained in:
Peter Steinberger
2026-05-28 14:40:58 -04:00
parent 528371e7a4
commit b2fdbc53e8
2 changed files with 5 additions and 1 deletions

View File

@@ -13,6 +13,10 @@ describe("installQaParentWatchdog", () => {
expect(
installQaParentWatchdog({ env: { [QA_PARENT_PID_ENV]: "not-a-pid" }, ownPid: 10 }),
).toBeNull();
expect(
installQaParentWatchdog({ env: { [QA_PARENT_PID_ENV]: "0x10" }, ownPid: 10 }),
).toBeNull();
expect(installQaParentWatchdog({ env: { [QA_PARENT_PID_ENV]: "1e3" }, ownPid: 10 })).toBeNull();
});
it("exits when the QA parent process disappears", async () => {

View File

@@ -40,7 +40,7 @@ function resolveQaParentPid(env: NodeJS.ProcessEnv, ownPid: number): number | nu
if (!raw) {
return null;
}
const parentPid = Number(raw);
const parentPid = /^\d+$/.test(raw) ? Number(raw) : Number.NaN;
if (!Number.isSafeInteger(parentPid) || parentPid <= 0 || parentPid === ownPid) {
return null;
}