From 71aa0a3ecf673c77aaa98aa672c1d8360bd7a57a Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Tue, 4 May 2021 22:49:25 +0200 Subject: [PATCH] Review --- src/Elastic.Apm/Filters/ErrorContextSanitizerFilter.cs | 5 ++--- src/Elastic.Apm/Filters/HeaderDictionarySanitizerFilter.cs | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Elastic.Apm/Filters/ErrorContextSanitizerFilter.cs b/src/Elastic.Apm/Filters/ErrorContextSanitizerFilter.cs index b71ed3309..089edff61 100644 --- a/src/Elastic.Apm/Filters/ErrorContextSanitizerFilter.cs +++ b/src/Elastic.Apm/Filters/ErrorContextSanitizerFilter.cs @@ -22,10 +22,9 @@ public IError Filter(IError error) { if (realError.Context.Request?.Headers != null && realError.ConfigSnapshot != null) { - foreach (var key in realError.Context?.Request?.Headers?.Keys.ToList()) + foreach (var key in realError.Context?.Request?.Headers?.Keys) { - if (WildcardMatcher.IsAnyMatch(realError.ConfigSnapshot.SanitizeFieldNames, key) - && realError.Context.Request.Headers[key] != Consts.Redacted) + if (WildcardMatcher.IsAnyMatch(realError.ConfigSnapshot.SanitizeFieldNames, key)) realError.Context.Request.Headers[key] = Consts.Redacted; } } diff --git a/src/Elastic.Apm/Filters/HeaderDictionarySanitizerFilter.cs b/src/Elastic.Apm/Filters/HeaderDictionarySanitizerFilter.cs index e78be0c3b..729b641f4 100644 --- a/src/Elastic.Apm/Filters/HeaderDictionarySanitizerFilter.cs +++ b/src/Elastic.Apm/Filters/HeaderDictionarySanitizerFilter.cs @@ -22,10 +22,9 @@ public ITransaction Filter(ITransaction transaction) { if (realTransaction.IsContextCreated && realTransaction.Context.Request?.Headers != null) { - foreach (var key in realTransaction.Context?.Request?.Headers?.Keys.ToList()) + foreach (var key in realTransaction.Context?.Request?.Headers?.Keys) { - if (WildcardMatcher.IsAnyMatch(realTransaction.ConfigSnapshot.SanitizeFieldNames, key) - && realTransaction.Context.Request.Headers[key] != Consts.Redacted) + if (WildcardMatcher.IsAnyMatch(realTransaction.ConfigSnapshot.SanitizeFieldNames, key)) realTransaction.Context.Request.Headers[key] = Consts.Redacted; } }