From bc4a108059763fbf7ee7489bc9541ada42ac6e18 Mon Sep 17 00:00:00 2001 From: Nils Eberhardt Date: Wed, 9 Jul 2025 14:58:43 +0000 Subject: [PATCH 1/2] Add assumptions of use Add assumptions of use for nlohmann_json --- docs/trustable/report.rst | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/trustable/report.rst b/docs/trustable/report.rst index 09e8dab..b2886ae 100644 --- a/docs/trustable/report.rst +++ b/docs/trustable/report.rst @@ -120,3 +120,37 @@ Compliance for TT * - :doc:`tenets/TT-RESULTS/index` - Evidence is provided to demonstrate that json library does what it is supposed to do, and does not do what it must not do. - 0.00 + + +Assumptions of Use +################### + +.. list-table:: Assumptions of Use + :widths: 15 85 + :header-rows: 1 + + * - Id + - Summary + * - AoU-01 + - Problems with nlohmann_json's implementation identified during testing are reported to the upstream nlohmann_json project. + * - AoU-02 + - The build environment used for nlohmann_json in an integrating system is supplied with consistent dependencies. + * - AoU-03 + - The build process must use Integrator-controlled mirrors rather than pulling dependencies from the internet at build-time. + * - AoU-04 + - Exceptions are properly handled or turned off: + + - All exceptions (``json::parse_error``, ``json::invalid_iterator``, ``json::type_error``, ``json::out_of_range``, ``json::other_error``) inherit from ``json::exception``. + - The nlohman_json library uses ``JSON_TRY``, ``JSON_CATCH``, etc., macros instead of the exception keywords ``try``, ``catch``, etc., which may be overwritten to suppress exceptions. + - Each keyword can be individually overwritten (e.g. ``#define JSON_THROW(exception) std::abort()``) or all keywords can be changed by setting ``#define JSON_NOEXCEPTION`` to suppress exceptions. + - Alternatively, the ``accept`` function may be used to check JSON validity, as it only throws an exception for an empty input. In the case of invalid JSON, ``false`` is returned, and no exception occurs. The ``parse`` function also has a parameter ``allow_exceptions`` to turn off parse error exceptions. + - See: + - `nlohman_json: JSON_NOEXCEPTION Macro `_ + - `nlohman_json: Switch Off Exceptions `_ + + * - AoU-05 + - Input has to be encoded as UTF-8 (as required by RFC8259). In case other string formats are used the parse or dump function may throw an exception. + * - AoU-06 + - To avoid any confusion and ensure portable code, brace initialization (e.g. json j{true};) should not be used with the types basic_json, json, or ordered_json unless you want to create an object or array. + * - AoU-07 + - If the input is no valid JSON, exceptions should be expected during parsing with default parameters. From 3c5053eedc009c6c5cecdb1a4e164897a24df362 Mon Sep 17 00:00:00 2001 From: Nils Eberhardt Date: Thu, 10 Jul 2025 07:32:19 +0000 Subject: [PATCH 2/2] Refactoring AoU Changed assumption of use into proper TSF statements --- docs/trustable/report.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/trustable/report.rst b/docs/trustable/report.rst index b2886ae..73f9e23 100644 --- a/docs/trustable/report.rst +++ b/docs/trustable/report.rst @@ -136,10 +136,14 @@ Assumptions of Use * - AoU-02 - The build environment used for nlohmann_json in an integrating system is supplied with consistent dependencies. * - AoU-03 - - The build process must use Integrator-controlled mirrors rather than pulling dependencies from the internet at build-time. + - The integrator has Integrator-controlled mirrors of the dependencies. * - AoU-04 + - The system is built with the S-Core bazel build pipeline. + * - AoU-05 - Exceptions are properly handled or turned off: + Context: + - All exceptions (``json::parse_error``, ``json::invalid_iterator``, ``json::type_error``, ``json::out_of_range``, ``json::other_error``) inherit from ``json::exception``. - The nlohman_json library uses ``JSON_TRY``, ``JSON_CATCH``, etc., macros instead of the exception keywords ``try``, ``catch``, etc., which may be overwritten to suppress exceptions. - Each keyword can be individually overwritten (e.g. ``#define JSON_THROW(exception) std::abort()``) or all keywords can be changed by setting ``#define JSON_NOEXCEPTION`` to suppress exceptions. @@ -148,9 +152,9 @@ Assumptions of Use - `nlohman_json: JSON_NOEXCEPTION Macro `_ - `nlohman_json: Switch Off Exceptions `_ - * - AoU-05 - - Input has to be encoded as UTF-8 (as required by RFC8259). In case other string formats are used the parse or dump function may throw an exception. * - AoU-06 - - To avoid any confusion and ensure portable code, brace initialization (e.g. json j{true};) should not be used with the types basic_json, json, or ordered_json unless you want to create an object or array. + - Input is encoded as UTF-8 (as required by RFC8259) and in case other string formats are used, it is expected that the parse or dump function may throw an exception. * - AoU-07 - - If the input is no valid JSON, exceptions should be expected during parsing with default parameters. + - Brace initialization (e.g. json j{true};) is not used with the types basic_json, json, or ordered_json unless you want to create an object or array. + * - AoU-08 + - If the input is no valid JSON, exceptions are expected during parsing with default parameters.