mirror of
https://github.com/minio/minio.git
synced 2025-05-03 07:50:32 -04:00
api: Add new bucket policy nesting error (#1883)
* Added ErrPolicyNesting which is returned when nesting of policies has occured * Replaces ErrMalformedPolicy in the case of nesting * Changed test case in bucket-policy-parser_test.go (ErrMalformedPolicy -> ErrPolicyNesting)
This commit is contained in:
parent
f2765d98a8
commit
6f3bd76754
@ -109,6 +109,7 @@ const (
|
|||||||
ErrWriteQuorum
|
ErrWriteQuorum
|
||||||
ErrStorageFull
|
ErrStorageFull
|
||||||
ErrObjectExistsAsDirectory
|
ErrObjectExistsAsDirectory
|
||||||
|
ErrPolicyNesting
|
||||||
)
|
)
|
||||||
|
|
||||||
// error code to APIError structure, these fields carry respective
|
// error code to APIError structure, these fields carry respective
|
||||||
@ -415,6 +416,11 @@ var errorCodeResponse = map[APIErrorCode]APIError{
|
|||||||
Description: "Multiple disks failures, unable to write data.",
|
Description: "Multiple disks failures, unable to write data.",
|
||||||
HTTPStatusCode: http.StatusServiceUnavailable,
|
HTTPStatusCode: http.StatusServiceUnavailable,
|
||||||
},
|
},
|
||||||
|
ErrPolicyNesting: {
|
||||||
|
Code: "XMinioPolicyNesting",
|
||||||
|
Description: "Policy nesting conflict has occurred.",
|
||||||
|
HTTPStatusCode: http.StatusConflict,
|
||||||
|
},
|
||||||
// Add your error structure here.
|
// Add your error structure here.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ func checkBucketPolicyResources(bucket string, bucketPolicy BucketPolicy) APIErr
|
|||||||
for _, otherResource := range resources {
|
for _, otherResource := range resources {
|
||||||
// Common prefix reject such rules.
|
// Common prefix reject such rules.
|
||||||
if strings.HasPrefix(otherResource, resource) {
|
if strings.HasPrefix(otherResource, resource) {
|
||||||
return ErrMalformedPolicy
|
return ErrPolicyNesting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,8 +514,8 @@ func TestCheckBucketPolicyResources(t *testing.T) {
|
|||||||
{bucketAccessPolicies[4], ErrMalformedPolicy, false},
|
{bucketAccessPolicies[4], ErrMalformedPolicy, false},
|
||||||
// Test case - 6.
|
// Test case - 6.
|
||||||
// contructing policy statement with recursive resources.
|
// contructing policy statement with recursive resources.
|
||||||
// should result in ErrMalformedPolicy.
|
// should result in ErrPolicyNesting.
|
||||||
{bucketAccessPolicies[5], ErrMalformedPolicy, false},
|
{bucketAccessPolicies[5], ErrPolicyNesting, false},
|
||||||
// Test case - 7.
|
// Test case - 7.
|
||||||
// constructing policy statement with lexically close
|
// constructing policy statement with lexically close
|
||||||
// characters.
|
// characters.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user