Skip to content

Commit

Permalink
Comment out sensitive log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
arlowatts committed Aug 3, 2023
1 parent 2ea9bd9 commit cdc0399
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Services/Common/src/Delegates/PharmanetDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ private string TrimBadCharactersInMessage(string hl7base64Message = @"")
byte[] bytes = Convert.FromBase64String(hl7base64Message);
byte[] newBytes = new byte[bytes.Length];

// This log statement logs sensitive health information - use it only for debugging in a development environment
// Logger.LogDebug(this.logger, $"RESPONSE B64='{hl7base64Message}'");

Span<byte> span = bytes;
int i = 0;
foreach(byte aByte in span)
Expand All @@ -65,6 +68,9 @@ private string TrimBadCharactersInMessage(string hl7base64Message = @"")
}
string b64ResultStr = Convert.ToBase64String(newBytes, 0, i);

// This log statement logs sensitive health information - use it only for debugging in a development environment
// Logger.LogDebug(this.logger, $"UPDATED RESPONSE B64='{b64ResultStr}'");

return b64ResultStr;
}

Expand Down Expand Up @@ -102,6 +108,9 @@ public async Task<RequestResult<PharmanetMessageModel>> SubmitRequest(PharmanetM
{
Uri delegateUri = new Uri(this.pharmanetDelegateConfig.Endpoint);

// This log statement logs sensitive health information - use it only for debugging in a development environment
// Logger.LogDebug(this.logger, $"PharmanetDelegate Proxy POST {delegateUri}. Payload: {jsonOutput}");

HttpResponseMessage response = await this.httpClient.PostAsync(delegateUri, content).ConfigureAwait(true);
requestResult.IsSuccessStatusCode = response.IsSuccessStatusCode;
requestResult.StatusCode = response.StatusCode;
Expand All @@ -120,6 +129,8 @@ public async Task<RequestResult<PharmanetMessageModel>> SubmitRequest(PharmanetM

responseMessage!.Hl7Message = TrimBadCharactersInMessage(responseMessage!.Hl7Message); // Workaround stray chars from Delegate
requestResult.Payload = responseMessage;
// This log statement does not log sensitive health information, even though it looks like it might
Logger.LogDebug(this.logger, $"PharmanetDelegate Proxy Response: {responseMessage}");
}
}
#pragma warning disable CA1031 // Do not catch general exception types
Expand Down
9 changes: 9 additions & 0 deletions Services/Common/src/Services/PharmanetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public async Task<RequestResult<DocumentReference>> SubmitRequest(DocumentRefere

try
{
// This log statement logs sensitive health information - use it only for debugging in a development environment
// Logger.LogDebug(this.logger, $"Pharmanet Request: {requestMessage.Hl7Message}");

RequestResult<PharmanetMessageModel> result = await this.pharmanetDelegate.SubmitRequest(requestMessage).ConfigureAwait(true);

response.StatusCode = result.StatusCode;
Expand All @@ -74,9 +77,15 @@ public async Task<RequestResult<DocumentReference>> SubmitRequest(DocumentRefere
{
PharmanetMessageModel? message = result.Payload;

// This log statement logs sensitive health information - use it only for debugging in a development environment
// this.logger.LogDebug($"Pharmanet Response: {message!.Hl7Message}");

ResourceReference reference = PharmanetDelegateAdapter.RelatedToDocumentReference(request);
response.Payload = PharmanetDelegateAdapter.ToDocumentReference(message!, reference);

// This log statement does not log sensitive health information, even though it looks like it might
this.logger.LogDebug($"FHIR Response: {response!.Payload.ToString()}");

response.IsSuccessStatusCode = true;
}
else
Expand Down

0 comments on commit cdc0399

Please sign in to comment.