Files
seaweedFS/weed
Chris Lu d00a2a8707 Fix S3 bucket policy ARN validation to accept AWS ARNs and simplified formats (#7409)
* Fix S3 bucket policy ARN validation to accept AWS ARNs and simplified formats

Fixes #7252

The bucket policy validation was rejecting valid AWS-style ARNs and
simplified resource formats, causing validation failures with the
error 'resource X does not match bucket X' even when they were
identical strings.

Changes:
- Updated validateResourceForBucket() to accept three formats:
  1. AWS-style ARNs: arn:aws:s3:::bucket-name[/*|/path]
  2. SeaweedFS ARNs: arn:seaweed:s3:::bucket-name[/*|/path]
  3. Simplified formats: bucket-name[/*|/path]

- Added comprehensive test coverage for all three formats
- Added specific test cases from issue #7252 to prevent regression

This ensures compatibility with standard AWS S3 bucket policies
while maintaining support for SeaweedFS-specific ARN format.

* Refactor validateResourceForBucket to reduce code duplication

Simplified the validation logic by stripping ARN prefixes first,
then performing validation on the remaining resource path.
This reduces code duplication and improves maintainability while
maintaining identical functionality.

Addresses review feedback from Gemini Code Assist.

* Use strings.CutPrefix for cleaner ARN prefix stripping

Replace strings.HasPrefix checks with strings.CutPrefix for more
idiomatic Go code. This function is available in Go 1.20+ and
provides cleaner conditional logic with the combined check and
extraction.

Addresses review feedback from Gemini Code Assist.
2025-10-30 11:00:31 -07:00
..
2025-10-27 23:04:55 -07:00
2025-10-27 17:33:10 -07:00
2025-10-13 18:05:17 -07:00
2025-08-31 23:31:28 -07:00
2025-10-27 23:04:55 -07:00
2025-10-27 23:04:55 -07:00
2024-06-25 09:18:11 -07:00
2025-08-30 11:15:48 -07:00
2024-02-14 08:26:38 -08:00
2025-10-28 17:57:51 -07:00
2025-10-29 10:40:03 -07:00
2025-10-13 18:05:17 -07:00
2025-10-27 23:04:55 -07:00
2025-07-19 21:43:34 -07:00
2025-03-17 23:13:27 -07:00