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

Platform/bill/16144 #16550

Merged
merged 17 commits into from
Nov 22, 2024
Merged

Platform/bill/16144 #16550

merged 17 commits into from
Nov 22, 2024

Conversation

wcutshall
Copy link
Collaborator

@wcutshall wcutshall commented Nov 15, 2024

This PR contains coding changes for user story 16144.

Test Steps:

  1. POST a message through Postman (or equivalent) and observe the log files.

Changes

  • Modified FHIRTranslator and associated tests.
    • Added new ITEM_TRANSLATE azure event in translate function.
    • Check for matching file digest SHAs.

Checklist

Testing

  • Tested locally?
  • Ran ./prime test or ./gradlew testSmoke against local Docker ReportStream container?
  • [N/A] (For Changes to /frontend-react/...) Ran npm run lint:write?
  • Added tests?

Process

  • Are there licensing issues with any new dependencies introduced? N/A
  • Includes a summary of what a code reviewer should test/verify?
  • Updated the release notes? N/A
  • Database changes are submitted as a separate PR? N/A
  • DevOps team has been notified if PR requires ops support? N/A

Linked Issues

  • N/A

To Be Done

  • N/A

Specific Security-related subjects a reviewer should pay specific attention to

  • Does this PR introduce new endpoints? No
  • Does this PR include changes in authentication and/or authorization of existing endpoints? No
  • Does this change introduce new dependencies that need vetting? No
  • Does this change require changes to our infrastructure? No
  • Does logging contain sensitive data? No
  • Does this PR include or remove any sensitive information itself? No

@wcutshall wcutshall added the platform Platform Team label Nov 15, 2024
Copy link

github-actions bot commented Nov 15, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

Copy link

github-actions bot commented Nov 15, 2024

Test Results

1 248 tests  +1   1 244 ✅ +1   7m 43s ⏱️ +4s
  162 suites ±0       4 💤 ±0 
  162 files   ±0       0 ❌ ±0 

Results for commit 97b21ad. ± Comparison against base commit 9258b5d.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Nov 15, 2024

Integration Test Results

 54 files  ±0   54 suites  ±0   28m 36s ⏱️ +43s
414 tests ±0  404 ✅ ±0  10 💤 ±0  0 ❌ ±0 
417 runs  ±0  407 ✅ ±0  10 💤 ±0  0 ❌ ±0 

Results for commit 97b21ad. ± Comparison against base commit 9258b5d.

♻️ This comment has been updated with latest results.

@@ -114,6 +118,10 @@ class FHIRTranslator(
logger.trace("Preparing to send original message")
val originalReport = reportService.getRootReport(message.reportId)
val bodyBytes = BlobAccess.downloadBlobAsByteArray(originalReport.bodyUrl)
val localDigest = BlobUtils.digestToString(sha256Digest(bodyBytes))
check(message.digest == localDigest) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems wrong to me. The digest value in the message I believe would be the digest of the blob associated with the passed in report (so the report that is downloaded in sendTranslated). Here, you are downloading the ROOT report, which would have a different digest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So, if I'm understanding correctly, we should be comparing message.digest with blobInfo.digest (after the file is uploaded)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

message.digest is already used in sendTranslated and that's the only place it should be used. Here, you are downloading the root report, so you need to to compare the downloaded root report to the root report's digest (which is stored in the DB report_file table)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Latest changes should address this.

@@ -163,6 +171,18 @@ class FHIRTranslator(
topic = message.topic
)

val builder = ReportStreamItemEventBuilder(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should prefer the style that is shown in FHIRDestinationFilter where we pass in the builder directly to sendItemEvent (so we remain consistent):

reportEventService.sendItemEvent(
            eventName = ReportStreamEventName.ITEM_ROUTED,
            childReport = report,
            pipelineStepName = TaskAction.destination_filter
        ) {
            parentReportId(queueMessage.reportId)
            params(
                mapOf(
                ReportStreamEventProperties.RECEIVER_NAME to receiver.fullName,
                ReportStreamEventProperties.BUNDLE_DIGEST
                    to bundleDigestExtractor.generateDigest(bundle)
            )
            )
            trackingId(bundle)
        }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should be in there now.

@arnejduranovic arnejduranovic marked this pull request as ready for review November 20, 2024 17:14
@arnejduranovic arnejduranovic requested a review from a team as a code owner November 20, 2024 17:14
@arnejduranovic arnejduranovic self-assigned this Nov 20, 2024
@@ -114,6 +121,11 @@ class FHIRTranslator(
logger.trace("Preparing to send original message")
val originalReport = reportService.getRootReport(message.reportId)
val bodyBytes = BlobAccess.downloadBlobAsByteArray(originalReport.bodyUrl)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Have we considered updating this to use BlobAccess.downloadBlob(...) which will do the digest check for us?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Made the change.

Copy link

sonarcloud bot commented Nov 21, 2024

Copy link
Collaborator

@arnejduranovic arnejduranovic left a comment

Choose a reason for hiding this comment

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

great work!

@wcutshall wcutshall merged commit ad28996 into main Nov 22, 2024
24 checks passed
@wcutshall wcutshall deleted the platform/bill/16144 branch November 22, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform Platform Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants