Repository navigation
feat: accept the floating sdlc launcher in XII; constitution 1.46.0 #157
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
Changes from all commits
2603041
371e59d
db3384c
ea74bee
a8dc712
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/bin/sh | ||
| # Run `sdlc` with no `rev:` to pin: get the launcher from the image, then run it. | ||
| # | ||
| # The launcher (bin/sdlc) ships inside quay.io/crunchtools/sdlc, so it floats | ||
| # with the image tag exactly as the tools in the image do: `:latest` by | ||
| # default, SDLC_IMAGE=main for what has merged and not been released, a | ||
| # release such as SDLC_IMAGE=0.9.0, or SDLC_IMAGE=@sha256:<digest>. Nothing | ||
| # else: this file runs whatever it pulls, so it pulls from that one repository. | ||
| # A seat trying a local build runs a python-sdlc clone's bin/sdlc instead. The | ||
| # image prints the launcher with its own ref written into it (`sdlc launcher | ||
| # <ref>`), so the launcher and the image it starts cannot disagree. | ||
| # | ||
| # A converted repo carries this file as .sdlc/bin/sdlc, and its hooks and its | ||
| # CI job run it (scripts/convert_repo.py writes it). Nothing in it names a | ||
| # release, so nothing ever bumps it, and the constitution pins its bytes. An | ||
| # `sdlc` RPM would install the same file as /usr/bin/sdlc. | ||
| # | ||
| # Host contract: podman and POSIX sh, nothing else. Never a pipe into `sh`: a | ||
| # failed pull would hand sh nothing, and nothing runs and exits 0. An image | ||
| # that cannot print its launcher is a 2 -- the gate could not run. | ||
|
|
||
| set -u | ||
|
|
||
| FLEET=quay.io/crunchtools/sdlc | ||
| refuse() { | ||
| printf 'sdlc: GATE CANNOT RUN: SDLC_IMAGE=%s is not main, latest, X.Y.Z or @sha256:<64 hex> of %s\n' \ | ||
| "${SDLC_IMAGE:-}" "$FLEET" >&2 | ||
| exit 2 | ||
| } | ||
|
|
||
| # The value, with the repository named in full or not at all. | ||
| want=${SDLC_IMAGE:-latest} | ||
| case $want in | ||
| "$FLEET":*) want=${want#"$FLEET":} ;; | ||
| "$FLEET"@*) want=${want#"$FLEET"} ;; | ||
| esac | ||
| case $want in | ||
| main|latest) image=$FLEET:$want ;; | ||
| @sha256:*) | ||
| hex=${want#@sha256:} | ||
| case $hex in *[!0-9a-f]*) refuse ;; esac | ||
| [ "${#hex}" -eq 64 ] || refuse | ||
| image=$FLEET$want ;; | ||
| *[!0-9.]*|.*|*.|*..*|*.*.*.*) refuse ;; | ||
| *.*.*) image=$FLEET:$want ;; | ||
| *) refuse ;; | ||
| esac | ||
|
|
||
| dir=$(mktemp -d) || exit 2 | ||
| trap 'rm -rf "$dir"' EXIT | ||
| trap 'exit 2' HUP INT TERM | ||
|
|
||
| # --pull=newer: :latest moves, and a stale local copy is how a two-week-old | ||
| # reviewer once judged trentina. Offline, podman keeps the copy it has. | ||
| if ! podman --events-backend=none run --rm --log-driver=none --network=none \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEDIUM (Test Coverage): The new bootstrap script invokes an external Suggestion: Add shell-level tests using a stub Evidence:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a bug: tests/sdlc-bootstrap is a byte-for-byte fixture of python-sdlc's bin/sdlc-bootstrap, kept here only so the validator's sha256 pin is tested against real bytes; this repo never runs it. Its behaviour (stub podman, pull failure, empty output, argv and exit status) is tested where it lives, in python-sdlc#62's tests/test_host_contract.sh and tests/contract.sh. |
||
| --cap-drop=all --security-opt=no-new-privileges --pull=newer \ | ||
| -- "$image" launcher "$image" > "$dir/sdlc" || [ ! -s "$dir/sdlc" ]; then | ||
| printf 'sdlc: GATE CANNOT RUN: %s could not print its launcher\n' "$image" >&2 | ||
| exit 2 | ||
| fi | ||
| # The launcher reads SDLC_IMAGE too; it gets the full reference checked here. | ||
| SDLC_IMAGE=$image sh "$dir/sdlc" "$@" | ||
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.
MEDIUM (Test Coverage): The new image-reference allowlist has multiple parsing and rejection branches, but no tests were added or updated to cover them. Regressions could accept an unintended reference or reject a supported one without detection.
Suggestion: Add table-driven shell tests for
main,latest, version refs, fully qualified refs, and valid digests, plus rejected refs and digest length/character boundary cases. Mock the pull command to verify invalid values are rejected before any image is pulled.Evidence:
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.
Not a bug: tests/sdlc-bootstrap is a byte-for-byte fixture of python-sdlc's bin/sdlc-bootstrap at a483867, kept here only so the validator's sha256 pin is tested against real bytes; this repo never runs it. The image-ref allowlist this finding asks about is table-tested at its source, python-sdlc a483867 tests/test_host_contract.sh ("the floating launcher" section). It covers main, X.Y.Z, @sha256 and fully qualified refs as accepted. It covers localhost/, other repos, 1.2, v1.2.3, 1.2.3.4, 1..3, a short or non-hex digest,
main;idand--privilegedas refused with exit 2 before podman runs.