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(plugin): preserve Go declarations after raw strings ending in backslashes (#1235)

12e4eff6521926
diff --git a/plugins/codex-security/scripts/rank_preview.py b/plugins/codex-security/scripts/rank_preview.py
index 2988d3125..6b87179fd 100644
--- a/plugins/codex-security/scripts/rank_preview.py
+++ b/plugins/codex-security/scripts/rank_preview.py
@@ -379,6 +379,11 @@ def mask_c_style_source(text: str, suffix: str) -> str:
quote = '@"'
index += 2
continue
+ if suffix == ".go" and char == "`":
+ masked.append(" ")
+ raw_terminator = "`"
+ index += 1
+ continue
triple_quote = text[index : index + 3]
if triple_quote in {'"""', "'''"}:
masked.extend((" ", " ", " "))
diff --git a/plugins/codex-security/tests/test_rank_preview.py b/plugins/codex-security/tests/test_rank_preview.py
index 70557f4f4..b1856c495 100644
--- a/plugins/codex-security/tests/test_rank_preview.py
+++ b/plugins/codex-security/tests/test_rank_preview.py
@@ -626,6 +626,22 @@ TXT;
assert "method Service.visible" in preview
+def test_go_raw_string_backslash_does_not_hide_following_function(tmp_path: Path) -> None:
+ source = r"""package sample
+
+func Before() {}
+
+const Root = `C:\`
+
+func After() {}
+"""
+
+ preview = generate_preview(tmp_path, "sample.go", source)
+
+ assert "function Before" in preview
+ assert "function After" in preview
+
+
def test_malformed_python_uses_sampled_source_fallback(tmp_path: Path) -> None:
source = """import package
broken = (