Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of api: ensure ACL role upsert decode error returns a 400 status code. into release/1.4.x #15321

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .semgrep/http_endpoint.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion command/agent/acl_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down