S3: surface bucket listing failures and fix multi-role object count#5035
Open
shahzadhaider1 wants to merge 2 commits into
Open
S3: surface bucket listing failures and fix multi-role object count#5035shahzadhaider1 wants to merge 2 commits into
shahzadhaider1 wants to merge 2 commits into
Conversation
Listing failures were logged at V(3) whenever a role was assumed, hiding access and role-assumption errors for buckets the user explicitly asked to scan. Suppression now applies only in list-all-buckets mode, and a bucket_list_errors_total metric records every listing failure.
scanBuckets runs once per configured role and reset its object counter each pass, so the final progress message only reflected the last role's count. Multi-role scans could report 0 objects scanned even when earlier roles scanned objects.
6827420 to
f9b729c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
S3 scans reported
0 objects scannedfor buckets that contain objects, with no errors logged. Investigation showedListObjectsV2was failing withAccessDeniedon every configured role, but because a role was assumed, the failure was logged atV(3)and never surfaced. The scans completed "successfully" while scanning nothing.The suppression exists for list-all-buckets mode (role without a bucket list), where the scanner probes every bucket in the account and denials are expected. Applying it when buckets are explicitly configured hides real failures on targets the user asked to scan. Note that role-assumption (STS) failures also surface on this code path, since role credentials are resolved lazily.
Changes
Commit 1: surface listing failures for explicitly configured buckets
V(3)remains only for list-all-buckets mode.listErrorsAreExpected, covered by a unit test.bucket_list_errors_total{bucket, role_arn}records every listing failure; previously a failed bucket left no trace in metrics.Commit 2: accumulate object count across role passes
scanBucketsruns once per configured role and reset its object counter each pass, so the final progress message reported only the last role's count; a multi-role scan could report0 objects scannedeven when earlier roles scanned objects. The counter is now owned byChunksand shared across passes.Impact
Misconfigured access (IAM, bucket policy, or role trust policy) on an explicitly configured bucket is now visible at default log verbosity and in metrics, and the scan completion message reports the true total across all roles.
Checklist:
make test-community)?make lintthis requires golangci-lint)?Note
Medium Risk
Changes S3 scan observability and progress reporting for IAM/list failures and multi-role scans; behavior is more visible but scan logic paths are otherwise unchanged.
Overview
S3 scanning now surfaces bucket listing failures when targets are explicitly configured, and reports the correct total object count across multiple assumed roles.
Listing errors used to be downgraded to verbose logs whenever any role was assumed, which hid
AccessDeniedand STS failures on buckets the user named.listErrorsAreExpectednow only treats denials as expected in list-all-buckets mode (role set, no explicit bucket list); otherwise failures log at error level. Every list failure incrementsbucket_list_errors_totalwithbucketandrole_arnlabels.Chunksowns a shared object counter passed intoscanBucketson each role pass, so the completion message reflects the cumulative scan instead of resetting to the last role’s pass.Reviewed by Cursor Bugbot for commit f9b729c. Bugbot is set up for automated code reviews on this repo. Configure here.