An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Pin and verify musl compiler downloads
Daniela21e661405b8
diff --git a/.github/workflows/desktop-build.yml b/.github/workflows/desktop-build.ymlindex de311d5026..f5ac48a421 100644--- a/.github/workflows/desktop-build.yml+++ b/.github/workflows/desktop-build.yml@@ -49,11 +49,18 @@ jobs:GOARCH: ${{ fromJSON(inputs.config).goarch }}run: |case "$GOARCH" in- amd64) target_prefix=x86_64-linux-musl ;;- arm64) target_prefix=aarch64-linux-musl ;;+ amd64)+ target_prefix=x86_64-linux-musl+ sha256=c5d410d9f82a4f24c549fe5d24f988f85b2679b452413a9f7e5f7b956f2fe7ea+ ;;+ arm64)+ target_prefix=aarch64-linux-musl+ sha256=c909817856d6ceda86aa510894fa3527eac7989f0ef6e87b5721c58737a06c38+ ;;*) echo "Unsupported Linux architecture: $GOARCH"; exit 1 ;;esac- curl --fail --location --retry 3 "https://musl.cc/${target_prefix}-cross.tgz" -o "$RUNNER_TEMP/musl-cross.tgz"+ curl --fail --location --retry 3 "https://github.com/musl-cc/musl.cc/releases/download/v0.0.1/${target_prefix}-cross.tgz" -o "$RUNNER_TEMP/musl-cross.tgz"+ printf '%s %s\n' "$sha256" "$RUNNER_TEMP/musl-cross.tgz" | sha256sum --check --stricttar -xzf "$RUNNER_TEMP/musl-cross.tgz" -C "$RUNNER_TEMP"echo "cc=$RUNNER_TEMP/${target_prefix}-cross/bin/${target_prefix}-gcc" >> "$GITHUB_OUTPUT"diff --git a/scripts/test_editor_e2e_workflow.py b/scripts/test_editor_e2e_workflow.pyindex ea8d693615..a20f6ac1d7 100644--- a/scripts/test_editor_e2e_workflow.py+++ b/scripts/test_editor_e2e_workflow.py@@ -1,5 +1,6 @@"""编辑器分组工作流的发布门禁和运行时快照回归测试。"""+import hashlibimport itertoolsimport osfrom pathlib import Path@@ -28,6 +29,70 @@ def snapshot_command():class EditorWorkflowTests(unittest.TestCase):+ @unittest.skipUnless(os.name == "posix" and all(shutil.which(tool) for tool in ["bash", "tar", "sha256sum"]),+ "musl download verification requires Bash, tar and sha256sum")+ def test_musl_download_is_pinned_and_verified_before_extraction(self):+ step = DESKTOP.split(" - name: Set up Linux musl compiler\n", 1)[1].split(" - ", 1)[0]+ self.assertIn("shell: bash", step)+ self.assertNotIn("continue-on-error", step)+ command = step.split(" run: |\n", 1)[1]+ command = "\n".join(line[10:] for line in command.splitlines())+ hashes = {+ "amd64": ("x86_64-linux-musl", "c5d410d9f82a4f24c549fe5d24f988f85b2679b452413a9f7e5f7b956f2fe7ea"),+ "arm64": ("aarch64-linux-musl", "c909817856d6ceda86aa510894fa3527eac7989f0ef6e87b5721c58737a06c38"),+ }+ for arch, (prefix, digest) in hashes.items():+ with self.subTest(arch=arch), tempfile.TemporaryDirectory(prefix="musl test ") as temporary:+ root = Path(temporary)+ tools = root / "bin"+ tools.mkdir()+ curl = tools / "curl"+ curl.write_text(+ '#!/bin/bash\nset -eu\nprintf "%s\\n" "$@" > "$CURL_LOG"\n'+ 'if [[ "$DOWNLOAD_FAIL" == 1 ]]; then exit 22; fi\n'+ 'cp "$FIXTURE" "${@: -1}"\n', encoding="utf-8")+ curl.chmod(0o755)+ marker = root / "marker"+ marker.write_text("synthetic toolchain archive", encoding="utf-8")+ fixture = root / "fixture.tgz"+ with tarfile.open(fixture, "w:gz") as archive:+ archive.add(marker, arcname=f"{prefix}-cross/marker")+ fixture_hash = hashlib.sha256(fixture.read_bytes()).hexdigest()+ self.assertIn(digest, command)+ for scenario in ["success", "checksum-mismatch", "download-failure", "unknown-arch"]:+ with self.subTest(scenario=scenario):+ runner = root / scenario+ runner.mkdir()+ output = runner / "output"+ curl_log = runner / "curl.log"+ # 只替换当前架构的已核验哈希,使用合成包验证流程,不执行工具链。+ script = command if scenario == "checksum-mismatch" else command.replace(digest, fixture_hash)+ result = subprocess.run(+ ["bash", "--noprofile", "--norc", "-eo", "pipefail", "-c", script],+ env={**os.environ, "PATH": f"{tools}{os.pathsep}{os.environ['PATH']}",+ "GOARCH": "unsupported" if scenario == "unknown-arch" else arch,+ "RUNNER_TEMP": str(runner), "GITHUB_OUTPUT": str(output),+ "FIXTURE": str(fixture), "CURL_LOG": str(curl_log),+ "DOWNLOAD_FAIL": "1" if scenario == "download-failure" else "0"},+ capture_output=True, text=True)+ if scenario == "success":+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)+ self.assertEqual((runner / f"{prefix}-cross/marker").read_text(), marker.read_text())+ self.assertEqual(output.read_text(), f"cc={runner}/{prefix}-cross/bin/{prefix}-gcc\n")+ else:+ self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr)+ self.assertFalse((runner / f"{prefix}-cross").exists())+ self.assertFalse(output.exists())+ if scenario == "unknown-arch":+ self.assertFalse(curl_log.exists())+ self.assertIn("Unsupported Linux architecture", result.stdout)+ else:+ self.assertEqual(curl_log.read_text().splitlines(), [+ "--fail", "--location", "--retry", "3",+ f"https://github.com/musl-cc/musl.cc/releases/download/v0.0.1/{prefix}-cross.tgz",+ "-o", str(runner / "musl-cross.tgz"),+ ])+@unittest.skipUnless(sys.platform == "linux" and all(shutil.which(tool) for tool in ["bash", "gcc", "readelf"]),"Linux ELF verification requires native compiler and binutils")def test_linux_kernel_verification_rejects_dynamic_and_unusable_binaries(self):