Verify debug info for first-party release binaries
Modular container CI / release-build (push) Successful in 29m50s
Signed modular release / publish (push) Successful in 25m42s

This commit is contained in:
faumaray committed 2026-08-01 21:49:53 +03:00
1 parent ebb1040a71
commit 9e6e6ca97b
3 files changed
+57 -12

No files matched your search

+29 -6
View File
@@ -49,6 +49,10 @@ PLUGIN_RUNPATH = (
"$ORIGIN/../../current/lib:"
"$ORIGIN/lib"
)
FIRST_PARTY_LIBRARY_PATTERN = re.compile(
r"^(?:Echoion\.ts|libechoion-[A-Za-z0-9_.-]+\.so(?:\..*)?|"
r"libVoidTeamspeak\.so(?:\..*)?|libVoid_[A-Za-z0-9_.-]+\.so(?:\..*)?)$"
)
def parse_version(value: str) -> tuple[int, ...]:
@@ -113,6 +117,15 @@ def is_system_dependency(name: str) -> bool:
return any(pattern.fullmatch(name) for pattern in SYSTEM_DEPENDENCIES)
def is_first_party_payload(path: Path, root: Path, plugin_files: set[Path]) -> bool:
if path in plugin_files or path.parent == root / "bin":
return True
return (
path.parent == root / "lib"
and FIRST_PARTY_LIBRARY_PATTERN.fullmatch(path.name) is not None
)
def ensure_inside(path: Path, directory: Path, description: str) -> None:
try:
path.resolve(strict=True).relative_to(directory)
@@ -181,7 +194,7 @@ def validate(
root: Path,
maximum_glibc: tuple[int, ...] | None = None,
forbidden_content_prefixes: tuple[bytes, ...] = (),
require_debug_info: bool = False,
require_first_party_debug_info: bool = False,
) -> list[str]:
executable = root / "bin/echoiond"
updater = root / "bin/echoion-updater"
@@ -226,13 +239,16 @@ def validate(
re.MULTILINE,
):
raise ValueError(f"{relative} is not an x86-64 ELF")
if require_debug_info:
if require_first_party_debug_info and is_first_party_payload(
path, root, plugin_files
):
sections = command_output(["readelf", "-SW", os.fspath(path)])
if re.search(r"\]\s+\.(?:z)?debug_info\s", sections) is None:
raise ValueError(
f"{relative} has no debug information; expected a "
"RelWithDebInfo artifact"
"first-party RelWithDebInfo artifact"
)
report.append(f"DEBUG\t{relative}\tFIRST_PARTY=verified")
dynamic = command_output(["readelf", "-dW", os.fspath(path)])
runpaths = RUNPATH_PATTERN.findall(dynamic)
if path in plugin_files:
@@ -322,9 +338,13 @@ def main() -> int:
parser.add_argument("--report", type=Path)
parser.add_argument("--max-glibc", type=parse_version)
parser.add_argument(
"--require-debug-info",
"--require-first-party-debug-info",
action="store_true",
help="reject ELF payloads without DWARF debug information",
help=(
"reject Echoion, VoidLibrary, VoidTeamspeak, and bundled plugin "
"payloads without DWARF debug information; redistributed system "
"libraries are exempt"
),
)
parser.add_argument(
"--forbid-content-prefix",
@@ -347,12 +367,15 @@ def main() -> int:
root,
arguments.max_glibc,
forbidden_content_prefixes,
arguments.require_debug_info,
arguments.require_first_party_debug_info,
)
except (OSError, ValueError) as error:
parser.error(str(error))
if arguments.report:
write_report(report, arguments.report)
if arguments.require_first_party_debug_info:
verified = sum(line.startswith("DEBUG\t") for line in report)
print(f"verified debug information in {verified} first-party ELF files")
else:
print("\n".join(report))
return 0