Merge pull request #85800 from beautytiger/dev-191202-fixtrim

fix: replace TrimLeft with TrimPrefix and TrimRight with TrimSuffix
This commit is contained in:
Kubernetes Prow Robot 2019-12-03 15:47:22 -08:00 committed by GitHub
commit 896b77ed53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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
}
}