mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Merge pull request #97124 from gavinfish/json-parser
Cleanup: remove sanity check for CVE-2019-11253
This commit is contained in:
commit
98f64c9c10
@ -337,15 +337,6 @@ func (p *jsonPatcher) createNewObject() (runtime.Object, error) {
|
|||||||
func (p *jsonPatcher) applyJSPatch(versionedJS []byte) (patchedJS []byte, retErr error) {
|
func (p *jsonPatcher) applyJSPatch(versionedJS []byte) (patchedJS []byte, retErr error) {
|
||||||
switch p.patchType {
|
switch p.patchType {
|
||||||
case types.JSONPatchType:
|
case types.JSONPatchType:
|
||||||
// sanity check potentially abusive patches
|
|
||||||
// TODO(liggitt): drop this once golang json parser limits stack depth (https://github.com/golang/go/issues/31789)
|
|
||||||
if len(p.patchBytes) > 1024*1024 {
|
|
||||||
v := []interface{}{}
|
|
||||||
if err := json.Unmarshal(p.patchBytes, &v); err != nil {
|
|
||||||
return nil, errors.NewBadRequest(fmt.Sprintf("error decoding patch: %v", err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
patchObj, err := jsonpatch.DecodePatch(p.patchBytes)
|
patchObj, err := jsonpatch.DecodePatch(p.patchBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.NewBadRequest(err.Error())
|
return nil, errors.NewBadRequest(err.Error())
|
||||||
@ -361,15 +352,6 @@ func (p *jsonPatcher) applyJSPatch(versionedJS []byte) (patchedJS []byte, retErr
|
|||||||
}
|
}
|
||||||
return patchedJS, nil
|
return patchedJS, nil
|
||||||
case types.MergePatchType:
|
case types.MergePatchType:
|
||||||
// sanity check potentially abusive patches
|
|
||||||
// TODO(liggitt): drop this once golang json parser limits stack depth (https://github.com/golang/go/issues/31789)
|
|
||||||
if len(p.patchBytes) > 1024*1024 {
|
|
||||||
v := map[string]interface{}{}
|
|
||||||
if err := json.Unmarshal(p.patchBytes, &v); err != nil {
|
|
||||||
return nil, errors.NewBadRequest(fmt.Sprintf("error decoding patch: %v", err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsonpatch.MergePatch(versionedJS, p.patchBytes)
|
return jsonpatch.MergePatch(versionedJS, p.patchBytes)
|
||||||
default:
|
default:
|
||||||
// only here as a safety net - go-restful filters content-type
|
// only here as a safety net - go-restful filters content-type
|
||||||
|
Loading…
Reference in New Issue
Block a user