From 0ba3b6049d1e8687a470bd547e29c14ea97d843d Mon Sep 17 00:00:00 2001 From: ShuaixinHuang <1836656514@qq.com> Date: Wed, 18 Nov 2026 22:42:13 +0800 Subject: [PATCH] fix(audit): split ELF linker search lists at every colon (#12035) Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com> --- .../releaseExposure/ReleaseExposureService.test.ts | 3 +++ src/domain/releaseExposureGoPaths.ts | 11 +++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/application/releaseExposure/ReleaseExposureService.test.ts b/src/application/releaseExposure/ReleaseExposureService.test.ts index 818979164f..764c5b22f2 100644 --- a/src/application/releaseExposure/ReleaseExposureService.test.ts +++ b/src/application/releaseExposure/ReleaseExposureService.test.ts @@ -2252,6 +2252,7 @@ describe("ReleaseExposureService Go linker -r search list", () => { it.each([ ["-r=$ORIGIN/../lib:/opt/private-runtime", ["/opt/private-runtime"]], ["-r /opt/a:$ORIGIN/lib:vendor/lib", ["/opt/a", "vendor/lib"]], + ["-r a:$ORIGIN:/opt/private-runtime", ["a", "/opt/private-runtime"]], ])("reads each ELF entry of the search list in %s", async (value, paths) => { const report = await goReport(goModule([{ key: "-ldflags", value }])); const check = report.checks.find((item) => item.id === "go.build_paths"); @@ -2332,6 +2333,8 @@ describe("ReleaseExposureService Go forwarded linker search paths", () => { ["/opt/a", "/opt/b"], ], ["-Wl,-rpath-link,/opt/a:vendor/lib", ["/opt/a", "vendor/lib"]], + ["-Wl,-rpath,a:/opt/private-runtime", ["a", "/opt/private-runtime"]], + ["-Wl,-rpath-link,a:vendor/lib", ["a", "vendor/lib"]], ])("reads each entry of the search list in %s", async (value, paths) => { const report = await goReport(goModule([{ key: "CGO_LDFLAGS", value }])); const check = report.checks.find((item) => item.id === "go.build_paths"); diff --git a/src/domain/releaseExposureGoPaths.ts b/src/domain/releaseExposureGoPaths.ts index 43ebd5a218..2fafe6645d 100644 --- a/src/domain/releaseExposureGoPaths.ts +++ b/src/domain/releaseExposureGoPaths.ts @@ -73,11 +73,6 @@ const LINKER_RUNTIME_TOKENS: Record = { }; /** `-rpath` and `-rpath-link` take a search list, not one directory. */ const LINKER_SEARCH_LIST_FLAG = /^-{1,2}(?:rpath|rpath-link)(?==|$)/u; -/** - * The `:` between search list entries. A `:` after a lone drive letter, as in - * `C:\lib`, is part of the entry. - */ -const LINKER_SEARCH_LIST_SEPARATOR = /(? { const token = LINKER_RUNTIME_TOKENS[format]; - return ( - format === "elf" ? list.split(LINKER_SEARCH_LIST_SEPARATOR) : [list] - ).filter((entry) => entry.length > 0 && token?.test(entry) !== true); + return (format === "elf" ? list.split(":") : [list]).filter( + (entry) => entry.length > 0 && token?.test(entry) !== true, + ); }; /** Consume compiler operands before interpreting any remaining forwarding syntax. */