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

fix(knowledge-base): skip the old position of moved DOCX text (#2256)

Lanre Shittue3615c48e3dd
diff --git a/sdk/typescript/src/knowledge-base.ts b/sdk/typescript/src/knowledge-base.ts
index 3782beba1..5733a676b 100644
--- a/sdk/typescript/src/knowledge-base.ts
+++ b/sdk/typescript/src/knowledge-base.ts
@@ -350,7 +350,8 @@ function extractDocx(path: string, bytes: Uint8Array): string {
if (
localName === "del" ||
localName === "delText" ||
- localName === "delInstrText"
+ localName === "delInstrText" ||
+ localName === "moveFrom"
) {
deletedDepth++;
}
@@ -389,7 +390,8 @@ function extractDocx(path: string, bytes: Uint8Array): string {
if (
localName === "del" ||
localName === "delText" ||
- localName === "delInstrText"
+ localName === "delInstrText" ||
+ localName === "moveFrom"
) {
deletedDepth--;
}
diff --git a/sdk/typescript/tests-ts/knowledge-base.test.ts b/sdk/typescript/tests-ts/knowledge-base.test.ts
index f1ef8cb3d..0116e743e 100644
--- a/sdk/typescript/tests-ts/knowledge-base.test.ts
+++ b/sdk/typescript/tests-ts/knowledge-base.test.ts
@@ -517,6 +517,14 @@ describe("scan knowledge bases", () => {
"<w:r><w:t>internal only</w:t></w:r></w:p>",
),
);
+ await writeFile(
+ join(root, "tracked-move.docx"),
+ docxBody(
+ '<w:p><w:r><w:t xml:space="preserve">Rotate keys. </w:t></w:r>' +
+ '<w:moveFrom w:id="2" w:author="Example Author"><w:r><w:t>Audit weekly.</w:t></w:r></w:moveFrom></w:p>' +
+ '<w:p><w:moveTo w:id="3" w:author="Example Author"><w:r><w:t>Audit weekly.</w:t></w:r></w:moveTo></w:p>',
+ ),
+ );
await writeFile(
join(root, "field-code.docx"),
docxBody(
@@ -537,6 +545,7 @@ describe("scan knowledge bases", () => {
expect(documents).toContain("Role\tCapability\n");
expect(documents).toContain("User\tPermission\n");
expect(documents).toContain("Admin API is internal only\n");
+ expect(documents).toContain("Rotate keys. \nAudit weekly.\n");
expect(documents).toContain("See the runbook\n");
});