fix: merge existing orgs in ProvisionWIF to prevent WIF condition clobber - #1113
Conversation
Site previewPreview: https://5abc07a1-site.fullsend-ai.workers.dev Commit: |
ReviewFindingsLow
Previous runReviewFindingsLow
Previous run (2)ReviewFindingsNo findings. Previous run (3)ReviewFindingsNo findings. Previous run (4)ReviewFindingsNo findings. Previous run (5)ReviewFindingsNo findings. The fix correctly addresses the WIF condition clobber bug by extracting
Previous run (6)ReviewFindingsNo findings. Previous run (7)ReviewFindingsNo findings. Previous run (8)ReviewFindingsNo findings. Previous run (9)ReviewFindingsNo findings. The fix correctly addresses the WIF condition clobber bug by extracting the merge logic into a shared
Previous run (10)ReviewFindingsNo findings. The fix correctly addresses the WIF condition clobber bug by extracting the existing merge logic from
Previous run (11)ReviewFindingsLow
Previous run (12)ReviewFindingsLow
|
Review follow-upsCreated follow-up issues for actionable non-blocking review findings:
Previous runReview follow-upsCreated follow-up issues for actionable non-blocking review findings:
Previous run (2)Review follow-upsCreated follow-up issues for actionable non-blocking review findings:
Previous run (3)Review follow-upsCreated follow-up issues for actionable non-blocking review findings:
|
githubRepoSlugPattern now rejects leading/trailing dots and hyphens and enforces a 100-char max, matching GitHub's actual repo name rules. Repo-scoped ProvisionWIF lowercases p.cfg.Repo before using it in the CEL attribute condition and IAM principal, preventing silent auth failures when callers pass mixed-case repo names. Signed-off-by: Wayne Sun <gsun@redhat.com>
GitHub allows repo names starting with dots (e.g., .fullsend, .github) but rejects "." and ".." as standalone names. Relax the regex to permit leading dots while adding an explicit check for the two invalid cases. Signed-off-by: Wayne Sun <gsun@redhat.com>
Use a local `repo` variable instead of mutating p.cfg.Repo in-place, matching the pattern already used for providerID. Validate the owner component of repo-scoped installs with githubOrgPattern (rejects dots, underscores, >39 chars) instead of the looser githubRepoSlugPattern, since the owner is always a GitHub org/user name. Signed-off-by: Wayne Sun <gsun@redhat.com>
| for i, org := range p.cfg.GitHubOrgs { | ||
| if !githubOrgPattern.MatchString(org) { | ||
| if !githubOrgPattern.MatchString(org) || strings.Contains(org, "--") { | ||
| return "", fmt.Errorf("invalid GitHub org name: %q", org) |
There was a problem hiding this comment.
[low] correctness
strings.Contains(org, "--") check rejects valid GitHub org names with consecutive hyphens. GitHub allows names like my--org. The existing githubOrgPattern regex already constrains the character set.
Suggested fix: Remove the -- check, or document why consecutive hyphens are intentionally rejected if there is a GCP-side constraint.
Error messages in repo-scoped ProvisionWIF now show the user's original input casing instead of the lowercased value used for validation. Also reject repo names ending in .git since GitHub strips this suffix from OIDC tokens, making the WIF condition silently unmatchable. Adds test for double-hyphen owner rejection and .git suffix validation. Signed-off-by: Wayne Sun <gsun@redhat.com>
| seen := make(map[string]bool) | ||
| for i, org := range p.cfg.GitHubOrgs { | ||
| if !githubOrgPattern.MatchString(org) { | ||
| if !githubOrgPattern.MatchString(org) || strings.Contains(org, "--") { |
There was a problem hiding this comment.
[low] correctness
The strings.Contains(org, "--") check in ProvisionWIF() org validation rejects GitHub org/user names with consecutive hyphens (e.g., my--org), which GitHub allows. The existing githubOrgPattern regex already constrains the character set. This is consistent with the same check in Provision() (line 482) but could cause confusing rejections for valid org names.
Suggested fix: Remove the -- check from both Provision() and ProvisionWIF(), or document the GCP-side constraint that motivates it.
Summary
ProvisionWIF()overwrote the WIF provider'sattributeConditionwith only the installing org, removing all other orgs. This caused STS 400 → mint 403 for every org not in the latest install run.ProvisionWIF()(used by inference WIF and per-repo install paths) lacked the merge logic thatProvision()already had.Provision()intoProvisionWIF()via sharedensureWIFPoolAndProviderhelper.p.cfg.WIFProviderin the repo-scoped path.GetWIFProvidererror handling from silent continue to fail-fast in bothProvision()andProvisionWIF()paths to prevent condition clobber on transient errors.Incident:
fullsend-ai/fullsenddispatch failed on PR #1111 (run 26062774013) because an earlierfullsend installforkonflux-cioverwrote the WIF condition to only allowkonflux-ci, blocking all other orgs (STS returned 400, mint returned 403). The WIF provider has been manually corrected.Test plan
TestProvisionWIF_*tests passTestProvisionWIF_OrgScoped_MergesExistingOrgsverifies merge behaviorTestProvisionWIF_OrgScoped_GetProviderError_FailsToPreventClobberverifies fail-fast on transient errorsTestProvisioner_Provision_GetWIFProviderError_FailsFastverifies fail-fast in Provision() pathTestProvisionWIF_RepoScoped_RejectsInvalidRepoverifies allowlist validation (quotes, backslash, spaces)TestParseConditionOrgsverifies case normalization and format parsinggo test ./...passes