-
Notifications
You must be signed in to change notification settings - Fork 40
Feature Request: JSON Parser #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feature Request: JSON Parser #822
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run //:license-check Status: Click to expand output
|
2fb2df2
to
29b929c
Compare
Security Impact | ||
=============== | ||
|
||
The module will likely work with input and output streams. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so what is the impact? Access Control needed?, please set also tag security to yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For access control and manipulation prevention (e.g. dm-verity) the hosting process and system configuration need to take care of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then may add this as assumption of use in the feature request, otherwise it get lost, by the way, this is more a component_request as part of feature:baselib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked: is now a component request, but AoU is still missing. Additionally we should have a seperate AoU that states that the integrity of the input JSON data is with the user (i.e. if it comes from a file it must be protected)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this in the latest commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about not making this clear: The AoU should be done as a requirement using template https://eclipse-score.github.io/process_description/main/process_areas/requirements_engineering/guidance/requirements_templates.html#gd_temp__req__aou_req
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the two AoU requirements in the latest commit.
The created documentation from the pull request is available at: docu-html |
5c9e3a9
to
70d0134
Compare
Signed-off-by: Alexandru Iulian <[email protected]>
Signed-off-by: Alexandru Iulian <[email protected]>
Co-authored-by: rattenking52 <[email protected]> Signed-off-by: Alexandru Iulian <[email protected]>
Signed-off-by: Alexandru Iulian <[email protected]>
Co-authored-by: rattenking52 <[email protected]> Signed-off-by: Alexandru Iulian <[email protected]>
Signed-off-by: Alexandru Iulian <[email protected]>
Co-authored-by: rattenking52 <[email protected]> Signed-off-by: Alexandru Iulian <[email protected]>
70d0134
to
0684f44
Compare
Co-authored-by: Jonas Lammers <[email protected]> Signed-off-by: Alexandru Iulian <[email protected]>
8c08309
to
70b96a9
Compare
Signed-off-by: Alexandru Iulian <[email protected]>
It was decided that for each component in the Base Libs there will be at least one feature requirement, which will link to the Base libs stakeholder requirement. The component requirements will link to that respective feature requirement. Signed-off-by: Alexandru Iulian <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To sum things up:
Which public API is meant in the different requirements?
:satisfies: feat_req__baselibs__json_library | ||
:status: valid | ||
|
||
Each public API shall support the idioms of the programming language it is written in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the intention here? Which public API is meant here. Do you mean the one implemented in baselibs or the one provided by nlohmann?
Just considering how this might be supported with evidence? Is an SME review necessary here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requirement is "Non-functional" so a "SME review" is appropriate. After discussion with @LittleHuba we concluded we wanted this kind of requirement (which is applicable for every user API) rather defined in a coding guideline. But this is a future PR so let's keep this here for the moment.
:satisfies: feat_req__baselibs__json_library | ||
:status: valid | ||
|
||
Each public API shall use core infrastructure of its programming language and accompanying standard libraries, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be proven to be fulfilled by SME review or on codebasis? Which API is meant here again? The requirement appears to be very general and vague.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
Signed-off-by: Alexandru Iulian <[email protected]>
Signed-off-by: Alexandru Iulian <[email protected]>
Signed-off-by: Alexandru Iulian <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the great progress in this area.
I classify my comments with the following priority/importance (must/should/could/may):
- Must:
parsed_json
reqs - Must: Error handling reqs
- Could: JSON schema reqs
- May: Compile-time parsing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The requirements around the 'parsing functionality' of JSON have been captured here. The outcome of the parsing shall be a parsed representation of the JSON. Let me refer to this as the parsed_json
. I did not find any requirements that relate to the parsed_json
. I would like to note some high-level aspects related to the parsed_json
.
The parsed_json
shall
- be a regular type
- not expose the implementation library types (as this can restrict future changes/evolution)
Some of the above requirements may relate to other components & modules too. Such high-level requirements should be considered to be elevated as guidance (e.g. thou shalt not expose implementation-level data-types across the component boundaries).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a requirement for this in the latest commit.
The public API shall use core infrastructure of its programming language and accompanying standard libraries, | ||
whenever possible and meaningful. | ||
|
||
Note: This includes error handling. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our implementations should have a greater guarantee. Error handling should not be left to a Note in my opinion.
I would like to suggest the following requirements: (again, if found generic, we could promote to overall Eclipse S-CORE level)
- Error encountered (due to incorrect input, system error, or otherwise) should be reported back to the user
- Error reporting via non-throwing mechanisms is preferrable (like
optional<T>
,std::expected<T>
,score::cpp::optional
,score::Result<T>
) - In case of error, it should be difficult for the users to carry out operations on the parsed representation of the JSON as if it was successful. The API shall allow foe easy error handling in case of an error. This is to make correct implementations easier than not.
Sample code:
//Let's say the application wants to apply config read from a JSON
void apply(score::json);
//Possible API offered by this component
using score::json = ...defined by this component...;
score::Result<score::json> deserialize(const std::string_view json_str) { ... }
//Such an API cannot be used incorrectly
auto ill_formatted_json = "xyz"sv;
auto my_config = deserialize(ill_formatted_json);
//The following must not even compile as it is trying to use the return as json
apply(my_config);
//Error handling must be possible
score::json default_config = { {"threshold-min", 80}, {"threshold_max", 95} }; //should be possible to construct directly
apply(my_config.value_or(default_config));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point, but I think we should clarify if it should be added here or somewhere else. It seems to me more like a general S-CORE guideline than something specific to the JSON library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, I discussed with @LittleHuba and said we would not have this in every component's requirements but add to a Coding Guideline. No actions in this PR. #1533 created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A possible requirement could be to ensure correctness by default by allowing compile-time constructs & checks.
I would put it as below:
- to be able to parse a JSON at compilation-time. This can help have compile-time tests (with facilities like
static_assert
). This will block compilation if the implementation does develop an error or incorrectness. This will ensure that a component with errors cannot exist even in the absence of a pipeline (yes, the tests should be extensive). Plus, generally, it will shift-left catching errors.
I understand that the nlohmann library does not offer compile-time parsing. So, this can be kept as a good to have requirement. Or be dropped, if we decide to not support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only have requirements which can be fulfilled by our implementation (OSS component we select). Can be added to the component requirements later if really required. So we should add this to the component request in https://eclipse-score.github.io/score/pr-822/modules/baselibs/json/docs/index.html#future-extensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want JSON schema validation as a requirement?
Something like this:
- It should be possible to validate a json against a json-schema.
This could be lower in priority as compared to the core functionality depending on the need across all partners.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this already in the past and then the decision was to not have schema validation. Can be added to the component requirements later if really required. Also here: add this to the component request in https://eclipse-score.github.io/score/pr-822/modules/baselibs/json/docs/index.html#future-extensions with the addition that this might even be an additional component (request).
Signed-off-by: Alexandru Iulian <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requirements are fine from logging side
https://github.com/orgs/eclipse-score/discussions/1414#discussioncomment-13787441
Signed-off-by: Alexandru Iulian <[email protected]>
2da6ca0
to
397f68e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments originally from masc2023 still have to be resolved
Signed-off-by: Alexandru Iulian <[email protected]>
c117500
to
0a44e59
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see also updated inline comments
|
||
.. comp_req:: Enforce strict type compatibility | ||
:id: comp_req__json__type_compatibility | ||
:reqtype: Non-Functional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say this is a Functional requirement, as could be tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to :reqtype: Functional in the latest commit.
.. comp_req:: JSON library ASIL level | ||
:id: comp_req__json__asil | ||
:reqtype: Functional | ||
:security: YES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this requirement is not security relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to :security: NO in the latest commit.
Co-authored-by: Ulrich Huber <[email protected]> Signed-off-by: Alexandru Iulian <[email protected]>
Signed-off-by: Alexandru Iulian <[email protected]>
Provides a proposal for a safe JSON parser feature.