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

test: preserve carriage returns in Git-backed fixtures (#2504)

Michael D'Angelobc5fd0abf6ae
diff --git a/sdk/typescript/tests-ts/cli-patch.test.ts b/sdk/typescript/tests-ts/cli-patch.test.ts
index 2f6e0b06c..cf31b03e7 100644
--- a/sdk/typescript/tests-ts/cli-patch.test.ts
+++ b/sdk/typescript/tests-ts/cli-patch.test.ts
@@ -2831,8 +2831,10 @@ describe("scan and patch workflow", () => {
let savedBody = `Synthetic saved report\n\n\t/close\n\n${summary}`;
if (mode === "resume CRLF")
savedBody = savedBody.replaceAll("\n", "\r\n");
- if (mode === "resume embedded CR")
- savedBody = "Synthetic saved report\n\n>\r>>\n/label ~example";
+ if (mode === "resume embedded CR") {
+ // A Markdown heading makes older Git quote the config value and preserve its CR.
+ savedBody = "## Synthetic saved report\n\n>\r>>\n/label ~example";
+ }
if (resumed) {
git("branch", branch);
git(
diff --git a/sdk/typescript/tests-ts/external-findings-local.test.ts b/sdk/typescript/tests-ts/external-findings-local.test.ts
index bc86ff455..f863af24f 100644
--- a/sdk/typescript/tests-ts/external-findings-local.test.ts
+++ b/sdk/typescript/tests-ts/external-findings-local.test.ts
@@ -1619,9 +1619,16 @@ describe("local normalized scanner findings", () => {
"a line break in the primary Git URL cannot establish a repository match: %j",
async (suffix) => {
const url = "https://github.com/example/project";
- const { repository, environment } = await fixture({
- remote: url + suffix,
- });
+ const { repository, environment, git } = await fixture();
+ // A quoted value preserves a trailing carriage return on older Git.
+ const quotedSuffix = suffix.replaceAll("\n", "\\n");
+ await appendFile(
+ join(repository, ".git", "config"),
+ `\n[remote "origin"]\n\turl = "${url}${quotedSuffix}"\n`,
+ );
+ expect(git("config", "--null", "--get", "remote.origin.url")).toBe(
+ `${url}${suffix}\0`,
+ );
await expect(
prepareNormalizedLocalImport(
input(),