Azure Bucket: anonymous access to public containers is unreachable since #1875
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Bắt đầu tại internal/bucket/azure/blob.go, ở chainCredentialWithSecret và đường dẫn chọn client, sau đó kiểm tra auth/azure.NewTokenCredential và các trường hợp anonymous trong blob_test.go. Chạy staticcheck ./internal/... và make test để xác nhận control flow và phạm vi bao phủ hiện có. Hoàn thành có nghĩa là một Bucket không có secretRef có thể truy cập anonymous trong production, với các test bao phủ đường dẫn đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Since #1875 (04ab27b42a4ab3bc989accdd8e958e189c60370c, merged 2025-09-02), a Bucket with provider: azure and no secretRef can no longer get an unauthenticated client. Both paths that would produce one are unreachable on main (99d894dd).
Why
chainCredentialWithSecret appends a credential that is never nil:
https://github.com/fluxcd/source-controller/blob/main/internal/bucket/azure/blob.go#L518
if token := azureauth.NewTokenCredential(ctx, opts...); token != nil {
creds = append(creds, token)
}
auth/azure.NewTokenCredential returns &tokenCredential{ctx, opts} — a non-nil pointer in a non-nil interface, unconditionally. So the guard is always true, creds is never empty, len(creds) > 0 always holds, and the documented return nil, nil ("If no valid token is created, it returns nil") is dead code.
That propagates to the caller, where token != nil is then always true:
token, err = chainCredentialWithSecret(ctx, o.secret, o.authOpts...)
...
if token != nil {
c.Client, err = azblob.NewClient(obj.Spec.Endpoint, token, clientOpts)
return
}
// Fallback to simple client.
c.Client, err = azblob.NewClientWithNoCredential(obj.Spec.Endpoint, clientOpts) // unreachable
The other unauthenticated path, the o.withoutCredentials early return, is gated on an unexported withoutCredentials() option that is only ever called from blob_test.go (4 call sites) and never from production code. So the anonymous behaviour that tests exercise is reached through a door the reconciler does not have, which is why the tests still pass.
Before #1875 this worked: creds only received NewEnvironmentCredential when that returned non-nil, so an empty chain — and therefore the nil, nil return and the no-credential fallback — was reachable.
Impact
A public/anonymously-readable Azure container configured without a secretRef gets an azblob client carrying a token credential instead of a no-credential client. At request time that calls auth.GetAccessToken, which fails when no Azure identity is configured, so the fetch fails rather than falling back to anonymous access.
I have verified the control flow and the regression point by reading the source; I have not reproduced it against a live public container, so please treat the runtime symptom as inferred from the code path rather than observed.
Found by
staticcheck ./internal/... flags it as SA4023, "this comparison is always true". The repo has no .golangci.yaml and CI runs make test only, so the check does not currently run anywhere.
Possible fixes
- Drop the always-true
token != nilguard and decide the chain on whether any credential source is actually configured, sochainCredentialWithSecretcan returnnil, nilagain as documented. - Or make the intent explicit at the caller and have the reconciler pass the existing
withoutCredentials()option when nosecretRefis set, which would also give the anonymous path production coverage rather than test-only coverage.
Happy to open a PR for whichever direction you prefer.
- Ngôn ngữ chính
- Go
- Star
- 283
- Fork
- 258
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fluxcd/source-controller
-
Improve documentation on debugging the controller locallyCó thể làm lại được @Bryandero98 đã nhận 25 ngày trước và không có pull request nào đang mở. Đang mởarea/docs good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
fluxcd/source-controller#666 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/oci enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
fluxcd/source-controller#2180 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`OCIRepository`/cosign verification: support TSA-only trusted roots (no transparency log) for private Sigstore instances like GitHub Artifact AttestationsCó thể đã có người làm @stealthybox đã nhận 139 ngày trước. Đang mởarea/oci area/security enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
fluxcd/source-controller#2167 · 4 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
fluxcd/source-controller#2150 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
GitRepository `.spec.ref.commit` + `.spec.ref.branch` does not shallow clone, contrary to the docsĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
fluxcd/source-controller#2146 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của fluxcd/source-controller
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
Maintainer thường phản hồi trong vòng 1 ngày
-
product/backlog
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
TencentBlueKing/bk-nodemgr#3645 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
modelcontextprotocol/go-sdk#1387 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docs(prompt): filer socket fragment hardcodes an issue-intent cap of 8 that Chore runs overrideĐang mởagent-butler-finding chore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jordansmall/spindrift#5128 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 2 ngày