-
-
Notifications
You must be signed in to change notification settings - Fork 469
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
#2849 ApplyEventException can leak event data to logs #2854
Merged
jeremydmiller
merged 1 commit into
JasperFx:master
from
erdtsieck:feature/2849-ApplyEventException-can-leak-event-data-to-logs
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Marten.Events; | ||
using Marten.Exceptions; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace CoreTests.Exceptions; | ||
|
||
public class ApplyEventExceptionTests | ||
{ | ||
public class FakeEventThatContainsSecretInformation | ||
{ | ||
public string Secret { get; set; } | ||
} | ||
|
||
[Fact] | ||
public void should_only_include_sequence_and_id_no_data() | ||
{ | ||
var @event = new Event<FakeEventThatContainsSecretInformation>(new() | ||
{ | ||
Secret = "very secret!!!" | ||
}); | ||
var exception = new ApplyEventException(@event, new("inner")); | ||
|
||
exception.Message.ShouldBe($"Failure to apply event #{@event.Sequence} Id({@event.Id})"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As I see it, depending on usage,
@event.Id
may or may not get set by the code using Marten lib. So in some cases,Id
as a value in the exception log may not be relatable since it might have been generated internally within Marten for event persistence if it was not set.So data leakage looks be a bit of a tricky issue to deal with.
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 guess you're right, but I think its better to not have the best log message thinkable, then to have GPDR requirements broken. So maybe this logging can be improved in a future fix?
I could add the EventTypeName and StreamKey ?? StreamId
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.
Currently, we don't know what is GDPR related data or some sensitive data which shouldn't be logged. May be once there is support for GDPR in Marten, there could be an attribute or something which can be applied on a property or field and which can be used to redact the text while logging as well. Until then we can't have a clear cut fix.
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.
Well, we could not include Data and include other descriptive properties untill then? That will prevent sensitive data to be unintentially written, especially using records. Which is becoming the default for events as of there ease of use for the case.
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 will see what could be a short term solution, will discuss with @jeremydmiller and @oskardudycz on this.
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.
That event.Id is Marten assigned and I don't think would refer directly to any kind of PII
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.
Just having
event.Id
wouldn't give much details about the exception for troubleshooting purposes.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 agree @mysticmind , maybe we can add the event type and event stream id in another PR