Skip to content

Commit

Permalink
Protect against missing permissions field.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Oct 18, 2024
1 parent 03e02fe commit 5ca00bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ func setPermissionsHandler(reqpath string, globals *globalConfiguration) error {
if err != nil {
return newHttpError(http.StatusBadRequest, fmt.Errorf("invalid 'project' property in %q; %w", reqpath, err))
}

if incoming.Permissions == nil {
return newHttpError(http.StatusBadRequest, fmt.Errorf("expected a 'permissions' object in %q", reqpath))
}
}

source_user, err := identifyUser(reqpath)
Expand Down
2 changes: 1 addition & 1 deletion permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func TestSetPermissionsHandlerHandler(t *testing.T) {

reqpath, err := dumpRequest(
"set_permissions",
fmt.Sprintf(`{ "project": "%s" }`, project),
fmt.Sprintf(`{ "project": "%s", "permissions": {} }`, project),
)
if err != nil {
t.Fatalf("failed to dump a request type; %v", err)
Expand Down

0 comments on commit 5ca00bc

Please sign in to comment.