From c12fc9659f94e1d3702e6bd74da9176e9a3425d6 Mon Sep 17 00:00:00 2001 From: Stefan Jandl Date: Fri, 21 Jun 2024 09:26:52 +0200 Subject: [PATCH] chore: Revert adding an EventScrubber (#3441) --- CHANGELOG.md | 1 - ...s.EventScrubberBenchmarks-report-github.md | 14 -- .../EventScrubberBenchmarks.cs | 79 -------- src/Sentry/Breadcrumb.cs | 15 +- src/Sentry/Internal/EventScrubber.cs | 175 ------------------ src/Sentry/SentryClient.cs | 2 - src/Sentry/SentryOptions.cs | 58 ------ ...piApprovalTests.Run.DotNet6_0.verified.txt | 3 - ...piApprovalTests.Run.DotNet7_0.verified.txt | 3 - ...piApprovalTests.Run.DotNet8_0.verified.txt | 3 - .../ApiApprovalTests.Run.Net4_8.verified.txt | 3 - ...ests.ScrubEvent_ScrubsRequest.verified.txt | 18 -- .../Internals/EventScrubberTests.cs | 146 --------------- test/Sentry.Tests/SentryClientTests.cs | 16 -- test/Sentry.Tests/SentryOptionsTests.cs | 42 ----- 15 files changed, 2 insertions(+), 576 deletions(-) delete mode 100644 benchmarks/Sentry.Benchmarks/BenchmarkDotNet.Artifacts/results/Sentry.Benchmarks.EventScrubberBenchmarks-report-github.md delete mode 100644 benchmarks/Sentry.Benchmarks/EventScrubberBenchmarks.cs delete mode 100644 src/Sentry/Internal/EventScrubber.cs delete mode 100644 test/Sentry.Tests/Internals/EventScrubberTests.ScrubEvent_ScrubsRequest.verified.txt delete mode 100644 test/Sentry.Tests/Internals/EventScrubberTests.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index bf05a3c186..ab6dc04a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,6 @@ - Added a new package `Sentry.AspNetCore.Blazor.WebAssembly`. This packages provides you with an extension to `WebAssemblyHostBuilder` to allow SDK configuration via the builder pattern. This package gives us an entry point and the ability to extend the SDKs support and out-of-the-box offering. You can follow the progress and leave feedback either ([here](https://github.com/getsentry/sentry-dotnet/issues/2329)) for extending the support for Blazor Server or ([here](https://github.com/getsentry/sentry-dotnet/issues/2021)) for Blazor WebAssembly support ([#3386](https://github.com/getsentry/sentry-dotnet/pull/3386)) - Added a new package `Sentry.AspNetCore.Blazor`. This packages provides you with an extension to `WebAssemblyHostBuilder` to allow SDK configuration via the builder pattern. This package gives us an entry point and the ability to extend the SDKs support and out-of-the-box offering. You can follow the progress and leave feedback either ([here](https://github.com/getsentry/sentry-dotnet/issues/2329)) for extending the support for Blazor Server or ([here](https://github.com/getsentry/sentry-dotnet/issues/2021)) for Blazor WebAssembly support ([#3386](https://github.com/getsentry/sentry-dotnet/pull/3386)) -- Added an event scrubber to remove sensitive data from events before sending these to Sentry ([#3419](https://github.com/getsentry/sentry-dotnet/pull/3419)) ### Fixes diff --git a/benchmarks/Sentry.Benchmarks/BenchmarkDotNet.Artifacts/results/Sentry.Benchmarks.EventScrubberBenchmarks-report-github.md b/benchmarks/Sentry.Benchmarks/BenchmarkDotNet.Artifacts/results/Sentry.Benchmarks.EventScrubberBenchmarks-report-github.md deleted file mode 100644 index d01c19ca86..0000000000 --- a/benchmarks/Sentry.Benchmarks/BenchmarkDotNet.Artifacts/results/Sentry.Benchmarks.EventScrubberBenchmarks-report-github.md +++ /dev/null @@ -1,14 +0,0 @@ -``` - -BenchmarkDotNet v0.13.12, macOS Sonoma 14.5 (23F79) [Darwin 23.5.0] -Apple M2 Max, 1 CPU, 12 logical and 12 physical cores -.NET SDK 8.0.204 - [Host] : .NET 6.0.22 (6.0.2223.42425), Arm64 RyuJIT AdvSIMD - Job-OWQIOL : .NET 6.0.22 (6.0.2223.42425), Arm64 RyuJIT AdvSIMD - -InvocationCount=1 UnrollFactor=1 - -``` -| Method | Mean | Error | StdDev | Allocated | -|--------------------------- |---------:|----------:|----------:|----------:| -| ScrubEvent_DefaultDenyList | 8.250 μs | 0.1525 μs | 0.3184 μs | 2.44 KB | diff --git a/benchmarks/Sentry.Benchmarks/EventScrubberBenchmarks.cs b/benchmarks/Sentry.Benchmarks/EventScrubberBenchmarks.cs deleted file mode 100644 index b660303706..0000000000 --- a/benchmarks/Sentry.Benchmarks/EventScrubberBenchmarks.cs +++ /dev/null @@ -1,79 +0,0 @@ -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Engines; -using Sentry.Internal; -using Sentry.Protocol; - -namespace Sentry.Benchmarks; - -[SimpleJob] -public class EventScrubberBenchmarks -{ - private SentryEvent _ev; - private EventScrubber _scrubber; - - [GlobalSetup] - public void GlobalSetup() - { - _scrubber = new EventScrubber(); // executed once per each N value - } - - [IterationSetup] - public void IterationSetup() - { - _ev = new SentryEvent - { - Request = new SentryRequest() - { - Url = "http://absolute.uri/foo", - Method = "POST", - ApiTarget = "apiType", - QueryString = "hello=world", - Cookies = "foo=bar; secret=squirrel", - Headers = { - {"Content-Type", "text/html"}, - {"apikey", "myapikey"} - }, - Env = { - {"REMOTE_ADDR", "192.168.0.1"} - } - }, - SentryExceptionValues = new SentryValues([ - new SentryException - { - Stacktrace = new SentryStackTrace - { - Frames = [new SentryStackFrame()] - } - } - ]), - User = - { - Other = new Dictionary(){ - {"foo", "bar"}, - {"apikey", "myapikey"} - } - } - }; - _ev.SentryExceptions!.First().Stacktrace!.Frames[0].Vars["foo"] = "bar"; - _ev.SentryExceptions!.First().Stacktrace!.Frames[0].Vars["password"] = "42"; - for (var i = 0; i < 10; i++) - { - _ev.AddBreadcrumb(new Breadcrumb("message", "type", new Dictionary - { - {"foo", "bar"}, - {"apikey", "myapikey"} - })); - } - _ev.SetExtras(new Dictionary(){ - {"foo", "bar"}, - {"apikey", "myapikey"}, - {"session", new object()} - }); - } - - [Benchmark] - public void ScrubEvent_DefaultDenyList() - { - _scrubber.ScrubEvent(_ev); - } -} diff --git a/src/Sentry/Breadcrumb.cs b/src/Sentry/Breadcrumb.cs index b2d15ad11a..e7d447edf6 100644 --- a/src/Sentry/Breadcrumb.cs +++ b/src/Sentry/Breadcrumb.cs @@ -10,7 +10,7 @@ namespace Sentry; [DebuggerDisplay("Message: {" + nameof(Message) + "}, Type: {" + nameof(Type) + "}")] public sealed class Breadcrumb : ISentryJsonSerializable { - private readonly Dictionary? _data; + private readonly IReadOnlyDictionary? _data; private readonly string? _message; private bool _sendDefaultPii = true; @@ -59,9 +59,7 @@ public IReadOnlyDictionary? Data x => x.Value.RedactUrl() ) ; - private init => - _data = value as Dictionary - ?? value?.ToDictionary(v => v.Key, v => v.Value); + private init => _data = value; } /// @@ -131,15 +129,6 @@ internal Breadcrumb( Level = level; } - internal void ScrubData(string dataKey, string replacement) - { - if (_data is null) - { - return; - } - _data![dataKey] = replacement; - } - /// public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger) { diff --git a/src/Sentry/Internal/EventScrubber.cs b/src/Sentry/Internal/EventScrubber.cs deleted file mode 100644 index 9a5a1e0bbb..0000000000 --- a/src/Sentry/Internal/EventScrubber.cs +++ /dev/null @@ -1,175 +0,0 @@ -namespace Sentry.Internal; - -using System.Collections.Generic; -using Sentry; - -internal class EventScrubber -{ - internal HashSet Denylist { get; } - internal const string ScrubbedText = "*****"; - internal static readonly string[] DefaultDenylist = - [ - // stolen from relay - "password", - "passwd", - "secret", - "api_key", - "apikey", - "auth", - "credentials", - "mysql_pwd", - "privatekey", - "private_key", - "token", - "ip_address", - "session", - // common names used in web frameworks - "csrftoken", - "sessionid", - "remote_addr", - "x_csrftoken", - "x_forwarded_for", - "set_cookie", - "cookie", - "authorization", - "x_api_key", - "x_forwarded_for", - "x_real_ip", - "aiohttp_session", - "connect.sid", - "csrf_token", - "csrf", - "_csrf", - "_csrf_token", - "PHPSESSID", - "_session", - "symfony", - "user_session", - "_xsrf", - "XSRF-TOKEN" - ]; - - public EventScrubber() - { - Denylist = new(DefaultDenylist, StringComparer.InvariantCultureIgnoreCase); - } - - internal EventScrubber(IEnumerable denylist) - { - Denylist = new(denylist, StringComparer.InvariantCultureIgnoreCase); - } - - private void ScrubStringDictionary(IDictionary dict) - { -#if NETFRAMEWORK - foreach (var key in dict.Keys.ToArray()) -#else - foreach (var key in dict.Keys) -#endif - { - if (Denylist.Contains(key)) - { - dict[key] = ScrubbedText; - } - } - } - - private void ScrubRequest(SentryEvent ev) - { - ScrubStringDictionary(ev.Request.Headers); - - if (ev.Request.Cookies == null) - { - return; - } - - var cookies = ev.Request.Cookies.Split(';'); - foreach (var cookie in cookies) - { - var parts = cookie.Split('='); - if (parts.Length != 2) - { - continue; - } - - var name = parts[0].Trim(); - if (Denylist.Contains(name)) - { - ev.Request.Cookies = ev.Request.Cookies.Replace(cookie, $"{name}={ScrubbedText}"); - } - } - } - - private void ScrubExtra(SentryEvent ev) - { -#if NETFRAMEWORK - foreach (var key in ev.Extra.Keys.ToArray()) -#else - foreach (var key in ev.Extra.Keys) -#endif - { - if (Denylist.Contains(key)) - { - ev.SetExtra(key, ScrubbedText); - } - } - } - - private void ScrubUser(SentryEvent ev) - { - ScrubStringDictionary(ev.User.Other); - } - - private void ScrubBreadcrumbs(SentryEvent ev) - { - foreach (var breadcrumb in ev.Breadcrumbs) - { - if (breadcrumb.Data is not { } data) - { - continue; - } - -#if NETFRAMEWORK - foreach (var key in data.Keys.ToArray()) -#else - foreach (var key in data.Keys) -#endif - { - if (Denylist.Contains(key)) - { - breadcrumb.ScrubData(key, ScrubbedText); - } - } - } - } - - private void ScrubFrames(SentryEvent ev) - { - if (ev.SentryExceptions == null) - { - return; - } - - foreach (var exception in ev.SentryExceptions) - { - if (exception.Stacktrace == null) - { - continue; - } - - foreach (var frame in exception.Stacktrace.Frames) - { - ScrubStringDictionary(frame.Vars); - } - } - } - - public virtual void ScrubEvent(SentryEvent ev) - { - ScrubRequest(ev); - ScrubExtra(ev); - ScrubUser(ev); - ScrubBreadcrumbs(ev); - ScrubFrames(ev); - } -} diff --git a/src/Sentry/SentryClient.cs b/src/Sentry/SentryClient.cs index bd3b157a40..cf211258ba 100644 --- a/src/Sentry/SentryClient.cs +++ b/src/Sentry/SentryClient.cs @@ -319,8 +319,6 @@ private SentryId DoSendEvent(SentryEvent @event, SentryHint? hint, Scope? scope) } } - _options.EventScrubber?.ScrubEvent(processedEvent); - processedEvent = BeforeSend(processedEvent, hint); if (processedEvent == null) // Rejected event { diff --git a/src/Sentry/SentryOptions.cs b/src/Sentry/SentryOptions.cs index fee1aed1b2..35a2fe3a31 100644 --- a/src/Sentry/SentryOptions.cs +++ b/src/Sentry/SentryOptions.cs @@ -1761,62 +1761,4 @@ internal void SetupLogging() // In the future, this will most likely contain process ID return TryGetDsnSpecificCacheDirectoryPath(); } - - private EventScrubber? _eventScrubber; - internal EventScrubber? EventScrubber - { - get - { - if (_denyList.Count == 0) - { - return null; - } - _eventScrubber ??= new EventScrubber(_denyList); // Instantiate and cache the scrubber only if needed - return _eventScrubber; - } - set => _eventScrubber = value; - } - - private List _denyList = EventScrubber.DefaultDenylist.ToList(); - - /// - /// By default, sensitive data is scrubbed from events that get sent to Sentry. This option allows you to disable - /// this default behavior. Alternatively you can use or - /// to configure scrubbing behaviour. - /// - public void DisableScrubbing() - { - _denyList = []; - } - - /// - /// - /// By default, sensitive data is scrubbed from events that get sent to Sentry using a "deny list" that contains - /// the names of various keys that are commonly used to store sensitive data. If items from the deny list are found - /// in Cookies, Headers, StackFrames etc. then the value for these items will be scrubbed and replaced with `*****`. - /// - /// - /// This method allows you to override the default deny list that Sentry uses with your own list of strings used to - /// identify potentially sensitive data. - /// - /// - public void ScrubData(IEnumerable denyList) - { - _denyList = denyList.ToList(); - } - - /// - /// - /// By default, sensitive data is scrubbed from events that get sent to Sentry using a "deny list" that contains - /// the names of various keys that are commonly used to store sensitive data. If items from the deny list are found - /// in Cookies, Headers, StackFrames etc. then the value for these items will be scrubbed and replaced with `*****`. - /// - /// - /// This method allows you to modify the list of strings used to identify potentially sensitive data. - /// - /// - public void ScrubData(Action> configureDenyList) - { - configureDenyList.Invoke(_denyList); - } } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt index d92ee36214..01fe515080 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt @@ -732,7 +732,6 @@ namespace Sentry public void DisableAppDomainUnhandledExceptionCapture() { } public void DisableDiagnosticSourceIntegration() { } public void DisableDuplicateEventDetection() { } - public void DisableScrubbing() { } public void DisableUnobservedTaskExceptionCapture() { } public void DisableWinUiUnhandledExceptionIntegration() { } public System.Collections.Generic.IEnumerable GetAllEventProcessors() { } @@ -746,8 +745,6 @@ namespace Sentry where TIntegration : Sentry.Integrations.ISdkIntegration { } public void RemoveTransactionProcessor() where TProcessor : Sentry.Extensibility.ISentryTransactionProcessor { } - public void ScrubData(System.Action> configureDenyList) { } - public void ScrubData(System.Collections.Generic.IEnumerable denyList) { } public void SetBeforeBreadcrumb(System.Func beforeBreadcrumb) { } public void SetBeforeBreadcrumb(System.Func beforeBreadcrumb) { } public void SetBeforeSend(System.Func beforeSend) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt index d92ee36214..01fe515080 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt @@ -732,7 +732,6 @@ namespace Sentry public void DisableAppDomainUnhandledExceptionCapture() { } public void DisableDiagnosticSourceIntegration() { } public void DisableDuplicateEventDetection() { } - public void DisableScrubbing() { } public void DisableUnobservedTaskExceptionCapture() { } public void DisableWinUiUnhandledExceptionIntegration() { } public System.Collections.Generic.IEnumerable GetAllEventProcessors() { } @@ -746,8 +745,6 @@ namespace Sentry where TIntegration : Sentry.Integrations.ISdkIntegration { } public void RemoveTransactionProcessor() where TProcessor : Sentry.Extensibility.ISentryTransactionProcessor { } - public void ScrubData(System.Action> configureDenyList) { } - public void ScrubData(System.Collections.Generic.IEnumerable denyList) { } public void SetBeforeBreadcrumb(System.Func beforeBreadcrumb) { } public void SetBeforeBreadcrumb(System.Func beforeBreadcrumb) { } public void SetBeforeSend(System.Func beforeSend) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index b30a752b6a..45c5501bba 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -733,7 +733,6 @@ namespace Sentry public void DisableAppDomainUnhandledExceptionCapture() { } public void DisableDiagnosticSourceIntegration() { } public void DisableDuplicateEventDetection() { } - public void DisableScrubbing() { } public void DisableSystemDiagnosticsMetricsIntegration() { } public void DisableUnobservedTaskExceptionCapture() { } public void DisableWinUiUnhandledExceptionIntegration() { } @@ -748,8 +747,6 @@ namespace Sentry where TIntegration : Sentry.Integrations.ISdkIntegration { } public void RemoveTransactionProcessor() where TProcessor : Sentry.Extensibility.ISentryTransactionProcessor { } - public void ScrubData(System.Action> configureDenyList) { } - public void ScrubData(System.Collections.Generic.IEnumerable denyList) { } public void SetBeforeBreadcrumb(System.Func beforeBreadcrumb) { } public void SetBeforeBreadcrumb(System.Func beforeBreadcrumb) { } public void SetBeforeSend(System.Func beforeSend) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index 852a3e6c9b..5b9839ef06 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -730,7 +730,6 @@ namespace Sentry public void DisableAppDomainUnhandledExceptionCapture() { } public void DisableDuplicateEventDetection() { } public void DisableNetFxInstallationsIntegration() { } - public void DisableScrubbing() { } public void DisableUnobservedTaskExceptionCapture() { } public System.Collections.Generic.IEnumerable GetAllEventProcessors() { } public System.Collections.Generic.IEnumerable GetAllExceptionProcessors() { } @@ -743,8 +742,6 @@ namespace Sentry where TIntegration : Sentry.Integrations.ISdkIntegration { } public void RemoveTransactionProcessor() where TProcessor : Sentry.Extensibility.ISentryTransactionProcessor { } - public void ScrubData(System.Action> configureDenyList) { } - public void ScrubData(System.Collections.Generic.IEnumerable denyList) { } public void SetBeforeBreadcrumb(System.Func beforeBreadcrumb) { } public void SetBeforeBreadcrumb(System.Func beforeBreadcrumb) { } public void SetBeforeSend(System.Func beforeSend) { } diff --git a/test/Sentry.Tests/Internals/EventScrubberTests.ScrubEvent_ScrubsRequest.verified.txt b/test/Sentry.Tests/Internals/EventScrubberTests.ScrubEvent_ScrubsRequest.verified.txt deleted file mode 100644 index bd932e5781..0000000000 --- a/test/Sentry.Tests/Internals/EventScrubberTests.ScrubEvent_ScrubsRequest.verified.txt +++ /dev/null @@ -1,18 +0,0 @@ -{ - Url: http://absolute.uri/foo, - Method: POST, - ApiTarget: apiType, - Data: -{ - "foo": "bar" -}, - QueryString: hello=world, - Cookies: foo=bar;secret=*****, - Headers: { - apikey: *****, - Content-Type: text/html - }, - Env: { - REMOTE_ADDR: 192.168.0.1 - } -} \ No newline at end of file diff --git a/test/Sentry.Tests/Internals/EventScrubberTests.cs b/test/Sentry.Tests/Internals/EventScrubberTests.cs deleted file mode 100644 index 5b0d74f0e7..0000000000 --- a/test/Sentry.Tests/Internals/EventScrubberTests.cs +++ /dev/null @@ -1,146 +0,0 @@ -#if !__MOBILE__ -namespace Sentry.Tests.Internals; - -[UsesVerify] -public class EventScrubberTests -{ - [Fact] - public Task ScrubEvent_ScrubsRequest() - { - // Arrange - const string data = """ - { - "foo": "bar" - } - """; - var ev = new SentryEvent - { - Request = new SentryRequest() - { - Url = "http://absolute.uri/foo", - Method = "POST", - ApiTarget = "apiType", - Data = data, - QueryString = "hello=world", - Cookies = "foo=bar; secret=squirrel", - Headers = { - {"Content-Type", "text/html"}, - {"apikey", "myapikey"} - }, - Env = { - {"REMOTE_ADDR", "192.168.0.1"} - } - } - }; - - // Act - var scrubber = new EventScrubber(); - scrubber.ScrubEvent(ev); - - // Assert - return Verify(ev.Request); - } - - [Fact] - public void ScrubEvent_ScrubsExtra() - { - // Arrange - var ev = new SentryEvent(); - ev.SetExtras(new Dictionary(){ - {"foo", "bar"}, - {"apikey", "myapikey"}, - {"session", new object()} - }); - - // Act - var scrubber = new EventScrubber(); - scrubber.ScrubEvent(ev); - - // Assert - ev.Extra["foo"].Should().Be("bar"); - ev.Extra["apikey"].Should().Be(EventScrubber.ScrubbedText); - ev.Extra["session"].Should().Be(EventScrubber.ScrubbedText); - } - - [Fact] - public void ScrubEvent_ScrubsUser() - { - // Arrange - var ev = new SentryEvent - { - User = - { - Other = new Dictionary(){ - {"foo", "bar"}, - {"apikey", "myapikey"} - } - } - }; - - // Act - var scrubber = new EventScrubber(); - scrubber.ScrubEvent(ev); - - // Assert - ev.User.Other["foo"].Should().Be("bar"); - ev.User.Other["apikey"].Should().Be(EventScrubber.ScrubbedText); - } - - [Fact] - public void ScrubEvent_ScrubsBreadcrumbs() - { - // Arrange - var ev = new SentryEvent(); - ev.AddBreadcrumb(new Breadcrumb("message", "type", new Dictionary - { - {"foo", "bar"}, - {"apikey", "myapikey"} - })); - - // Act - var scrubber = new EventScrubber(); - scrubber.ScrubEvent(ev); - - // Assert - var breadcrumb = ev.Breadcrumbs.FirstOrDefault(); - breadcrumb.Should().NotBeNull(); - using (new AssertionScope()) - { - breadcrumb!.Message.Should().Be("message"); - breadcrumb.Type.Should().Be("type"); - breadcrumb.Data!["foo"].Should().Be("bar"); - breadcrumb.Data!["apikey"].Should().Be(EventScrubber.ScrubbedText); - } - } - - [Fact] - public void ScrubEvent_ScrubsStackFrames() - { - // Arrange - var ev = new SentryEvent - { - SentryExceptionValues = new SentryValues([ - new SentryException - { - Stacktrace = new SentryStackTrace - { - Frames = [new SentryStackFrame()] - } - } - ]) - }; - ev.SentryExceptions!.First().Stacktrace!.Frames[0].Vars["foo"] = "bar"; - ev.SentryExceptions!.First().Stacktrace!.Frames[0].Vars["password"] = "42"; - - // Act - var scrubber = new EventScrubber(); - scrubber.ScrubEvent(ev); - - // Assert - var exception = ev.SentryExceptions!.FirstOrDefault(); - var frame = exception!.Stacktrace!.Frames.FirstOrDefault(); - frame!.InternalVars!["foo"].Should().Be("bar"); - frame!.InternalVars!["password"].Should().Be(EventScrubber.ScrubbedText); - } -} -#endif diff --git a/test/Sentry.Tests/SentryClientTests.cs b/test/Sentry.Tests/SentryClientTests.cs index 92f92f6460..3c9d72ca7a 100644 --- a/test/Sentry.Tests/SentryClientTests.cs +++ b/test/Sentry.Tests/SentryClientTests.cs @@ -17,12 +17,10 @@ private class Fixture public IBackgroundWorker BackgroundWorker { get; set; } = Substitute.For(); public IClientReportRecorder ClientReportRecorder { get; } = Substitute.For(); public ISessionManager SessionManager { get; set; } = Substitute.For(); - public EventScrubber EventScrubber { get; set; } = Substitute.For(); public Fixture() { SentryOptions.ClientReportRecorder = ClientReportRecorder; - SentryOptions.EventScrubber = EventScrubber; BackgroundWorker.EnqueueEnvelope(Arg.Any()).Returns(true); } @@ -1541,18 +1539,4 @@ public void CaptureEvent_ActiveSession_UnhandledExceptionSessionEndedAsCrashed() // Assert _fixture.SessionManager.Received().EndSession(SessionEndStatus.Crashed); } - - [Fact] - public void CaptureEvent_ScrubsData() - { - // Arrange - var sentryEvent = new SentryEvent(); - var sut = _fixture.GetSut(); - - // Act - var actualId = sut.CaptureEvent(sentryEvent); - - // Assert - _fixture.EventScrubber.Received(1).ScrubEvent(sentryEvent); - } } diff --git a/test/Sentry.Tests/SentryOptionsTests.cs b/test/Sentry.Tests/SentryOptionsTests.cs index 9d8af72ca4..2c1167a819 100644 --- a/test/Sentry.Tests/SentryOptionsTests.cs +++ b/test/Sentry.Tests/SentryOptionsTests.cs @@ -738,46 +738,4 @@ public void Integrations_Includes_MajorSystemPrefixes(string expected) var sut = new SentryOptions(); Assert.Contains(sut.InAppExclude!, e => e.ToString() == expected); } - - [Fact] - public void DisableScrubbing_EventScrubberIsNull() - { - // Arrange - var sut = new SentryOptions(); - - // Act - sut.DisableScrubbing(); - - // Assert - Assert.Null(sut.EventScrubber); - } - - [Fact] - public void ScrubData_CustomList() - { - // Arrange - var sut = new SentryOptions(); - List denyList = ["foo", "bar"]; - - // Act - sut.ScrubData(denyList); - - // Assert - Assert.NotNull(sut.EventScrubber); - sut.EventScrubber.Denylist.Should().BeEquivalentTo(denyList); - } - - [Fact] - public void ScrubData_RemoveItem() - { - // Arrange - var sut = new SentryOptions(); - - // Act - sut.ScrubData(denyList => denyList.Remove("password")); - - // Assert - Assert.NotNull(sut.EventScrubber); - sut.EventScrubber.Denylist.Should().NotContain("password"); - } }