mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
fix(audit): split ELF linker search lists at every colon (#12035)
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
This commit is contained in:
1 parent
32b2020571
commit
0ba3b6049d
2 files changed
+6
-8
No files matched your search
@@ -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");
|
||||
|
||||
@@ -73,11 +73,6 @@ const LINKER_RUNTIME_TOKENS: Record<NativeImageFormat, RegExp | null> = {
|
||||
};
|
||||
/** `-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 = /(?<!(?:^|:)[A-Za-z]):/u;
|
||||
/**
|
||||
* The options `go tool link -h` documents as taking a directory, path or file,
|
||||
* as `-L dir` or `-L=dir`, never attached. `-extld` and `-extar` name
|
||||
@@ -180,9 +175,9 @@ const searchListEntries = (
|
||||
format: NativeImageFormat,
|
||||
): string[] => {
|
||||
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. */
|
||||
|
||||
Reference in new issue
Block a user