Skip to content
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

AA: kbs: Improve handling of invalid RCAR JSON #723

Merged

Conversation

jodh-intel
Copy link
Member

Create a new error to handle the scenario where the RCAR JSON specifies the selected hash algorithm
using the wrong data type (any type other than 'string').

Signed-off-by: James O. D. Hunt [email protected]

@jodh-intel jodh-intel marked this pull request as ready for review September 16, 2024 17:08
@jodh-intel jodh-intel requested a review from a team as a code owner September 16, 2024 17:08
@jodh-intel
Copy link
Member Author

This PR addresses @mkulke's comment: #712 (comment).

@jodh-intel jodh-intel force-pushed the aa-kbs-rcar-improvement branch from 934118a to a0e4f74 Compare September 16, 2024 17:09
@fidencio fidencio requested a review from mkulke September 17, 2024 07:35
@@ -56,6 +56,26 @@ async fn get_request_extra_params() -> serde_json::Value {
extra_params
}

async fn get_hash_algorithm(extra_params: serde_json::Value) -> Result<HashAlgorithm> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might not need this to be async

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Xynnn007 - true, this function doesn't actually need to be async, but I feel the code is cleaner + safer if we use async everywhere we can reasonably do so.

If I drop the async, I either:

  • block the calling task implicitly (maybe not an issue now, but potentially problematic if the implementation changes (future bug potential)).
  • block it explicitly with spawn_blocking() (extra code noise for no obvious benefit).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that coloring everything in the call tree async is a good approach. Can you elaborate on the safety risk? for all I know the async annotation functions should be reserved to functions that do await a Future.

tokio is a work-stealing scheduler, even a large sync computation wouldn't block an eventloop or something.

the annotation of a fn with async desugars into a future return type in the fn signature and makes things more complicated in terms of lifetimes (futures need to be sync + send, as they cannot be shared across threads), you have to start an executor for a unit test, etc...

so, intuitively I'd say that async should be strictly limited to places where it's absolutely required, but I'm happy for pointers to docs/articles that say otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My personal preference is to mark it as non-async. Once it needs to be async, we can then mark it as async version.

btw, if a function is a concrete implementation of an async-trait function, I can live with situations where even no async code is inside the function body.

wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've spent enough time discussing a 5 byte change. Branch updated 😄

Implement `PartialEq` for `HashAlgorithm` to allow two hash algorith
values to be compared.

Signed-off-by: James O. D. Hunt <[email protected]>
Create a new error to handle the scenario where the RCAR JSON specifies
the selected hash algorithm using the wrong data type (any type other than
'string').

Signed-off-by: James O. D. Hunt <[email protected]>
@jodh-intel jodh-intel force-pushed the aa-kbs-rcar-improvement branch from a0e4f74 to 6c30f4b Compare September 24, 2024 13:54
@fitzthum fitzthum merged commit f8e3bff into confidential-containers:main Sep 25, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants