-
Notifications
You must be signed in to change notification settings - Fork 0
release: v0.3.0-beta.4 #171
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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,94 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| usage() { | ||
| printf 'usage: %s --dist <release-distribution-directory>\n' "${0##*/}" >&2 | ||
| exit 2 | ||
| } | ||
|
|
||
| if [[ "$#" != 2 || "$1" != "--dist" ]]; then | ||
| usage | ||
| fi | ||
|
|
||
| readonly REPOSITORY_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" | ||
| readonly DIST_DIRECTORY="$(cd "$2" && pwd -P)" | ||
| readonly DOCKER_BIN="${DOCKER_BIN:-docker}" | ||
|
|
||
| command -v "$DOCKER_BIN" >/dev/null | ||
| command -v python3 >/dev/null | ||
|
|
||
| shopt -s nullglob | ||
| amd64_archives=("${DIST_DIRECTORY}"/sith_*_linux_amd64.tar.gz) | ||
| arm64_archives=("${DIST_DIRECTORY}"/sith_*_linux_arm64.tar.gz) | ||
| if [[ "${#amd64_archives[@]}" != 1 || "${#arm64_archives[@]}" != 1 ]]; then | ||
| printf 'expected exactly one Linux archive per supported architecture in %s\n' "$DIST_DIRECTORY" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| context_directory="$(mktemp -d)" | ||
| builder="sith-release-hub-${RANDOM}-$$" | ||
| cleanup() { | ||
| "$DOCKER_BIN" buildx rm --force "$builder" >/dev/null 2>&1 || true | ||
| rm -rf "$context_directory" | ||
| } | ||
| trap cleanup EXIT | ||
| install -d -m 0755 "$context_directory/bin/linux/amd64" "$context_directory/bin/linux/arm64" | ||
| tar -xzf "${amd64_archives[0]}" -C "$context_directory/bin/linux/amd64" sith | ||
| tar -xzf "${arm64_archives[0]}" -C "$context_directory/bin/linux/arm64" sith | ||
| install -m 0644 "$REPOSITORY_ROOT/Containerfile" "$context_directory/Containerfile" | ||
| test -x "$context_directory/bin/linux/amd64/sith" | ||
| test -x "$context_directory/bin/linux/arm64/sith" | ||
|
|
||
| oci_layout="$context_directory/sith-hub.oci" | ||
| "$DOCKER_BIN" buildx create --driver docker-container --name "$builder" >/dev/null | ||
| "$DOCKER_BIN" buildx inspect --builder "$builder" --bootstrap >/dev/null | ||
| "$DOCKER_BIN" buildx build \ | ||
| --builder "$builder" \ | ||
| --platform linux/amd64,linux/arm64 \ | ||
| --provenance=false \ | ||
| --sbom=false \ | ||
| --file "$context_directory/Containerfile" \ | ||
| --output "type=oci,dest=${oci_layout}" \ | ||
| "$context_directory" | ||
|
|
||
| oci_directory="$context_directory/oci-layout" | ||
| install -d -m 0755 "$oci_directory" | ||
| tar -xf "$oci_layout" -C "$oci_directory" | ||
| python3 - "$oci_directory" <<'PY' | ||
| import json | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| root = Path(sys.argv[1]) | ||
| index_media_types = { | ||
| "application/vnd.oci.image.index.v1+json", | ||
| "application/vnd.docker.distribution.manifest.list.v2+json", | ||
| } | ||
|
|
||
| def indexed_platforms(index): | ||
| platforms = set() | ||
| for manifest in index.get("manifests", []): | ||
| if manifest.get("mediaType") in index_media_types: | ||
| algorithm, digest = manifest["digest"].split(":", 1) | ||
| with (root / "blobs" / algorithm / digest).open(encoding="utf-8") as nested_file: | ||
| platforms.update(indexed_platforms(json.load(nested_file))) | ||
| continue | ||
| platform = manifest.get("platform", {}) | ||
| os_name = platform.get("os") | ||
| architecture = platform.get("architecture") | ||
| if os_name is not None and architecture is not None: | ||
| platforms.add((os_name, architecture)) | ||
| return platforms | ||
|
|
||
| with (root / "index.json").open(encoding="utf-8") as index_file: | ||
| platforms = indexed_platforms(json.load(index_file)) | ||
|
|
||
| expected = {("linux", "amd64"), ("linux", "arm64")} | ||
| if platforms != expected: | ||
| raise SystemExit(f"OCI layout platforms = {sorted(platforms)!r}, want {sorted(expected)!r}") | ||
| PY | ||
|
|
||
| printf 'release hub OCI layout verified from release archives\n' |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
GitHub CLI gh attestation verify --source-ref exact syntax refs/tags tag release workflow identity💡 Result:
The gh attestation verify command in the GitHub CLI allows you to enforce that an artifact's provenance matches a specific Git reference (such as a tag) using the --source-ref flag [1][2]. When verifying an artifact against a release tag and a specific workflow identity, the syntax is as follows: gh attestation verify \ --repo / \ --source-ref refs/tags/ \ --signer-workflow //
@refs/tags/Explanation of flags: --repo /: Specifies the repository associated with the artifact [3][2]. This is required for fetching the attestation [4]. --source-ref refs/tags/: Enforces that the Git reference associated with the source repository matches the provided tag exactly [5][2]. --signer-workflow@refs/tags/: Enforces that the workflow that signed the attestation matches the specified workflow file, optionally scoped to a specific tag or commit [4][2][6]. Example: To verify an artifact against a release version (e.g., v1.0.0) and a specific release workflow: gh attestation verify my-artifact.zip \ --repo my-org/my-repo \ --source-ref refs/tags/v1.0.0 \ --signer-workflow my-org/my-repo/.github/workflows/release.yaml@refs/tags/v1.0.0 This ensures the artifact was produced by the specified workflow running on the exact tag provided [4][6].Citations:
gh attestation verifycli/cli#10308Bind attestation verification to the exact release tag.
Add
--source-ref "refs/tags/$tag"to bothgh attestation verifycommands so the attestation must come from the release tag, not just the workflow file.🤖 Prompt for AI Agents