Allow dot in project policy. Closes #2724 (#2755)

This commit is contained in:
Alex Collins 2019-12-01 19:14:32 -08:00 committed by GitHub
parent bfe05e4755
commit cbe94440df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

View file

@ -58,6 +58,7 @@ dep ensure
make dev-tools-image
make install-lint-tools
go get github.com/mattn/goreman
go get github.com/jstemmer/go-junit-report
```
Common make targets:

View file

@ -1374,7 +1374,7 @@ func validatePolicy(proj string, role string, policy string) error {
}
// object
object := strings.Trim(policyComponents[4], " ")
objectRegexp, err := regexp.Compile(fmt.Sprintf(`^%s/[*\w-]+$`, proj))
objectRegexp, err := regexp.Compile(fmt.Sprintf(`^%s/[*\w-.]+$`, proj))
if err != nil || !objectRegexp.MatchString(object) {
return status.Errorf(codes.InvalidArgument, "invalid policy rule '%s': object must be of form '%s/*' or '%s/<APPNAME>', not '%s'", policy, proj, proj, object)
}

View file

@ -305,6 +305,7 @@ func TestAppProject_ValidPolicyRules(t *testing.T) {
"p, proj:my-proj:my-role, applications, get, my-proj/*-foo, allow",
"p, proj:my-proj:my-role, applications, get, my-proj/foo-*, allow",
"p, proj:my-proj:my-role, applications, get, my-proj/*-*, allow",
"p, proj:my-proj:my-role, applications, get, my-proj/*.*, allow",
"p, proj:my-proj:my-role, applications, *, my-proj/foo, allow",
"p, proj:my-proj:my-role, applications, create, my-proj/foo, allow",
"p, proj:my-proj:my-role, applications, update, my-proj/foo, allow",