fix: replace TrimLeft with TrimPrefix and TrimRight with TrimSuffix

Kubernetes-commit: 51b7ef2c87e3321668fedecbbc02c1a16357033d
This commit is contained in:
Guangming Wang 2019-12-02 21:27:15 +08:00 committed by Kubernetes Publisher
parent 137a9d3b88
commit ab9ec5ee43
1 changed files with 2 additions and 2 deletions

View File

@ -185,11 +185,11 @@ func ruleMatchesResource(r *audit.PolicyRule, attrs authorizer.Attributes) bool
return true
}
// match "*/subresource"
if len(subresource) > 0 && strings.HasPrefix(res, "*/") && subresource == strings.TrimLeft(res, "*/") {
if len(subresource) > 0 && strings.HasPrefix(res, "*/") && subresource == strings.TrimPrefix(res, "*/") {
return true
}
// match "resource/*"
if strings.HasSuffix(res, "/*") && resource == strings.TrimRight(res, "/*") {
if strings.HasSuffix(res, "/*") && resource == strings.TrimSuffix(res, "/*") {
return true
}
}