Azure Bucket: anonymous access to public containers is unreachable since #1875
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
調査の方向性
internal/bucket/azure/blob.go の chainCredentialWithSecret とクライアント選択パスから始め、続いて auth/azure.NewTokenCredential と blob_test.go の匿名ケースを調べます。staticcheck ./internal/... と make test を実行して、制御フローと既存のカバレッジを確認します。Bucket が secretRef なしで本番環境の匿名アクセスに到達でき、そのパスをテストがカバーしていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Go
- スター
- 283
- フォーク
- 252
- 平均マージ
- 1時間 6分
- マージ済み PR(30日)
- 12
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fluxcd/source-controller のほかの issue
-
area/docs good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
fluxcd/source-controller#666 · コメント 2 件 ·
-
area/git bug
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
fluxcd/source-controller#2165 · コメント 3 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
fluxcd/source-controller#2150 ·
-
GitRepository `.spec.ref.commit` + `.spec.ref.branch` does not shallow clone, contrary to the docs オープン
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
fluxcd/source-controller#2146 · コメント 2 件 ·
-
HelmRepository: use conditional HTTP requests (ETag / If-Modified-Since) when fetching index.yaml オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
fluxcd/source-controller#2113 · コメント 1 件 ·
fluxcd/source-controller の issue をすべて見る
似ている issue
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
microsoft/agent-framework-go#1179 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
[Bug]: OLLAMA_KEEP_ALIVE="5m" / "24h" crashes Ollama embedding and vision models with ValueError オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
infiniflow/ragflow#20223 · リアクション 1 件 ·
-
bug needs triage pkg/translator/faro
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
open-telemetry/opentelemetry-collector-contrib#51484 · コメント 1 件 ·