Fix bootstrap CLI handling and cleanup robustness in kInit.sh #24

Merged
kleb merged 1 commit from fix/kinit-bootstrap-audit into main 2026-06-13 00:23:59 +02:00
Owner

What changed

Audit follow-up on the kInit.sh bootstrap. Six fixes, all in kInit.sh:

  • Handle --help/-h in parseBootstrapOptions() before the root check and the utils.sh download, so help works without root or network access. A minimal color table is declared before utils.sh is sourced (utils.sh re-declares the identical table).
  • Suppress the misleading "Installation complete/failed" cleanup status after help or usage-error output (helpRequested flag).
  • Add --timeout/--tries to the bootstrap wget call (previously unbounded: wget defaults retry 20 times with a 900s read timeout) and honor KINIT_DOWNLOAD_TIMEOUT in both wget and curl branches.
  • Reject option-like values (--*) in bootstrap option parsing, matching requireOptionValue() semantics; --base-url --analyze previously set BASE_URL="--analyze" and attempted a garbage download.
  • Report the failing URL on stderr (with newline) when the utils.sh download fails.
  • Guard the showSummary greps with || true so a served kInit.vars missing an *_EXECUTE key cannot abort cleanup under set -e -o pipefail.

Security / risk impact

No changes to the security-relevant paths: pinned bootstrap hash, checksum manifest validation, and HTTPS enforcement are untouched. kInit.sh is excluded from checksums.sha256 and installer/utils.sh is unchanged, so no hash regeneration was needed (verified: pinned hashes still match).

Validation

  • bash -n and shellcheck clean (only pre-existing info-level SC2059 color-style notes remain)
  • 19 functional tests against a local HTTP server serving the repo: profile URL normalization/HTTPS enforcement, bootstrap download, pinned-hash validation (accept genuine / reject tampered utils.sh), manifest validation (official URL + pinned hash; custom URL refused without explicit hash, accepted with correct hash, rejected with wrong hash), --base-url location derivation, secret/URL redaction, summary fallback
  • --help exits 0 without root/network; all four bad-argument paths exit 2 with correct messages
  • sha256sum -c checksums.sha256 passes
  • Not run: full installer run on a Debian/Ubuntu host (no Linux environment available); recommended before merge per AGENTS.md
## What changed Audit follow-up on the `kInit.sh` bootstrap. Six fixes, all in `kInit.sh`: - Handle `--help`/`-h` in `parseBootstrapOptions()` before the root check and the `utils.sh` download, so help works without root or network access. A minimal color table is declared before `utils.sh` is sourced (utils.sh re-declares the identical table). - Suppress the misleading "Installation complete/failed" cleanup status after help or usage-error output (`helpRequested` flag). - Add `--timeout`/`--tries` to the bootstrap wget call (previously unbounded: wget defaults retry 20 times with a 900s read timeout) and honor `KINIT_DOWNLOAD_TIMEOUT` in both wget and curl branches. - Reject option-like values (`--*`) in bootstrap option parsing, matching `requireOptionValue()` semantics; `--base-url --analyze` previously set `BASE_URL="--analyze"` and attempted a garbage download. - Report the failing URL on stderr (with newline) when the `utils.sh` download fails. - Guard the `showSummary` greps with `|| true` so a served `kInit.vars` missing an `*_EXECUTE` key cannot abort cleanup under `set -e -o pipefail`. ## Security / risk impact No changes to the security-relevant paths: pinned bootstrap hash, checksum manifest validation, and HTTPS enforcement are untouched. `kInit.sh` is excluded from `checksums.sha256` and `installer/utils.sh` is unchanged, so no hash regeneration was needed (verified: pinned hashes still match). ## Validation - `bash -n` and shellcheck clean (only pre-existing info-level SC2059 color-style notes remain) - 19 functional tests against a local HTTP server serving the repo: profile URL normalization/HTTPS enforcement, bootstrap download, pinned-hash validation (accept genuine / reject tampered `utils.sh`), manifest validation (official URL + pinned hash; custom URL refused without explicit hash, accepted with correct hash, rejected with wrong hash), `--base-url` location derivation, secret/URL redaction, summary fallback - `--help` exits 0 without root/network; all four bad-argument paths exit 2 with correct messages - `sha256sum -c checksums.sha256` passes - Not run: full installer run on a Debian/Ubuntu host (no Linux environment available); recommended before merge per AGENTS.md
- Handle --help/-h before the root check and utils.sh download so help
  works without root or network access
- Suppress misleading 'Installation complete/failed' status after help
  or usage-error output
- Add timeout and retry limit to the bootstrap wget call and honor
  KINIT_DOWNLOAD_TIMEOUT in both wget and curl branches
- Reject option-like values (--*) in bootstrap option parsing
- Report the failing URL on stderr when the utils.sh download fails
- Keep cleanup summary alive under set -e -o pipefail when a served
  kInit.vars is missing module EXECUTE keys
Collaborator

Codex review

Verdict: no findings

No must-fix issues were found in the reviewed diff.

Risk appears low; the diff is narrowly scoped and I did not find a validated regression in the changed behavior.

Reviewed by Codex at ea73fbad28. This comment is conservative and based only on the PR diff, metadata, and supplied repository context.

<!-- codex-forgejo-review --> <!-- codex-forgejo-review-head:ea73fbad287e429f2f611020be9e707afb8e502f --> ## Codex review **Verdict:** no findings No must-fix issues were found in the reviewed diff. Risk appears low; the diff is narrowly scoped and I did not find a validated regression in the changed behavior. _Reviewed by Codex at `ea73fbad28`. This comment is conservative and based only on the PR diff, metadata, and supplied repository context._ <!-- codex-forgejo-review-state:eyJoZWFkU2hhIjoiZWE3M2ZiYWQyODdlNDI5ZjJmNjExMDIwYmU5ZTcwN2FmYjhlNTAyZiIsInN1bW1hcnkiOiJSaXNrIGFwcGVhcnMgbG93OyB0aGUgZGlmZiBpcyBuYXJyb3dseSBzY29wZWQgYW5kIEkgZGlkIG5vdCBmaW5kIGEgdmFsaWRhdGVkIHJlZ3Jlc3Npb24gaW4gdGhlIGNoYW5nZWQgYmVoYXZpb3IuIiwiZmluZGluZ3MiOltdfQ== -->
kleb merged commit 0788ccf3b5 into main 2026-06-13 00:23:58 +02:00
kleb deleted branch fix/kinit-bootstrap-audit 2026-06-13 00:23:59 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kleb/kInit!24
No description provided.