fix(framework/tools): wrapper hardening — TLS validation, cred-path fallback, no-CI fast-exit #551
Reference in New Issue
Block a user
Delete Branch "fix/wrapper-hardening-tls-credpath-cicwait"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #550
One wrapper-hardening PR fixing three authorized defects in
packages/mosaic/framework/tools/. Design pre-decided by the lead; implemented faithfully.F-03 — TLS now validated for public hosts;
-kretained only for private-IP / opt-in_mosaic_tls_opthelper in_lib/credentials.shdecides the curl TLS flag per target URL:-k). MITM matters on the WAN — these were previously unverified.-k(10.,127.,192.168.,172.16–31.). These are self-signed certs on the trusted LAN (Portainer172.16.0.253:10443, Proxmox172.16.1.108:8007/172.20.1.20:8007, etc.) that legitimately need-k.MOSAIC_INSECURE_TLSopt-in →-kfor any explicit override.mosaic_http/mosaic_http_post/mosaic_http_patchnow usecurl -sS $_tls(kept-s, added-Sso real errors surface, scoped flag unquoted so empty expands to nothing). Headers/body/-Xunchanged._lib.sh,pipeline-status.sh,pipeline-list.sh,pipeline-trigger.sh) talk only to the two CI hosts (ci.uscllc.com,ci.mosaicstack.dev), both public and TLS-valid (spot-verified HTTP 200 with no-k). For these,-sk→-sS(straight removal; no helper needed since they never hit private hosts).F-02 — cred-path fallback chain; legacy stays as final fallback
MOSAIC_CREDENTIALS_FILEnow resolves via: env first →~/.config/mosaic/credentials.json→ legacy~/src/jarvis-brain/credentials.json. The legacy path is kept as the final fallback so the running fleet keeps working — the default is NOT flipped out from under it. (Verified on this fleet: with env unset, resolves to the legacy path since the standard config path doesn't yet exist, andload_credentials woodpeckersucceeds.)F-06 —
pr-ci-wait.shfast-exits no-CI reposextract_state_from_status_jsonnow emits a distinctno-statuswhen there is genuinely no pipeline/status of any kind (empty state AND empty statuses) — distinct fromunknown(ambiguous, keeps polling). The poll loop counts consecutiveno-statusresults and, after 3 in a row, fast-exits0with[INFO] no CI configured for this repo/commit(distinct from a real failure). Modeled ongit/ci-queue-wait.sh's existingno-status→ proceed idiom. Repos that DO have pipelines are unchanged — any pipeline signal resets the streak, andpendingstill waits to timeout.Not swept
F-04 was deliberately NOT addressed in this PR.
Testing
bash -non all 6 touched files — clean._mosaic_tls_opt:ci.uscllc.com,git.mosaicstack.dev,m2m-api.uscllc.com→ empty;172.16.0.253:10443(portainer),172.16.1.108:8007,172.20.1.20:8007,192.168.1.5,10.0.0.1→-k;MOSAIC_INSECURE_TLS=1on a public host →-k.-k):pipeline-status.sh -r usc/uconnect -n 3943 -a usc -f jsonthrough the patched code returned full pipeline JSON over a validated TLS connection.-k.load_credentials woodpeckerexports successfully (no token values printed).no-status, real states correctly; counter unit-tested across 4 cases (pure no-CI fast-exits after 3; pending mid-stream resets streak; pipeline-bearing repo never fast-exits; real failure still exits 1).Independent review note
Codex review raised two findings, both adjudicated against the documented environment / decided design:
no-statuscould falsely pass delayed-CI PRs — kept per the lead's decided design; mirrors the establishedci-queue-wait.shidiom. The consecutive-3 requirement + streak-reset on any pipeline signal mitigates transient/delayed publication. Flagged here for visibility.-k— false positive against the cert evidence: both CI hosts are public and TLS-valid (spot-verified). The generic helpers retainMOSAIC_INSECURE_TLSfor any future edge case.Fixes #550
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.