Merge pull request #1256 from harshavardhana/resources

bucketpolicy: checkBucketPolicy should keep resources in map.
master
Anand Babu (AB) Periasamy 9 years ago
commit 4aa098ede9
  1. 9
      bucket-policy-parser.go

@ -193,7 +193,7 @@ var invalidPrefixActions = map[string]struct{}{
func checkBucketPolicy(bucket string, bucketPolicy BucketPolicy) APIErrorCode {
// Validate statements for special actions and collect resources
// for others to validate nesting.
var resources []string
var resourceMap = make(map[string]struct{})
for _, statement := range bucketPolicy.Statements {
for _, action := range statement.Actions {
for _, resource := range statement.Resources {
@ -211,12 +211,17 @@ func checkBucketPolicy(bucket string, bucketPolicy BucketPolicy) APIErrorCode {
return ErrMalformedPolicy
}
// All valid resources collect them separately to verify nesting.
resources = append(resources, resourcePrefix)
resourceMap[resourcePrefix] = struct{}{}
}
}
}
}
var resources []string
for resource := range resourceMap {
resources = append(resources, resource)
}
// Sort strings as shorter first.
sort.Strings(resources)

Loading…
Cancel
Save