Repository navigation
fix(control-plane): a near-miss SH_IDENTITY_PROVIDER name refuses to boot - #827
Conversation
…boot SH_IDENTITY_PROVIDER refused a wrong value at boot, but a misspelled name (SH_IDENTITY_PROVDER=oidc) left the switch unset, so the control plane quietly served the default github provider. configFromEnv now refuses a near-miss name first, naming the switch, with MOCA_TENANCY's rules: segments, case ignored, a leading SH/MOCA/KAGENTI word, then within one edit of IDENTITY_PROVIDER or starting with it; Kubernetes service-link variables exempt. tenancy.ts exports its edit-distance and service-link helpers for it, unchanged. Closes rossoctl#723 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Nice fix for #723 — closing the name side of the switch after the value side was already guarded, and reusing tenancy.ts's edit-distance and service-link helpers (exported unchanged) so the two guards share one policy, is exactly the right shape.
The guard runs first in configFromEnv, before both places that read the switch, so the misspelled-name path can't slip through to a quiet github default. The near-miss rule (leading SH/MOCA/KAGENTI word, within one edit of IDENTITYPROVIDER or a prefix of it, service links exempt) is well tested in both the new identity-switch.test.ts and main.test.ts, and the doc row in configuration.md is updated to match. No findings.
One note, not a finding: the proto CI check failed on this branch. The diff touches no proto files, so it's likely unrelated or flaky, but it's worth a glance before merge since I couldn't fetch the job logs to confirm.
Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript, Docs, Tests
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: proto failing (likely unrelated — no proto files touched); all other checks passing
All checks pass. Ready for human review.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
clawgenti
left a comment
There was a problem hiding this comment.
State marker for the review queue (full review posted separately on this SHA):
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Approving. The guard runs before both readers of the switch and reuses tenancy.ts's edit-distance and service-link rules, so the two near-miss guards can't drift apart. The tests cover the refused names, the accepted names and service links, and include a configFromEnv regression. One nit inline.
The red proto check fails in "Build and test remote-worker", which this PR doesn't touch (control-plane TS + docs only), and it is green on other PRs at the same main. Please re-run it.
Author: webchang (MEMBER, maintainer)
Areas reviewed: TypeScript (control-plane), Tests, Docs
Agent/IDE config (.claude/.vscode): none
Commits: 1, all signed off: yes
CI status: proto failing (unrelated remote-worker step, re-run); deploy-scripts-bash32 pending; all others passing
| } | ||
| } | ||
| } | ||
| return led && (rest.startsWith(CORE) || editDistanceAtMostOne(rest, CORE)); |
There was a problem hiding this comment.
nit — rest.startsWith(CORE) (as with MOCA_TENANCY) reserves the whole SH_IDENTITY_PROVIDER* namespace: any future knob such as SH_IDENTITY_PROVIDER_TIMEOUT_S or SH_IDENTITY_PROVIDERS_ALLOWED would refuse to boot until this guard learns about it. That's fine as a deliberate choice, but consider a one-line comment here (or an allow-list constant), so whoever adds such a knob knows to exempt it rather than being surprised by a boot failure.
There was a problem hiding this comment.
Done in ed5571b: a comment at that line says the guard reserves the SH_IDENTITY_PROVIDER* namespace, as tenancy.ts does MOCA_TENAN*, and that a new knob under that prefix must be exempted by name in the change that adds it. The branch also merges main (2046103), resolving the configuration.md conflict: main's re-padded table, plus this PR's one row.
Assisted-By: Claude Code
…ar-miss Signed-off-by: Rong Chang <[email protected]> # Conflicts: # docs/reference/configuration.md
…* namespace A new knob under that prefix must be exempted by name in the change that adds it (review nit). Part of rossoctl#723 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
…ss token The server's repository-wide guard test flags every MOCA_TENANCY near-miss name in the tree, and the comment's 'MOCA_TENAN*' was one. Part of rossoctl#723 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
Takes upstream main at 1a7f41e (19 merges since 032c8f6): the sandbox idle lifetime across docs, control plane, clients and deploy (rossoctl#820, rossoctl#837, rossoctl#842, rossoctl#843), grant redemption (rossoctl#822), the lease-check log line (rossoctl#824), egress fixes (rossoctl#829, rossoctl#834), the mock wait (rossoctl#828), the deadline timer (rossoctl#835), the create rollback (rossoctl#832), multi refusals and the rossoctl#363 leftovers (rossoctl#833, rossoctl#838), the identity near-miss check (rossoctl#827), mocactl login errors (rossoctl#836), the ghostunnel probes (rossoctl#830), refusal-burst deferral (rossoctl#831), a sandbox-worker change (rossoctl#841) and the v0.11 doc truth (rossoctl#821). Conflicts (one): - deploy/sbx/README.md, the "Optional inputs" table. Upstream (rossoctl#843) rewrote the SBX_LIFETIME_DAYS row (the default idle lifetime, at most SBX_MAX_LIFETIME_DAYS) and added the SBX_MAX_LIFETIME_DAYS and SBX_LOWER_WORKSPACE_IDLE rows, which widened the table; the fork had added an SBX_GATE_RECORD_SCHEMA row at its end. Resolved by taking upstream's table whole and appending the fork's SBX_GATE_RECORD_SCHEMA row after SBX_PROFILE, then re-padding the table with prettier. The fork's env-file example line for SBX_GATE_RECORD_SCHEMA merged cleanly. Merged without markers, checked: setup.sh keeps the fork's SBX_GATE_RECORD_SCHEMA validation and its sbx-settings write (so it stays in the settings hash) beside upstream's SH_SANDBOX_MAX_LIFETIME_SECONDS; both ocp-sbx and ocp-combined patch-control-plane.yaml keep the optional SH_GATE_RECORD_SCHEMA from sbx-settings beside the new optional SH_SANDBOX_MAX_LIFETIME_SECONDS; setup.test.sh keeps the fork's cases beside upstream's. The fork's RUNBOOK, README and template-onboarding docs say nothing about sandbox lifetime, refusal bursts, login errors or the create rollback, so none needed a correction; GUIDE.md is unchanged and GUIDE.pdf is not regenerated. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Closes #723
What changed and why
SH_IDENTITY_PROVIDERrefused a wrong value at boot, but a misspelled name was ignored.SH_IDENTITY_PROVDER=oidcleft the switch unset, so the control plane quietly served the defaultgithubprovider.configFromEnvnow refuses a near-miss name first, before either place that reads the switch (its own github-client-id check andidentityProviderFromEnv). The error names both the variable and the switch:unrecognised variable 'SH_IDENTITY_PROVDER': the identity switch is SH_IDENTITY_PROVIDER (unset 'SH_IDENTITY_PROVDER' to boot), in the same form asreadTenancy's.isTenancyNearMiss:SH,MOCAorKAGENTIwords are dropped, as segments or glued on;IDENTITYPROVIDER, or starts with it;SH_IDENTITY_PROVDER,SH_IDENTITYPROVIDER,sh_identity_provider,SHIDENTITY_PROVIDER,MOCA_IDENTITY_PROVIDER,SH_IDENTITY_PROVIDERSandSH_IDENTITY_PROVIDER_OLD. A bareIDENTITY_PROVIDER(no leading word, as withTENANT),AWS_WEB_IDENTITY_TOKEN_FILEandSKIP_GIT_IDENTITY_CHECKare not.tenancy.tsexports itseditDistanceAtMostOneandisServiceLinkfor this, unchanged, so the two guards share one edit-distance and one service-link policy.docs/reference/configuration.md: the switch's row says a near-miss name throws, asMOCA_TENANCY's does.Tests
packages/control-plane/test/identity-switch.test.ts: the refused names, the accepted ones and the service-link names, plus the thrown message.main.test.ts:configFromEnvwithSH_IDENTITY_PROVDER: 'oidc'throws, naming the switch. With themain.tschange reverted, this test fails (the github config is returned).SH_IDENTITY_PROVDERis flagged, so no shipped manifest or env file trips it.@moca/control-plane: typecheck clean, 1830 passed (3 skipped).@moca/server(which re-exports the tenancy guard): typecheck clean, 576 passed. pre-commit passes.Out of scope
SH_OIDC_*names the issue mentions. The required ones (SH_OIDC_ISSUER,SH_OIDC_CLIENT_ID,SH_OIDC_CLIENT_SECRET,SH_OIDC_REDIRECT_URI) already fail boot when misspelled, as missing. Only the optionalSH_OIDC_SCOPEcould be silently ignored, and it is left as is.Every commit is signed off (DCO).
Assisted-By: Claude Code