MCPcopy
hub / github.com/minio/minio-go / getInUsePolicy

Function getInUsePolicy

pkg/policy/bucket-policy.go:246–266  ·  view source on GitHub ↗

Returns whether given bucket statements are used by other than given prefix statements.

(statements []Statement, bucketName, prefix string)

Source from the content-addressed store, hash-verified

244
245// Returns whether given bucket statements are used by other than given prefix statements.
246func getInUsePolicy(statements []Statement, bucketName, prefix string) (readOnlyInUse, writeOnlyInUse bool) {
247 resourcePrefix := awsResourcePrefix + bucketName + "/"
248 objectResource := awsResourcePrefix + bucketName + "/" + prefix + "*"
249
250 for _, s := range statements {
251 if !s.Resources.Contains(objectResource) && !s.Resources.FuncMatch(startsWithFunc, resourcePrefix).IsEmpty() {
252 if s.Actions.Intersection(readOnlyObjectActions).Equals(readOnlyObjectActions) {
253 readOnlyInUse = true
254 }
255
256 if s.Actions.Intersection(writeOnlyObjectActions).Equals(writeOnlyObjectActions) {
257 writeOnlyInUse = true
258 }
259 }
260 if readOnlyInUse && writeOnlyInUse {
261 break
262 }
263 }
264
265 return readOnlyInUse, writeOnlyInUse
266}
267
268// Removes object actions in given statement.
269func removeObjectActions(statement Statement, objectResource string) Statement {

Callers 2

removeStatementsFunction · 0.85
TestGetInUsePolicyFunction · 0.85

Calls 5

ContainsMethod · 0.45
IsEmptyMethod · 0.45
FuncMatchMethod · 0.45
EqualsMethod · 0.45
IntersectionMethod · 0.45

Tested by 1

TestGetInUsePolicyFunction · 0.68