Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
c495cd99
Unverified
Commit
c495cd99
authored
2 years ago
by
James Rasell
Committed by
GitHub
2 years ago
Browse files
Options
Download
Email Patches
Plain Diff
api: ensure all request body decode error return a 400 status code. (#15252)
parent
329807bd
Branches unavailable
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.changelog/15252.txt
+3
-0
.changelog/15252.txt
command/agent/acl_endpoint.go
+3
-3
command/agent/acl_endpoint.go
command/agent/agent_endpoint.go
+3
-3
command/agent/agent_endpoint.go
command/agent/namespace_endpoint.go
+1
-1
command/agent/namespace_endpoint.go
with
10 additions
and
7 deletions
+10
-7
.changelog/15252.txt
0 → 100644
+
3
-
0
View file @
c495cd99
```release-note:bug
api: Ensure all request body decode errors return a 400 status code
```
This diff is collapsed.
Click to expand it.
command/agent/acl_endpoint.go
+
3
-
3
View file @
c495cd99
...
...
@@ -73,7 +73,7 @@ func (s *HTTPServer) aclPolicyUpdate(resp http.ResponseWriter, req *http.Request
// Parse the policy
var
policy
structs
.
ACLPolicy
if
err
:=
decodeBody
(
req
,
&
policy
);
err
!=
nil
{
return
nil
,
CodedError
(
500
,
err
.
Error
())
return
nil
,
CodedError
(
http
.
StatusBadRequest
,
err
.
Error
())
}
// Ensure the policy name matches
...
...
@@ -244,7 +244,7 @@ func (s *HTTPServer) aclTokenUpdate(resp http.ResponseWriter, req *http.Request,
// Parse the token
var
token
structs
.
ACLToken
if
err
:=
decodeBody
(
req
,
&
token
);
err
!=
nil
{
return
nil
,
CodedError
(
500
,
err
.
Error
())
return
nil
,
CodedError
(
http
.
StatusBadRequest
,
err
.
Error
())
}
// Ensure the token accessor matches
...
...
@@ -311,7 +311,7 @@ func (s *HTTPServer) ExchangeOneTimeToken(resp http.ResponseWriter, req *http.Re
var
args
structs
.
OneTimeTokenExchangeRequest
if
err
:=
decodeBody
(
req
,
&
args
);
err
!=
nil
{
return
nil
,
CodedError
(
500
,
err
.
Error
())
return
nil
,
CodedError
(
http
.
StatusBadRequest
,
err
.
Error
())
}
s
.
parseWriteRequest
(
req
,
&
args
.
WriteRequest
)
...
...
This diff is collapsed.
Click to expand it.
command/agent/agent_endpoint.go
+
3
-
3
View file @
c495cd99
...
...
@@ -509,17 +509,17 @@ func (s *HTTPServer) KeyringOperationRequest(resp http.ResponseWriter, req *http
sresp
,
err
=
kmgr
.
ListKeys
()
case
"install"
:
if
err
:=
decodeBody
(
req
,
&
args
);
err
!=
nil
{
return
nil
,
CodedError
(
500
,
err
.
Error
())
return
nil
,
CodedError
(
http
.
StatusBadRequest
,
err
.
Error
())
}
sresp
,
err
=
kmgr
.
InstallKey
(
args
.
Key
)
case
"use"
:
if
err
:=
decodeBody
(
req
,
&
args
);
err
!=
nil
{
return
nil
,
CodedError
(
500
,
err
.
Error
())
return
nil
,
CodedError
(
http
.
StatusBadRequest
,
err
.
Error
())
}
sresp
,
err
=
kmgr
.
UseKey
(
args
.
Key
)
case
"remove"
:
if
err
:=
decodeBody
(
req
,
&
args
);
err
!=
nil
{
return
nil
,
CodedError
(
500
,
err
.
Error
())
return
nil
,
CodedError
(
http
.
StatusBadRequest
,
err
.
Error
())
}
sresp
,
err
=
kmgr
.
RemoveKey
(
args
.
Key
)
default
:
...
...
This diff is collapsed.
Click to expand it.
command/agent/namespace_endpoint.go
+
1
-
1
View file @
c495cd99
...
...
@@ -80,7 +80,7 @@ func (s *HTTPServer) namespaceUpdate(resp http.ResponseWriter, req *http.Request
// Parse the namespace
var
namespace
structs
.
Namespace
if
err
:=
decodeBody
(
req
,
&
namespace
);
err
!=
nil
{
return
nil
,
CodedError
(
500
,
err
.
Error
())
return
nil
,
CodedError
(
http
.
StatusBadRequest
,
err
.
Error
())
}
// Ensure the namespace name matches
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help