-
Notifications
You must be signed in to change notification settings - Fork 1
fix(release): gate release identity and platform trust #1126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
seonghobae
wants to merge
17
commits into
develop
Choose a base branch
from
fix/trusted-release-version-identity-960
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9a6a3b8
test(release): reproduce desktop version identity drift
seonghobae 6749f4e
test(release): narrow RED to release version gate
seonghobae 261a9a2
feat(release): add fail-closed version identity guard
seonghobae 8d95854
fix(release): enforce version identity in preflight harness
seonghobae 164f344
test(release): reject ambiguous VERSION authority
seonghobae f3ebe4d
fix(release): parse VERSION as a single authority line
seonghobae d8efdf7
test(release): require identity gate before publication
seonghobae 96d6f16
fix(release): gate artifact publication on version identity
seonghobae 06ef13e
fix(release): keep workflow contract dependency-free
seonghobae 3ecadd7
refactor(release): use semantic identity names
seonghobae b0d5ecb
test(release): use semantic release-identity names
seonghobae dfbcbca
docs(release): document identity-gate security boundary
seonghobae 764e06c
test(release): require platform trust before publication
seonghobae 13da983
feat(release): verify native signing and notarization evidence
seonghobae 8de728b
fix(release): block tag packaging without native trust
seonghobae d33bb96
test(release): exercise tag packaging trust boundary
seonghobae b0bfbd2
Merge protected develop into trusted release owner
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| #!/usr/bin/env python3 | ||
| """Fail closed when BandScope release-version projections disagree. | ||
|
|
||
| Security Notes: | ||
| - ``repository_root`` is an already-selected repository boundary; this guard | ||
| reads only the fixed ``VERSION``, ``package.json``, and Tauri configuration | ||
| paths beneath it and never follows metadata-provided file paths. | ||
| - VERSION and JSON fields are validated as exact, non-empty, trimmed strings | ||
| before comparison; malformed text or JSON fails closed without echoing values. | ||
| - The guard has no network, filesystem-write, subprocess, update, credential, | ||
| signing, or publication authority. It only returns a version or a failure. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| import os | ||
| import sys | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| _REPOSITORY_ROOT = Path(__file__).resolve().parents[2] | ||
|
|
||
|
|
||
| def _read_json_object(metadata_path: Path) -> dict[str, Any]: | ||
| """Read one release metadata document and require a JSON object root.""" | ||
| try: | ||
| metadata_document = json.loads(metadata_path.read_text(encoding="utf-8")) | ||
| except (OSError, UnicodeError, json.JSONDecodeError) as metadata_error: | ||
| raise ValueError( | ||
| f"could not read release metadata: {metadata_path.name}" | ||
| ) from metadata_error | ||
| if not isinstance(metadata_document, dict): | ||
| raise ValueError(f"release metadata must be an object: {metadata_path.name}") | ||
| return metadata_document | ||
|
|
||
|
|
||
| def _required_string( | ||
| metadata_document: dict[str, Any], field_name: str, source_name: str | ||
| ) -> str: | ||
| """Return a non-empty string field without coercing malformed metadata.""" | ||
| field_value = metadata_document.get(field_name) | ||
| if ( | ||
| not isinstance(field_value, str) | ||
| or not field_value.strip() | ||
| or field_value != field_value.strip() | ||
| ): | ||
| raise ValueError( | ||
| f"{source_name} {field_name} must be a non-empty trimmed string" | ||
| ) | ||
| return field_value | ||
|
|
||
|
|
||
| def verify_release_identity( | ||
| repository_root: Path, release_tag: str | None = None | ||
| ) -> str: | ||
| """Verify package, Tauri, and optional tag versions against ``VERSION``.""" | ||
| try: | ||
| version_text = (repository_root / "VERSION").read_text(encoding="utf-8") | ||
| except (OSError, UnicodeError) as identity_error: | ||
| raise ValueError("could not read authoritative VERSION") from identity_error | ||
|
|
||
| version_lines = version_text.splitlines() | ||
| if ( | ||
| len(version_lines) != 1 | ||
| or not version_lines[0] | ||
| or version_lines[0] != version_lines[0].strip() | ||
| or version_text != f"{version_lines[0]}\n" | ||
| ): | ||
| raise ValueError("VERSION must contain exactly one non-empty version line") | ||
| release_version = version_lines[0] | ||
|
|
||
| package_document = _read_json_object(repository_root / "package.json") | ||
| tauri_document = _read_json_object( | ||
| repository_root / "apps" / "desktop" / "src-tauri" / "tauri.conf.json" | ||
| ) | ||
|
|
||
| package_version = _required_string( | ||
| package_document, "version", "package.json" | ||
| ) | ||
| tauri_version = _required_string( | ||
| tauri_document, "version", "tauri.conf.json" | ||
| ) | ||
| if package_version != release_version: | ||
| raise ValueError("package.json version does not match VERSION") | ||
| if tauri_version != release_version: | ||
| raise ValueError("tauri.conf.json version does not match VERSION") | ||
|
|
||
| if release_tag is not None and release_tag != f"v{release_version}": | ||
| raise ValueError("release tag does not match VERSION") | ||
|
|
||
| return release_version | ||
|
|
||
|
|
||
| def main() -> int: | ||
| """Run the release identity gate for repository and tag-triggered workflows.""" | ||
| release_tag = ( | ||
| os.environ.get("GITHUB_REF_NAME") | ||
| if os.environ.get("GITHUB_REF_TYPE") == "tag" | ||
| else None | ||
| ) | ||
| try: | ||
| release_version = verify_release_identity( | ||
| _REPOSITORY_ROOT, release_tag=release_tag | ||
| ) | ||
| except ValueError as identity_error: | ||
| print(f"release identity check failed: {identity_error}", file=sys.stderr) | ||
| return 1 | ||
| print(f"BandScope release identity verified: v{release_version}") | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| raise SystemExit(main()) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.