api: ensure ACL role upsert decode error returns a 400 status code. (#15253)
This commit is contained in:
parent
3225cf77b6
commit
a7350853ae
|
@ -0,0 +1,22 @@
|
|||
rules:
|
||||
- id: "http-endpoint-request-decode-error-code"
|
||||
patterns:
|
||||
- pattern: |
|
||||
if err := decodeBody(...); err != nil {
|
||||
return nil, CodedError(...)
|
||||
}
|
||||
- pattern-not-inside: |
|
||||
if err := decodeBody(...); err != nil {
|
||||
return nil, CodedError(400, ...)
|
||||
}
|
||||
- pattern-not-inside: |
|
||||
if err := decodeBody(...); err != nil {
|
||||
return nil, CodedError(http.StatusBadRequest, ...)
|
||||
}
|
||||
message: "HTTP endpoint request decode should return http.StatusBadRequest"
|
||||
languages:
|
||||
- "go"
|
||||
severity: "ERROR"
|
||||
paths:
|
||||
include:
|
||||
- "command/agent/*_endpoint.go"
|
|
@ -477,7 +477,7 @@ func (s *HTTPServer) aclRoleUpsertRequest(
|
|||
// Decode the ACL role.
|
||||
var aclRole structs.ACLRole
|
||||
if err := decodeBody(req, &aclRole); err != nil {
|
||||
return nil, CodedError(http.StatusInternalServerError, err.Error())
|
||||
return nil, CodedError(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
// Ensure the request path ID matches the ACL role ID that was decoded.
|
||||
|
|
Loading…
Reference in New Issue