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

[#879] Additional renaming and checkstyle changes #886

Merged
merged 2 commits into from
Dec 13, 2024
Merged

Conversation

chubtub
Copy link
Contributor

@chubtub chubtub commented Dec 10, 2024

These changes follow those from #848. It should be noted that after reviewing the documentation the ReferenceDigestValue class was deemed appropriately named and not renamed as originally intended. Variable names in a few other classes have been refactored to more clearly align with TCG documentation. More checkstyle changes have been implemented as well.

Closes #879

@chubtub chubtub requested a review from iadgovuser26 December 10, 2024 21:48
@chubtub chubtub self-assigned this Dec 10, 2024
Copy link
Collaborator

@ThatSilentCoder ThatSilentCoder left a comment

Choose a reason for hiding this comment

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

I had some questions about some of the changes you"ve made. Asides from those questions, I didn't have any other issues with the PR.

@@ -526,14 +522,18 @@ private void processTpmEvents(final List<SupportReferenceManifest> dbSupportRims

this.referenceDigestValueRepository.save(newRdv);
}
} catch (CertificateException | NoSuchAlgorithmException | IOException e) {
} catch (CertificateException e) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we are printing the same stack trace for all three exceptions, why did you separate them out into their own catch statement? Do you believe that we will add more code to each exception case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change was automatically applied by checkstyles. There are instances in the tcg_rim_tool of exceptions broken out into distinct catch blocks for specific handling, which can be applied here if appropriate.

@@ -608,6 +608,12 @@ public ModelAndView initPage(final ReferenceManifestDetailsPageParams params,
String uuidError = "Failed to parse ID from: " + params.getId();
messages.addError(uuidError);
log.error(uuidError, iaEx);
} catch (CertificateException cEx) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed that we are catching every possible exception the application could throw at us (with the very last catch statement on line 617 in the modified file), is that last catch necessary? If it is necessary, do you believe it would make sense to collapse all of the above exceptions into one big catch seeing as that we are logging the same exception and we aren't doing anything special per exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exception handling can be more elegantly handled in the ACA. In many cases a try block is followed by several catches with unique parameters that are otherwise identical. If deemed appropriate these can be addressed in a future PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah this issue isn't unique to this file. I think addressing our way of handling exceptions in a future PR is the move.

final PolicySettings policySettings) {
List<TpmPcrEvent> tpmPcrEvents = new LinkedList<>();
for (TpmPcrEvent tpe : tcgMeasurementLog.getEventList()) {
if (policySettings.isIgnoreImaEnabled() && tpe.getPcrIndex() == IMA_PCR) {
log.info("IMA Ignored -> {}", tpe);
log.info(String.format("IMA Ignored -> %s", tpe));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've noticed that you've changed the parameterized log messages to string format messages throughout the three files. Is this the standard that we are supposed to follow or is there another reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change was automatically applied by checkstyles so I assumed that was the standard we were following. I can look into logging best practices to see if there's any reason to prefer one over the other.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No worries! I wasn't trying to be nit-picky. I wasn't entirely sure if this was the standard we wanted to stick to or if parameterized log messages was the way to go. I saw that the Intellij IDE suggested that as the "preferred" option; however I do not know what the team believes is best.

Copy link
Collaborator

@ThatSilentCoder ThatSilentCoder left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. Appreciate you answering my questions. Further discussions should be had on the subject of the log message formatting and the way we handle exceptions.

@iadgovuser26 iadgovuser26 merged commit ad09669 into main Dec 13, 2024
7 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.

Rename ReferenceDigestValue
3 participants