Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

refactor(runtime): simplify Windows credential permission parsing (#1392)

mldangelo-oai7c84dc887c8f
diff --git a/sdk/typescript/src/runtime.ts b/sdk/typescript/src/runtime.ts
index 873cc8837..7f25e4660 100644
--- a/sdk/typescript/src/runtime.ts
+++ b/sdk/typescript/src/runtime.ts
@@ -684,14 +684,10 @@ function windowsAceAllowsAncestorReplacement(
if (/^0x[\da-f]+$/iu.test(rights)) {
return (BigInt(rights) & 0x100d0040n) !== 0n;
}
- for (let index = 0; index < rights.length; index += 2) {
- if (
- ["FA", "GA", "FW", "GW", "SD", "WD", "WO", "DC", "DT"].includes(
- rights.slice(index, index + 2),
- )
- ) {
+ // Rights tokens stay aligned to pairs of UTF-16 code units.
+ for (const [right] of rights.matchAll(/[\s\S]{2}/g)) {
+ if (["FA", "GA", "FW", "GW", "SD", "WD", "WO", "DC", "DT"].includes(right))
return true;
- }
}
return false;
}
diff --git a/sdk/typescript/tests-ts/runtime.test.ts b/sdk/typescript/tests-ts/runtime.test.ts
index ab22e4a5b..a6f68a5b1 100644
--- a/sdk/typescript/tests-ts/runtime.test.ts
+++ b/sdk/typescript/tests-ts/runtime.test.ts
@@ -3526,6 +3526,7 @@ describe("runtime directories and plugin Python boundary", () => {
"GXGW",
"FAGX",
"FWGX",
+ "😀FA",
"SD",
"WD",
"WO",
@@ -3549,6 +3550,7 @@ describe("runtime directories and plugin Python boundary", () => {
["", "FR"],
["", "FRGX"],
["", "GRGX"],
+ ["", "AFAX"],
["", "0x1200a9"],
["IO", "FA"],
] as const) {