diff --git a/CHANGES.rst b/CHANGES.rst index cfd152544c13c838542524132908dcabe3a27166..0e8e1ef16cf3e82919f3ecbf972062e9bccdf419 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -28,24 +28,59 @@ General Node ---- +- **Breaking change** Enforced stricter validation for the JSON configuration + file. Previously, the parser would silently ignore any content that appeared + after the first valid JSON object. Now, any extraneous data will cause the + function to return an error. (MR :gl:`!18745`) + Client ------ +- **Breaking change** Enforced stricter validation for the JSON files + manipulated by the client. Previously, the parser would silently ignore any + content that appeared after the first valid JSON object. Now, any extraneous + data will cause the function to return an error. (MR :gl:`!18745`) + Signer ------ +- **Breaking change** Enforced stricter validation for the JSON files + manipulated by the signer. Previously, the parser would silently ignore any + content that appeared after the first valid JSON object. Now, any extraneous + data will cause the function to return an error. (MR :gl:`!18745`) + Baker ----- +- **Breaking change** Enforced stricter validation for the JSON files + manipulated by the baker. Previously, the parser would silently ignore any + content that appeared after the first valid JSON object. Now, any extraneous + data will cause the function to return an error. (MR :gl:`!18745`) + Agnostic Baker -------------- +- **Breaking change** Enforced stricter validation for the JSON files + manipulated by the agnostic baker. Previously, the parser would silently + ignore any content that appeared after the first valid JSON object. Now, any + extraneous data will cause the function to return an error. (MR :gl:`!18745`) + Accuser ------- +- **Breaking change** Enforced stricter validation for the JSON files + manipulated by the accuser. Previously, the parser would silently + ignore any content that appeared after the first valid JSON object. Now, any + extraneous data will cause the function to return an error. (MR :gl:`!18745`) + Agnostic Accuser ---------------- +- **Breaking change** Enforced stricter validation for the JSON files + manipulated by the agnostic accuser. Previously, the parser would silently + ignore any content that appeared after the first valid JSON object. Now, any + extraneous data will cause the function to return an error. (MR :gl:`!18745`) + Proxy Server ------------ @@ -61,6 +96,12 @@ Docker Images Smart Rollup node ----------------- +- **Breaking change** Enforced stricter validation for the JSON configuration + file. Previously, the parser would silently ignore any content that appeared + after the first valid JSON object. Now, any extraneous data will cause the + function to return an error. (MR :gl:`!18745`) + + Smart Rollup WASM Debugger -------------------------- @@ -70,5 +111,11 @@ Data Availability Layer (DAL) DAL node ~~~~~~~~ +- **Breaking change** Enforced stricter validation for the JSON configuration + file. Previously, the parser would silently ignore any content that appeared + after the first valid JSON object. Now, any extraneous data will cause the + function to return an error. (MR :gl:`!18745`) + + Miscellaneous ------------- diff --git a/etherlink/CHANGES_NODE.md b/etherlink/CHANGES_NODE.md index 4a87863f766cae19bb0f00c01e6a67290e435641..d71c16d0298785fdb91c96ec9d465fdb1c0e6477 100644 --- a/etherlink/CHANGES_NODE.md +++ b/etherlink/CHANGES_NODE.md @@ -16,6 +16,11 @@ ### Execution changes +- Enforces stricter validation for the JSON configuration file. Previously, + the parser would silently ignore any content that appeared after the first + valid JSON object. Now, any extraneous data will cause the function to return + an error. (!18745) + ### Storage changes ### Documentation changes diff --git a/src/lib_stdlib_unix/lwt_utils_unix.ml b/src/lib_stdlib_unix/lwt_utils_unix.ml index a729fd84d318e9e7e1aad4a42bf4f3094ecd2431..01bac84d833162740df2036a36eec618d8125ec0 100644 --- a/src/lib_stdlib_unix/lwt_utils_unix.ml +++ b/src/lib_stdlib_unix/lwt_utils_unix.ml @@ -302,6 +302,19 @@ let getpass () = passwd module Json = struct + type error += Json_decoding_error of {input : string; error : string} + + let () = + register_error_kind + `Temporary + ~id:"json_decoding_error" + ~title:"Json decoding error" + ~description:"The input string is not a valid JSON value" + Data_encoding.(obj2 (req "input" string) (req "error" string)) + (function + | Json_decoding_error {input; error} -> Some (input, error) | _ -> None) + (fun (input, error) -> Json_decoding_error {input; error}) + let to_root = function | `O ctns -> `O ctns | `A ctns -> `A ctns @@ -322,7 +335,9 @@ module Json = struct Lwt_io.with_file ~mode:Input file (fun chan -> let open Lwt_result_syntax in let*! str = Lwt_io.read chan in - return (Ezjsonm.from_string str :> Data_encoding.json))) + match Data_encoding.Json.from_string str with + | Ok json -> return json + | Error error -> tzfail (Json_decoding_error {input = str; error}))) end (* This module is used by [safe_cancel_on_exit] to register and unregister