mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
api: POST /containers/{id}/wait: validate "condition" parameter
The endpoint was silently ignoring invalid values for the "condition" parameter. This patch now returns a 400 status if an unknown, non-empty "condition" is passed. With this patch: curl --unix-socket /var/run/docker.sock -XPOST 'http://localhost/v1.41/containers/foo/wait?condition=foobar' {"message":"invalid condition: \"foobar\""} Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
a832635e51
commit
737e8c6ab8
2 changed files with 12 additions and 6 deletions
|
@ -336,12 +336,16 @@ func (s *containerRouter) postContainersWait(ctx context.Context, w http.Respons
|
|||
if err := httputils.ParseForm(r); err != nil {
|
||||
return err
|
||||
}
|
||||
switch container.WaitCondition(r.Form.Get("condition")) {
|
||||
case container.WaitConditionNextExit:
|
||||
waitCondition = containerpkg.WaitConditionNextExit
|
||||
case container.WaitConditionRemoved:
|
||||
waitCondition = containerpkg.WaitConditionRemoved
|
||||
legacyRemovalWaitPre134 = versions.LessThan(version, "1.34")
|
||||
if v := r.Form.Get("condition"); v != "" {
|
||||
switch container.WaitCondition(v) {
|
||||
case container.WaitConditionNextExit:
|
||||
waitCondition = containerpkg.WaitConditionNextExit
|
||||
case container.WaitConditionRemoved:
|
||||
waitCondition = containerpkg.WaitConditionRemoved
|
||||
legacyRemovalWaitPre134 = versions.LessThan(version, "1.34")
|
||||
default:
|
||||
return errdefs.InvalidParameter(errors.Errorf("invalid condition: %q", v))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ keywords: "API, Docker, rcli, REST, documentation"
|
|||
was used and the architecture was ignored. If no `platform` option is set, the
|
||||
host's operating system and architecture as used as default. This change is not
|
||||
versioned, and affects all API versions if the daemon has this patch.
|
||||
* The `POST /containers/{id}/wait` endpoint now returns a `400` status code if an
|
||||
invalid `condition` is provided (on API 1.30 and up).
|
||||
|
||||
## v1.41 API changes
|
||||
|
||||
|
|
Loading…
Reference in a new issue