잠금 의존성 라이선스 원문 생성과 패키지 누락 차단을 추가함
- 작성자
- 호시노 히나타
- 작성 시각
- 커밋
5c9b48eff953e9c1d1136b7711e047f853d1d99d- 부모
- 8bfa254
변경된 파일 11개
+407-14| @@ -1,11 +1,6 @@ | ||
| 1 | 삭제: Zipelo 합성 메모리 UI 후보 | |
| 2 | 삭제: 자체 코드: MIT. LICENSE에 원문을 포함함. | |
| 3 | 삭제: 직접 의존성: 고정 PR42의 zipelo-app-core-memory와 선택적 eframe 0.37.0임. | |
| 4 | 삭제: eframe feature: accesskit, clipboard, glow, system_fonts, wayland, x11임. | |
| 5 | 삭제: 기존 PR34 및 PR42 lock에 있는 package/version/checksum만 사용함. | |
| 6 | 삭제: 플랫폼별 선택 feature, SPDX license, 캐시 archive checksum, 라이선스 파일의 상대 경로와 SHA256은 tests/rust-ui-memory-app/dependencies.json에 기록함. | |
| 7 | 삭제: 원문 출처는 해당 checksum의 crates.io crate archive와 그 archive에서 풀린 registry source임. | |
| 8 | 삭제: Linux headless/GUI 빌드만 수행함. Windows GNU/MSVC는 선택 그래프 분석이며 빌드/실행을 뜻하지 않음. | |
| 9 | 삭제: 설치된 Noto CJK 폰트는 런타임 경로에서 읽으며 이 후보에 재배포하지 않음. | |
| 10 | 삭제: 이 기록은 최종 설치기/배포용 전체 고지를 완료했다는 뜻이 아님. | |
| 11 | 삭제: crate에 원문이 없는 GUI package의 고정 upstream 보충 원문은 기존 PR34에서 보존한 tests/rust-ui-memory-app/license-supplement.json을 사용함. 원래 URL과 원문을 그대로 보존하며 새로운 네트워크 조회를 하지 않음. | |
| 1 | 추가: Zipelo 의존성 고지 생성 안내 | |
| 2 | 추가: | |
| 3 | 추가: 최종 배포 고지는 packaging/licenses.py가 빌드할 때 생성하는 THIRD-PARTY-LICENSES.txt임. | |
| 4 | 추가: 앱과 작업자의 Cargo.lock 전체 항목을 오프라인 cargo metadata와 대조함. | |
| 5 | 추가: 로컬 registry의 원문과 잠금 체크섬을 확인하며 누락 시 패키지 생성을 중단함. | |
| 6 | 추가: 이 안내 파일과 과거 시험용 보충 원문은 최종 배포 고지를 대신하지 않음. |
| @@ -0,0 +1,139 @@ | ||
| 1 | 추가: """잠금 의존성의 로컬 원문을 모으고 누락 시 배포를 중단함.""" | |
| 2 | 추가: | |
| 3 | 추가: import argparse | |
| 4 | 추가: import hashlib | |
| 5 | 추가: import json | |
| 6 | 추가: from pathlib import Path | |
| 7 | 추가: import subprocess | |
| 8 | 추가: import tarfile | |
| 9 | 추가: import tomllib | |
| 10 | 추가: | |
| 11 | 추가: ROOT = Path(__file__).resolve().parents[1] | |
| 12 | 추가: | |
| 13 | 추가: | |
| 14 | 추가: def identity(package): | |
| 15 | 추가: return package["name"], package["version"], package.get("source") or "workspace" | |
| 16 | 추가: | |
| 17 | 추가: | |
| 18 | 추가: def metadata(manifest): | |
| 19 | 추가: result = subprocess.run( | |
| 20 | 추가: ["cargo", "+1.99.1", "metadata", "--format-version", "1", "--locked", "--offline", | |
| 21 | 추가: "--all-features", "--manifest-path", str(manifest)], | |
| 22 | 추가: check=True, capture_output=True, text=True, | |
| 23 | 추가: ) | |
| 24 | 추가: return json.loads(result.stdout)["packages"] | |
| 25 | 추가: | |
| 26 | 추가: | |
| 27 | 추가: def is_license(path): | |
| 28 | 추가: path = Path(path) | |
| 29 | 추가: name = path.name.upper() | |
| 30 | 추가: return ( | |
| 31 | 추가: name.startswith(("LICENSE", "LICENCE", "COPYING", "COPYRIGHT", "NOTICE", "UNLICENSE", "OFL")) | |
| 32 | 추가: or any(part.lower() in {"license", "licenses", "licence", "licences"} for part in path.parts[:-1]) | |
| 33 | 추가: ) and path.suffix.lower() not in {".rs", ".c", ".h", ".cpp", ".py", ".json"} | |
| 34 | 추가: | |
| 35 | 추가: | |
| 36 | 추가: def registry_files(package, locked): | |
| 37 | 추가: root = Path(package["manifest_path"]).parent.resolve() | |
| 38 | 추가: archive = root.parents[2] / "cache" / root.parent.name / (root.name + ".crate") | |
| 39 | 추가: if hashlib.sha256(archive.read_bytes()).hexdigest() != locked["checksum"]: | |
| 40 | 추가: raise ValueError(f"crate 체크섬 불일치: {root.name}") | |
| 41 | 추가: explicit = package.get("license_file") | |
| 42 | 추가: if explicit: | |
| 43 | 추가: explicit = Path(explicit) | |
| 44 | 추가: if not explicit.is_absolute(): | |
| 45 | 추가: explicit = root / explicit | |
| 46 | 추가: explicit = explicit.resolve().relative_to(root).as_posix() | |
| 47 | 추가: records = [] | |
| 48 | 추가: with tarfile.open(archive, "r:gz") as source: | |
| 49 | 추가: for member in sorted(source.getmembers(), key=lambda member: member.name): | |
| 50 | 추가: name = Path(member.name) | |
| 51 | 추가: if name.parts[0] != root.name or ".." in name.parts: | |
| 52 | 추가: raise ValueError(f"crate 경로 오류: {root.name}") | |
| 53 | 추가: relative = Path(*name.parts[1:]) | |
| 54 | 추가: if not (is_license(relative) or relative.as_posix() == explicit): | |
| 55 | 추가: continue | |
| 56 | 추가: if not member.isfile(): | |
| 57 | 추가: if member.isdir(): | |
| 58 | 추가: continue | |
| 59 | 추가: raise ValueError(f"라이선스가 일반 파일이 아님: {member.name}") | |
| 60 | 추가: local = root / relative | |
| 61 | 추가: if local.is_symlink() or not local.resolve().is_relative_to(root): | |
| 62 | 추가: raise ValueError(f"라이선스 경로 이탈: {relative}") | |
| 63 | 추가: content = local.read_bytes() | |
| 64 | 추가: if content != source.extractfile(member).read(): | |
| 65 | 추가: raise ValueError(f"라이선스 원문 변경: {root.name}/{relative}") | |
| 66 | 추가: records.append({ | |
| 67 | 추가: "path": relative.as_posix(), | |
| 68 | 추가: "sha256": hashlib.sha256(content).hexdigest(), | |
| 69 | 추가: "text": content.decode("utf-8"), | |
| 70 | 추가: }) | |
| 71 | 추가: return records | |
| 72 | 추가: | |
| 73 | 추가: | |
| 74 | 추가: def inventory(manifests, project_root=ROOT): | |
| 75 | 추가: locked = {} | |
| 76 | 추가: packages = {} | |
| 77 | 추가: for manifest in manifests: | |
| 78 | 추가: manifest = Path(manifest).resolve(strict=True) | |
| 79 | 추가: lock = tomllib.loads(manifest.with_name("Cargo.lock").read_text()) | |
| 80 | 추가: locked.update({identity(package): package for package in lock["package"]}) | |
| 81 | 추가: packages.update({identity(package): package for package in metadata(manifest)}) | |
| 82 | 추가: if set(locked) != set(packages): | |
| 83 | 추가: raise ValueError(f"Cargo.lock/metadata 불일치: 누락 {sorted(set(locked) - set(packages))}, " | |
| 84 | 추가: f"추가 {sorted(set(packages) - set(locked))}") | |
| 85 | 추가: records = [] | |
| 86 | 추가: for key, package in sorted(packages.items()): | |
| 87 | 추가: if package.get("source"): | |
| 88 | 추가: if not package["source"].startswith("registry+"): | |
| 89 | 추가: raise ValueError(f"지원하지 않는 원문 저장소: {key}") | |
| 90 | 추가: files = registry_files(package, locked[key]) | |
| 91 | 추가: else: | |
| 92 | 추가: root = Path(project_root).resolve() | |
| 93 | 추가: if package["license"] != "MIT" or not Path(package["manifest_path"]).resolve().is_relative_to(root): | |
| 94 | 추가: raise ValueError(f"프로젝트 라이선스 범위 확인 필요: {key}") | |
| 95 | 추가: content = (root / "LICENSE").read_bytes() | |
| 96 | 추가: files = [{"path": "project/LICENSE", "sha256": hashlib.sha256(content).hexdigest(), | |
| 97 | 추가: "text": content.decode("utf-8")}] | |
| 98 | 추가: records.append({"name": key[0], "version": key[1], "source": key[2], | |
| 99 | 추가: "license": package["license"], "files": files}) | |
| 100 | 추가: return records | |
| 101 | 추가: | |
| 102 | 추가: | |
| 103 | 추가: def render(records): | |
| 104 | 추가: missing = [f'{record["name"]}@{record["version"]}' for record in records if not record["files"]] | |
| 105 | 추가: if missing: | |
| 106 | 추가: raise ValueError(f"라이선스 원문 누락 {len(missing)}개: " + ", ".join(missing)) | |
| 107 | 추가: lines = ["Zipelo third-party licenses", "Cargo.lock 전체 의존성의 로컬 원문 고지", ""] | |
| 108 | 추가: for record in records: | |
| 109 | 추가: lines.extend(["=" * 72, f'Crate: {record["name"]} {record["version"]}', | |
| 110 | 추가: f'Source: {record["source"]}', f'License: {record["license"]}', ""]) | |
| 111 | 추가: for file in record["files"]: | |
| 112 | 추가: lines.extend([f'File: {file["path"]}', f'SHA-256: {file["sha256"]}', "", file["text"], ""]) | |
| 113 | 추가: return "\n".join(lines) | |
| 114 | 추가: | |
| 115 | 추가: | |
| 116 | 추가: def generate(manifests, output, audit=None): | |
| 117 | 추가: records = inventory(manifests) | |
| 118 | 추가: if audit: | |
| 119 | 추가: Path(audit).write_text(json.dumps(records, ensure_ascii=False, indent=4) + "\n", encoding="utf-8") | |
| 120 | 추가: text = render(records) | |
| 121 | 추가: Path(output).write_text(text, encoding="utf-8") | |
| 122 | 추가: return records | |
| 123 | 추가: | |
| 124 | 추가: | |
| 125 | 추가: def main(): | |
| 126 | 추가: parser = argparse.ArgumentParser(description=__doc__) | |
| 127 | 추가: parser.add_argument("--manifest", type=Path, action="append", required=True) | |
| 128 | 추가: parser.add_argument("--output", type=Path, required=True) | |
| 129 | 추가: parser.add_argument("--audit", type=Path) | |
| 130 | 추가: args = parser.parse_args() | |
| 131 | 추가: try: | |
| 132 | 추가: records = generate(args.manifest, args.output, args.audit) | |
| 133 | 추가: except (ValueError, OSError, subprocess.CalledProcessError) as error: | |
| 134 | 추가: parser.exit(1, str(error) + "\n") | |
| 135 | 추가: print(f"라이선스 {len(records)}개, 누락 0개") | |
| 136 | 추가: | |
| 137 | 추가: | |
| 138 | 추가: if __name__ == "__main__": | |
| 139 | 추가: main() |
| @@ -14,3 +14,8 @@ Rust 1.99.1, dpkg-deb와 desktop-file-validate가 필요합니다. 출력은 새 | ||
| 14 | 14 | sudo로 처음 설치하면 postinst가 SUDO_USER의 ZIP, 7z, TAR.GZ, GZ, TAR 기본 앱을 xdg-mime으로 적용합니다. 최초 설치에서 기존 기본 앱 선택을 바꿉니다. 업그레이드와 재설정에서는 사용자의 기본 앱 선택을 유지합니다. 다른 패키지 관리자로 설치해 SUDO_USER가 없으면 사용자 설정을 추측하지 않고 연결 후보만 등록합니다. 이 경우 사용자 계정에서 xdg-mime default zipelo.desktop application/zip 등을 실행해야 합니다. 제거는 사용자 MIME 설정을 지우지 않으며 다른 앱을 기본 앱으로 다시 선택할 수 있습니다. |
| 15 | 15 | |
| 16 | 16 | 이 패키지의 검사 범위는 Ubuntu 26.04입니다. 다른 Ubuntu 버전과 Windows 실기는 별도 확인이 필요합니다. |
| 17 | 추가: | |
| 18 | 추가: | |
| 19 | 추가: 앱과 작업자의 Cargo.lock 전체 항목을 cargo metadata --locked --offline --all-features와 대조한 뒤 packaging/licenses.py로 THIRD-PARTY-LICENSES.txt를 생성합니다. 로컬 registry 원문과 캐시 crate의 잠금 체크섬을 확인하며 LICENSE, COPYING, NOTICE 등의 원문을 함께 보존합니다. 원문이 없거나 변조됐거나 metadata 대조에서 누락되면 패키지 생성을 중단합니다. | |
| 20 | 추가: | |
| 21 | 추가: 처음 준비할 때 각 manifest에 cargo +1.99.1 fetch --locked --manifest-path 명령으로 모든 플랫폼의 의존성을 캐시에 받아 두어야 합니다. 고지 생성 중에는 네트워크를 사용하지 않습니다. Windows에는 설치 폴더에, Ubuntu에는 /usr/share/doc/zipelo/THIRD-PARTY-LICENSES.txt에 포함합니다. 파일 동봉 자체가 별도 라이선스 준수 검토를 대신하지는 않습니다. |
| @@ -22,6 +22,12 @@ def build(args): | ||
| 22 | 22 | lib = stage / "usr/lib/zipelo" |
| 23 | 23 | lib.mkdir(parents=True) |
| 24 | 24 | records = {} |
| 25 | 추가: docs = stage / "usr/share/doc/zipelo" | |
| 26 | 추가: docs.mkdir(parents=True) | |
| 27 | 추가: WINDOWS.LICENSES.generate( | |
| 28 | 추가: [ROOT / "experiments/rust-ui-memory-app/Cargo.toml", ROOT / "experiments/rust-archive-worker/Cargo.toml"], | |
| 29 | 추가: docs / "THIRD-PARTY-LICENSES.txt", | |
| 30 | 추가: ) | |
| 25 | 31 | for name, manifest, binary, features in ( |
| 26 | 32 | ("Zipelo", ROOT / "experiments/rust-ui-memory-app/Cargo.toml", "zipelo-ui-memory-app", ("ui",)), |
| 27 | 33 | ("zipelo-archive-worker", ROOT / "experiments/rust-archive-worker/Cargo.toml", "zipelo-archive-worker", ()), |
| @@ -38,8 +44,6 @@ def build(args): | ||
| 38 | 44 | desktop.mkdir(parents=True) |
| 39 | 45 | shutil.copyfile(Path(__file__).with_name("zipelo.desktop"), desktop / "zipelo.desktop") |
| 40 | 46 | subprocess.run(["desktop-file-validate", str(desktop / "zipelo.desktop")], check=True) |
| 41 | 삭제: docs = stage / "usr/share/doc/zipelo" | |
| 42 | 삭제: docs.mkdir(parents=True) | |
| 43 | 47 | shutil.copyfile(ROOT / "LICENSE", docs / "copyright") |
| 44 | 48 | control = stage / "DEBIAN" |
| 45 | 49 | control.mkdir() |
| @@ -45,3 +45,8 @@ Windows 실행 검증 전에는 README 다운로드 버튼이나 release에 배 | ||
| 45 | 45 | Capabilities/RegisteredApplications 구조를 사용하며, |
| 46 | 46 | [Windows 기본 앱 설정 열기](https://learn.microsoft.com/en-us/windows/apps/develop/launch/launch-default-apps-settings)의 |
| 47 | 47 | ms-settings URI를 사용합니다. |
| 48 | 추가: | |
| 49 | 추가: | |
| 50 | 추가: 앱과 작업자의 Cargo.lock 전체 항목을 cargo metadata --locked --offline --all-features와 대조한 뒤 packaging/licenses.py로 THIRD-PARTY-LICENSES.txt를 생성합니다. 로컬 registry 원문과 캐시 crate의 잠금 체크섬을 확인하며 LICENSE, COPYING, NOTICE 등의 원문을 함께 보존합니다. 원문이 없거나 변조됐거나 metadata 대조에서 누락되면 패키지 생성을 중단합니다. | |
| 51 | 추가: | |
| 52 | 추가: 처음 준비할 때 각 manifest에 cargo +1.99.1 fetch --locked --manifest-path 명령으로 모든 플랫폼의 의존성을 캐시에 받아 두어야 합니다. 고지 생성 중에는 네트워크를 사용하지 않습니다. Windows에는 설치 폴더에, Ubuntu에는 /usr/share/doc/zipelo/THIRD-PARTY-LICENSES.txt에 포함합니다. 파일 동봉 자체가 별도 라이선스 준수 검토를 대신하지는 않습니다. |
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | import argparse |
| 4 | 4 | import hashlib |
| 5 | 추가: import importlib.util | |
| 5 | 6 | import json |
| 6 | 7 | import os |
| 7 | 8 | from pathlib import Path |
| @@ -11,6 +12,9 @@ import subprocess | ||
| 11 | 12 | |
| 12 | 13 | ROOT = Path(__file__).resolve().parents[3] |
| 13 | 14 | TARGET = "x86_64-pc-windows-gnu" |
| 15 | 추가: SPEC = importlib.util.spec_from_file_location("licenses", ROOT / "packaging/licenses.py") | |
| 16 | 추가: LICENSES = importlib.util.module_from_spec(SPEC) | |
| 17 | 추가: SPEC.loader.exec_module(LICENSES) | |
| 14 | 18 | |
| 15 | 19 | |
| 16 | 20 | def pe_machine(path): |
| @@ -72,6 +76,7 @@ def build(args): | ||
| 72 | 76 | records = {} |
| 73 | 77 | payload = output / "payload" |
| 74 | 78 | payload.mkdir() |
| 79 | 추가: LICENSES.generate([args.app_manifest, args.worker_manifest], payload / "THIRD-PARTY-LICENSES.txt") | |
| 75 | 80 | for name, manifest, binary, features in ( |
| 76 | 81 | ("Zipelo.exe", args.app_manifest, "zipelo-ui-memory-app", ("ui",)), |
| 77 | 82 | ("zipelo-archive-worker.exe", args.worker_manifest, "zipelo-archive-worker", ()), |
| @@ -99,6 +99,7 @@ Section "Zipelo" | ||
| 99 | 99 | File "payload\Zipelo.exe" |
| 100 | 100 | File "payload\zipelo-archive-worker.exe" |
| 101 | 101 | File "payload\LICENSE" |
| 102 | 추가: File "payload\THIRD-PARTY-LICENSES.txt" | |
| 102 | 103 | File "payload\BUILD-INFO.json" |
| 103 | 104 | IfErrors failed |
| 104 | 105 | WriteUninstaller "$INSTDIR\Uninstall.exe" |
| @@ -141,6 +142,7 @@ Function Rollback | ||
| 141 | 142 | Delete "$INSTDIR\Zipelo.exe" |
| 142 | 143 | Delete "$INSTDIR\zipelo-archive-worker.exe" |
| 143 | 144 | Delete "$INSTDIR\LICENSE" |
| 145 | 추가: Delete "$INSTDIR\THIRD-PARTY-LICENSES.txt" | |
| 144 | 146 | Delete "$INSTDIR\BUILD-INFO.json" |
| 145 | 147 | Delete "$INSTDIR\install.ini" |
| 146 | 148 | Delete "$INSTDIR\Uninstall.exe" |
| @@ -225,6 +227,7 @@ Section "Uninstall" | ||
| 225 | 227 | Delete "$INSTDIR\zipelo-archive-worker.exe" |
| 226 | 228 | IfErrors uninstall_failed |
| 227 | 229 | Delete "$INSTDIR\LICENSE" |
| 230 | 추가: Delete "$INSTDIR\THIRD-PARTY-LICENSES.txt" | |
| 228 | 231 | Delete "$INSTDIR\BUILD-INFO.json" |
| 229 | 232 | Delete "$SMPROGRAMS\Zipelo 개발판.lnk" |
| 230 | 233 | IfErrors uninstall_failed |
| @@ -57,7 +57,7 @@ class InstallerInputTests(unittest.TestCase): | ||
| 57 | 57 | def test_nsis_compiles_payloads_and_finish_callbacks(self): |
| 58 | 58 | payload = self.root / "payload" |
| 59 | 59 | payload.mkdir() |
| 60 | 삭제: for name in ("Zipelo.exe", "zipelo-archive-worker.exe", "LICENSE", "BUILD-INFO.json"): | |
| 60 | 추가: for name in ("Zipelo.exe", "zipelo-archive-worker.exe", "LICENSE", "BUILD-INFO.json", "THIRD-PARTY-LICENSES.txt"): | |
| 61 | 61 | (payload / name).write_bytes(b"compile-only test fixture") |
| 62 | 62 | shutil.copyfile(ROOT / "packaging/windows/rust/installer.nsi", self.root / "installer.nsi") |
| 63 | 63 | completed = subprocess.run(["makensis", "-WX", "installer.nsi"], cwd=self.root, |
| @@ -13,3 +13,13 @@ Ubuntu 실기 스모크는 이 패키지를 sudo로 설치하고 ZIP, 7z, TAR.GZ | ||
| 13 | 13 | sudo 비대화형 권한, Xvfb, xdotool과 ImageMagick import가 필요합니다. 이 검사는 실제 시스템 패키지를 설치하고 사용자 기본 앱을 임시로 바꾸므로 실행 전에 해당 작업의 승인이 필요합니다. 출력은 runs/에 남고 Git에는 포함하지 않습니다. |
| 14 | 14 | |
| 15 | 15 | Windows 설치와 설정 화면, 제거의 실기 검증은 이 Linux 시험에 포함되지 않습니다. release 게시와 다운로드 버튼 갱신도 수행하지 않습니다. |
| 16 | 추가: | |
| 17 | 추가: | |
| 18 | 추가: ## 라이선스 대조 | |
| 19 | 추가: | |
| 20 | 추가: ```sh | |
| 21 | 추가: python3 -m unittest discover -s tests/release-packages -p "test_*.py" | |
| 22 | 추가: python3 packaging/licenses.py --manifest experiments/rust-ui-memory-app/Cargo.toml --manifest experiments/rust-archive-worker/Cargo.toml --output tests/release-packages/runs/THIRD-PARTY-LICENSES.txt --audit tests/release-packages/runs/license-inventory.json | |
| 23 | 추가: ``` | |
| 24 | 추가: | |
| 25 | 추가: 고지의 crate 목록은 두 Cargo.lock과 metadata의 합집합을 기준으로 합니다. 플랫폼이나 활성 기능을 기준으로 항목을 줄이지 않습니다. 원문 파일이 없는 crate는 라이선스 식만으로 대체하지 않으며 최종 파일을 생성하지 않습니다. audit JSON은 누락 원인 확인용이며 배포 고지가 아닙니다. 대조 시험은 원문 보존, 변경된 캐시 거부, metadata 누락과 두 패키지의 조기 중단을 검증합니다. |
| @@ -0,0 +1,130 @@ | ||
| 1 | 추가: """원문 무결성과 고지 누락 시 패키지 생성 차단을 검증함.""" | |
| 2 | 추가: | |
| 3 | 추가: import hashlib | |
| 4 | 추가: import importlib.util | |
| 5 | 추가: import io | |
| 6 | 추가: import json | |
| 7 | 추가: from pathlib import Path | |
| 8 | 추가: import subprocess | |
| 9 | 추가: import tarfile | |
| 10 | 추가: import tempfile | |
| 11 | 추가: import unittest | |
| 12 | 추가: from types import SimpleNamespace | |
| 13 | 추가: from unittest.mock import patch | |
| 14 | 추가: | |
| 15 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 16 | 추가: | |
| 17 | 추가: | |
| 18 | 추가: def load(name, path): | |
| 19 | 추가: spec = importlib.util.spec_from_file_location(name, ROOT / path) | |
| 20 | 추가: module = importlib.util.module_from_spec(spec) | |
| 21 | 추가: spec.loader.exec_module(module) | |
| 22 | 추가: return module | |
| 23 | 추가: | |
| 24 | 추가: | |
| 25 | 추가: LICENSES = load("license_tests", "packaging/licenses.py") | |
| 26 | 추가: WINDOWS = load("windows_license_tests", "packaging/windows/rust/build.py") | |
| 27 | 추가: UBUNTU = load("ubuntu_license_tests", "packaging/ubuntu/rust/build.py") | |
| 28 | 추가: | |
| 29 | 추가: | |
| 30 | 추가: class LicenseTests(unittest.TestCase): | |
| 31 | 추가: def setUp(self): | |
| 32 | 추가: runs = ROOT / "tests/release-packages/runs" | |
| 33 | 추가: runs.mkdir(parents=True, exist_ok=True) | |
| 34 | 추가: temporary = tempfile.TemporaryDirectory(dir=runs) | |
| 35 | 추가: self.addCleanup(temporary.cleanup) | |
| 36 | 추가: self.root = Path(temporary.name) | |
| 37 | 추가: self.manifest = self.root / "Cargo.toml" | |
| 38 | 추가: self.manifest.write_text("") | |
| 39 | 추가: (self.root / "LICENSE").write_text("Project fixture license\n") | |
| 40 | 추가: self.registry = self.root / "registry/src/index/sample-1.0.0" | |
| 41 | 추가: self.registry.mkdir(parents=True) | |
| 42 | 추가: self.package = { | |
| 43 | 추가: "name": "sample", "version": "1.0.0", "source": "registry+https://example.invalid/index", | |
| 44 | 추가: "license": "MIT", "license_file": None, "manifest_path": str(self.registry / "Cargo.toml"), | |
| 45 | 추가: } | |
| 46 | 추가: self.archive = self.root / "registry/cache/index/sample-1.0.0.crate" | |
| 47 | 추가: self.archive.parent.mkdir(parents=True) | |
| 48 | 추가: | |
| 49 | 추가: def fixture(self, files): | |
| 50 | 추가: with tarfile.open(self.archive, "w:gz") as archive: | |
| 51 | 추가: for relative, content in files.items(): | |
| 52 | 추가: destination = self.registry / relative | |
| 53 | 추가: destination.parent.mkdir(parents=True, exist_ok=True) | |
| 54 | 추가: destination.write_bytes(content) | |
| 55 | 추가: member = tarfile.TarInfo("sample-1.0.0/" + relative) | |
| 56 | 추가: member.size = len(content) | |
| 57 | 추가: archive.addfile(member, io.BytesIO(content)) | |
| 58 | 추가: checksum = hashlib.sha256(self.archive.read_bytes()).hexdigest() | |
| 59 | 추가: self.manifest.with_name("Cargo.lock").write_text( | |
| 60 | 추가: 'version = 4\n[[package]]\nname = "sample"\nversion = "1.0.0"\n' | |
| 61 | 추가: 'source = "registry+https://example.invalid/index"\n' + f'checksum = "{checksum}"\n' | |
| 62 | 추가: ) | |
| 63 | 추가: return {"checksum": checksum} | |
| 64 | 추가: | |
| 65 | 추가: def test_inventory_matches_metadata_and_preserves_all_texts(self): | |
| 66 | 추가: originals = {"LICENSE-MIT": b"Fixture MIT text\r\n", "data/NOTICE": b"Fixture attribution\n"} | |
| 67 | 추가: self.fixture(originals) | |
| 68 | 추가: with patch.object(LICENSES, "metadata", return_value=[self.package]): | |
| 69 | 추가: records = LICENSES.inventory([self.manifest], self.root) | |
| 70 | 추가: text = LICENSES.render(records) | |
| 71 | 추가: self.assertEqual([(r["name"], r["version"]) for r in records], [("sample", "1.0.0")]) | |
| 72 | 추가: self.assertEqual(text.count("Crate: sample 1.0.0\n"), 1) | |
| 73 | 추가: for content in originals.values(): | |
| 74 | 추가: self.assertIn(content.decode(), text) | |
| 75 | 추가: self.assertIn(hashlib.sha256(content).hexdigest(), text) | |
| 76 | 추가: | |
| 77 | 추가: def test_missing_license_prevents_output(self): | |
| 78 | 추가: self.fixture({"README.md": b"No license text in fixture"}) | |
| 79 | 추가: output = self.root / "THIRD-PARTY-LICENSES.txt" | |
| 80 | 추가: with patch.object(LICENSES, "metadata", return_value=[self.package]): | |
| 81 | 추가: with self.assertRaisesRegex(ValueError, "원문 누락 1개"): | |
| 82 | 추가: LICENSES.generate([self.manifest], output) | |
| 83 | 추가: self.assertFalse(output.exists()) | |
| 84 | 추가: | |
| 85 | 추가: def test_metadata_omission_is_not_silently_ignored(self): | |
| 86 | 추가: self.fixture({"LICENSE": b"Fixture license"}) | |
| 87 | 추가: with patch.object(LICENSES, "metadata", return_value=[]): | |
| 88 | 추가: with self.assertRaisesRegex(ValueError, "Cargo.lock/metadata 불일치"): | |
| 89 | 추가: LICENSES.inventory([self.manifest], self.root) | |
| 90 | 추가: | |
| 91 | 추가: def test_modified_registry_license_is_rejected(self): | |
| 92 | 추가: locked = self.fixture({"LICENSE": b"Fixture license"}) | |
| 93 | 추가: (self.registry / "LICENSE").write_bytes(b"Modified license") | |
| 94 | 추가: with self.assertRaisesRegex(ValueError, "원문 변경"): | |
| 95 | 추가: LICENSES.registry_files(self.package, locked) | |
| 96 | 추가: | |
| 97 | 추가: def test_wrong_archive_checksum_is_rejected(self): | |
| 98 | 추가: self.fixture({"LICENSE": b"Fixture license"}) | |
| 99 | 추가: with self.assertRaisesRegex(ValueError, "체크섬 불일치"): | |
| 100 | 추가: LICENSES.registry_files(self.package, {"checksum": "0" * 64}) | |
| 101 | 추가: | |
| 102 | 추가: def test_license_file_cannot_escape_package(self): | |
| 103 | 추가: locked = self.fixture({"LICENSE": b"Fixture license"}) | |
| 104 | 추가: self.package["license_file"] = str(self.root / "LICENSE") | |
| 105 | 추가: with self.assertRaises(ValueError): | |
| 106 | 추가: LICENSES.registry_files(self.package, locked) | |
| 107 | 추가: | |
| 108 | 추가: def test_metadata_command_is_locked_and_offline(self): | |
| 109 | 추가: with patch.object(LICENSES.subprocess, "run", return_value=subprocess.CompletedProcess([], 0, '{"packages": []}')) as run: | |
| 110 | 추가: self.assertEqual(LICENSES.metadata(self.manifest), []) | |
| 111 | 추가: command = run.call_args.args[0] | |
| 112 | 추가: self.assertIn("--locked", command) | |
| 113 | 추가: self.assertIn("--offline", command) | |
| 114 | 추가: self.assertIn("--all-features", command) | |
| 115 | 추가: | |
| 116 | 추가: def test_both_packagers_stop_before_build_on_missing_licenses(self): | |
| 117 | 추가: for builder, binaries in [(WINDOWS, WINDOWS), (UBUNTU, UBUNTU.WINDOWS)]: | |
| 118 | 추가: with self.subTest(builder=builder.__name__): | |
| 119 | 추가: output = self.root / builder.__name__ | |
| 120 | 추가: args = SimpleNamespace(output=output, target_dir=self.root / "target", profile="release", | |
| 121 | 추가: app_manifest=self.manifest, worker_manifest=self.manifest) | |
| 122 | 추가: with patch.object(binaries.LICENSES, "generate", side_effect=ValueError("원문 누락")): | |
| 123 | 추가: with patch.object(binaries, "build_binary") as build_binary: | |
| 124 | 추가: with self.assertRaisesRegex(ValueError, "원문 누락"): | |
| 125 | 추가: builder.build(args) | |
| 126 | 추가: build_binary.assert_not_called() | |
| 127 | 추가: | |
| 128 | 추가: | |
| 129 | 추가: if __name__ == "__main__": | |
| 130 | 추가: unittest.main() |
| @@ -99,5 +99,102 @@ | ||
| 99 | 99 | "tests/release-packages/runs/lifecycle-regression.log", |
| 100 | 100 | "tests/release-packages/runs/local-lifecycle.log" |
| 101 | 101 | ] |
| 102 | 추가: }, | |
| 103 | 추가: "third_party_licenses": { | |
| 104 | 추가: "status": "blocked-missing-registry-originals", | |
| 105 | 추가: "base_remote_main": "8bfa25456b936346b4f1808233afb4551e769718", | |
| 106 | 추가: "tested_source_local_commit": "6b601591663f937a642d134e248b76e6a8dc20cc", | |
| 107 | 추가: "tested_code_tree": "d71bfec8a53025376405fce2ee36de6012e428fa", | |
| 108 | 추가: "metadata_locked_crates": 403, | |
| 109 | 추가: "registry_crates": 397, | |
| 110 | 추가: "workspace_crates": 6, | |
| 111 | 추가: "metadata_lock_mismatches": 0, | |
| 112 | 추가: "crates_with_original_files": 345, | |
| 113 | 추가: "missing_originals": [ | |
| 114 | 추가: "[email protected]", | |
| 115 | 추가: "[email protected]", | |
| 116 | 추가: "[email protected]", | |
| 117 | 추가: "[email protected]", | |
| 118 | 추가: "[email protected]", | |
| 119 | 추가: "[email protected]", | |
| 120 | 추가: "[email protected]", | |
| 121 | 추가: "[email protected]", | |
| 122 | 추가: "[email protected]", | |
| 123 | 추가: "[email protected]", | |
| 124 | 추가: "[email protected]", | |
| 125 | 추가: "[email protected]", | |
| 126 | 추가: "[email protected]", | |
| 127 | 추가: "[email protected]", | |
| 128 | 추가: "[email protected]", | |
| 129 | 추가: "[email protected]", | |
| 130 | 추가: "[email protected]", | |
| 131 | 추가: "[email protected]", | |
| 132 | 추가: "[email protected]", | |
| 133 | 추가: "[email protected]", | |
| 134 | 추가: "[email protected]", | |
| 135 | 추가: "[email protected]", | |
| 136 | 추가: "[email protected]", | |
| 137 | 추가: "[email protected]", | |
| 138 | 추가: "[email protected]", | |
| 139 | 추가: "[email protected]", | |
| 140 | 추가: "[email protected]", | |
| 141 | 추가: "[email protected]", | |
| 142 | 추가: "[email protected]", | |
| 143 | 추가: "[email protected]+11769913", | |
| 144 | 추가: "[email protected]", | |
| 145 | 추가: "[email protected]", | |
| 146 | 추가: "[email protected]", | |
| 147 | 추가: "[email protected]", | |
| 148 | 추가: "[email protected]", | |
| 149 | 추가: "[email protected]", | |
| 150 | 추가: "[email protected]", | |
| 151 | 추가: "[email protected]", | |
| 152 | 추가: "[email protected]", | |
| 153 | 추가: "[email protected]", | |
| 154 | 추가: "[email protected]", | |
| 155 | 추가: "[email protected]", | |
| 156 | 추가: "[email protected]", | |
| 157 | 추가: "[email protected]", | |
| 158 | 추가: "[email protected]", | |
| 159 | 추가: "[email protected]", | |
| 160 | 추가: "[email protected]", | |
| 161 | 추가: "[email protected]", | |
| 162 | 추가: "[email protected]", | |
| 163 | 추가: "[email protected]", | |
| 164 | 추가: "[email protected]", | |
| 165 | 추가: "[email protected]", | |
| 166 | 추가: "[email protected]", | |
| 167 | 추가: "[email protected]", | |
| 168 | 추가: "[email protected]", | |
| 169 | 추가: "[email protected]", | |
| 170 | 추가: "[email protected]", | |
| 171 | 추가: "[email protected]" | |
| 172 | 추가: ], | |
| 173 | 추가: "unit_command": "python3 -m unittest discover -s tests/release-packages -p \"test_*.py\" -v", | |
| 174 | 추가: "package_unit_tests_passed": 15, | |
| 175 | 추가: "new_license_tests_passed": 8, | |
| 176 | 추가: "local_command": "python3 tests/ci/run_rust.py local", | |
| 177 | 추가: "local_exit_code": 0, | |
| 178 | 추가: "rust_tests_passed": 953, | |
| 179 | 추가: "runner_tests_passed": 34, | |
| 180 | 추가: "linux_build_targets_passed": 21, | |
| 181 | 추가: "linux_test_targets_passed": 21, | |
| 182 | 추가: "windows_cross_targets_passed": 21, | |
| 183 | 추가: "windows_builder_exit_code": 1, | |
| 184 | 추가: "ubuntu_builder_exit_code": 1, | |
| 185 | 추가: "builder_failure_reason": "라이선스 원문 누락 58개", | |
| 186 | 추가: "final_packages_created": false, | |
| 187 | 추가: "package_contents_verified": false, | |
| 188 | 추가: "registry_preparation": "누락된 다른 플랫폼용 crate는 cargo fetch --locked로 캐시에 준비함. 생성은 cargo metadata --offline과 로컬 원문만 사용함.", | |
| 189 | 추가: "required_decision": "로컬 registry에 원문이 없는 crate에 대해 고정 upstream 보충 원문을 저장소에 포함할 수 있는지 확인 필요", | |
| 190 | 추가: "source_policy": "기존 시험용 보충 JSON이나 일반 라이선스 템플릿을 원문 대신 사용하지 않음", | |
| 191 | 추가: "local_logs": [ | |
| 192 | 추가: "tests/release-packages/runs/licenses/unit.log", | |
| 193 | 추가: "tests/release-packages/runs/licenses/local-fixed.log", | |
| 194 | 추가: "tests/release-packages/runs/licenses/generator.log", | |
| 195 | 추가: "tests/release-packages/runs/licenses/blocked-builds.json" | |
| 196 | 추가: ], | |
| 197 | 추가: "initial_local_failure": "NSIS 필수 고지 파일 추가로 기존 시험 payload가 실패하여 시험 입력에 해당 파일을 추가함. 이후 전체 local 통과.", | |
| 198 | 추가: "evidence_note": "코드 검증 뒤 이 검증 JSON만 갱신함" | |
| 102 | 199 | } |
| 103 | 200 | } |