From c3fd492bfe088cba7837f5f2e80afd6a48815045 Mon Sep 17 00:00:00 2001
From: Roman Balabukh <45488773+rbalabukh@users.noreply.github.com>
Date: Fri, 10 Jul 2020 10:49:41 +0300
Subject: [PATCH] #128
---
README.md | 12 +++---
src/Sharpbrake.Client/AirbrakeConfig.cs | 8 ++--
src/Sharpbrake.Client/NoticeBuilder.cs | 4 +-
src/Sharpbrake.Log4net/AirbrakeAppender.cs | 8 ++--
src/Sharpbrake.NLog/AirbrakeTarget.cs | 40 +++++++++----------
.../AirbrakeConfigTests.cs | 12 +++---
6 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/README.md b/README.md
index 2f54197..26aa8fe 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ Key features
* Support for environments[[link](#environment)]
* Support for proxying[[link](#proxy)]
* Filters support (filter out sensitive or unwanted data that shouldn't be sent
- to our servers)[[link](#blacklistkeys)]
+ to our servers)[[link](#blocklist)]
* Ability to ignore errors from specified environments[[link](#ignoreenvironments)]
* Severity support[[link](#setting-severity)]
@@ -269,7 +269,7 @@ var config = new AirbrakeConfig {
};
```
-#### BlacklistKeys
+#### Blocklist
Specifies which keys in the payload (parameters, session data, environment data,
etc.) should be filtered. Before sending an error, filtered keys will be
@@ -277,7 +277,7 @@ substituted with the `[Filtered]` label.
```csharp
var config = new AirbrakeConfig {
- BlacklistKeys = new List { "password", "creditCard", "email" }
+ Blocklist = new List { "password", "creditCard", "email" }
};
// The dashboard will display this parameter as filtered, but other values won't
@@ -288,11 +288,11 @@ var config = new AirbrakeConfig {
// creditCard: '[Filtered]' }
```
-**Note:** `BlacklistKeys` has higher priority than `WhitelistKeys`. It means
+**Note:** `Blocklist` has higher priority than `Allowlist`. It means
that if you set the same value into both blacklist and whitelist - that value
will be filtered out.
-#### WhitelistKeys
+#### Allowlist
Specifies which keys in the payload (parameters, session data, environment data,
etc.) should _not_ be filtered. All other keys will be substituted with the
@@ -300,7 +300,7 @@ etc.) should _not_ be filtered. All other keys will be substituted with the
```csharp
var config = new AirbrakeConfig {
- WhitelistKeys = new List { "user", "email", "accountId" }
+ Allowlist = new List { "user", "email", "accountId" }
};
// The dashboard will display this parameter as is, but all other values will be
diff --git a/src/Sharpbrake.Client/AirbrakeConfig.cs b/src/Sharpbrake.Client/AirbrakeConfig.cs
index 33c4a2e..7a12bd3 100644
--- a/src/Sharpbrake.Client/AirbrakeConfig.cs
+++ b/src/Sharpbrake.Client/AirbrakeConfig.cs
@@ -67,12 +67,12 @@ public class AirbrakeConfig
/// List of the parameters which will not be filtered.
/// If count of parameters is not zero - all not listed parameters will be filtered.
///
- public IList WhitelistKeys { get; set; }
+ public IList Allowlist { get; set; }
///
/// List of the parameters which will be filtered out.
///
- public IList BlacklistKeys { get; set; }
+ public IList Blocklist { get; set; }
///
/// Formatting information for error messages.
@@ -85,8 +85,8 @@ public class AirbrakeConfig
public AirbrakeConfig()
{
IgnoreEnvironments = new List();
- WhitelistKeys = new List();
- BlacklistKeys = new List();
+ Allowlist = new List();
+ Blocklist = new List();
}
///
diff --git a/src/Sharpbrake.Client/NoticeBuilder.cs b/src/Sharpbrake.Client/NoticeBuilder.cs
index bf7ea83..537879a 100644
--- a/src/Sharpbrake.Client/NoticeBuilder.cs
+++ b/src/Sharpbrake.Client/NoticeBuilder.cs
@@ -192,8 +192,8 @@ public static void SetHttpContext(this Notice notice, IHttpContext httpContext,
}
else
{
- var blackListRegex = Utils.CompileRegex(config.BlacklistKeys);
- var whiteListRegex = Utils.CompileRegex(config.WhitelistKeys);
+ var blackListRegex = Utils.CompileRegex(config.Blocklist);
+ var whiteListRegex = Utils.CompileRegex(config.Allowlist);
notice.Params = Utils.FilterParameters(httpContext.Parameters, blackListRegex, whiteListRegex);
notice.EnvironmentVars = Utils.FilterParameters(httpContext.EnvironmentVars, blackListRegex, whiteListRegex);
diff --git a/src/Sharpbrake.Log4net/AirbrakeAppender.cs b/src/Sharpbrake.Log4net/AirbrakeAppender.cs
index 4cd7e4f..1ef8ca1 100644
--- a/src/Sharpbrake.Log4net/AirbrakeAppender.cs
+++ b/src/Sharpbrake.Log4net/AirbrakeAppender.cs
@@ -71,12 +71,12 @@ public class AirbrakeAppender : AppenderSkeleton
/// Comma-separated list of parameters which will not be filtered.
/// If count of parameters is not zero - all not listed parameters will be filtered.
///
- public string WhitelistKeys { get; set; }
+ public string Allowlist { get; set; }
///
/// Comma-separated list of parameters which will be filtered out.
///
- public string BlacklistKeys { get; set; }
+ public string Blocklist { get; set; }
///
/// Initializes the appender based on the options set.
@@ -97,8 +97,8 @@ public override void ActivateOptions()
ProxyUsername = ProxyUsername,
ProxyPassword = ProxyPassword,
IgnoreEnvironments = Utils.ParseParameter(IgnoreEnvironments),
- WhitelistKeys = Utils.ParseParameter(WhitelistKeys),
- BlacklistKeys = Utils.ParseParameter(BlacklistKeys)
+ Allowlist = Utils.ParseParameter(Allowlist),
+ Blocklist = Utils.ParseParameter(Blocklist)
};
Notifier = new AirbrakeNotifier(config);
diff --git a/src/Sharpbrake.NLog/AirbrakeTarget.cs b/src/Sharpbrake.NLog/AirbrakeTarget.cs
index 487714c..d5a924a 100644
--- a/src/Sharpbrake.NLog/AirbrakeTarget.cs
+++ b/src/Sharpbrake.NLog/AirbrakeTarget.cs
@@ -1,7 +1,7 @@
using System;
using NLog;
using NLog.Config;
-using NLog.Layouts;
+using NLog.Layouts;
using NLog.Targets;
using Sharpbrake.Client;
using Sharpbrake.Client.Model;
@@ -74,16 +74,16 @@ public class AirbrakeTarget : TargetWithLayout
/// Comma-separated list of parameters which will not be filtered.
/// If count of parameters is not zero - all not listed parameters will be filtered.
///
- public string WhitelistKeys { get; set; }
+ public string Allowlist { get; set; }
///
/// Comma-separated list of parameters which will be filtered out.
///
- public string BlacklistKeys { get; set; }
+ public string Blocklist { get; set; }
public AirbrakeTarget()
- {
- Layout = "${message}";
+ {
+ Layout = "${message}";
}
///
@@ -132,24 +132,24 @@ protected override void InitializeTarget()
ProxyUsername = RenderSimpleLayout(ProxyUsername, nameof(ProxyUsername)),
ProxyPassword = RenderSimpleLayout(ProxyPassword, nameof(ProxyPassword)),
IgnoreEnvironments = Utils.ParseParameter(RenderSimpleLayout(IgnoreEnvironments, nameof(IgnoreEnvironments))),
- WhitelistKeys = Utils.ParseParameter(RenderSimpleLayout(WhitelistKeys, nameof(WhitelistKeys))),
- BlacklistKeys = Utils.ParseParameter(RenderSimpleLayout(BlacklistKeys, nameof(BlacklistKeys))),
+ Allowlist = Utils.ParseParameter(RenderSimpleLayout(Allowlist, nameof(Allowlist))),
+ Blocklist = Utils.ParseParameter(RenderSimpleLayout(Blocklist, nameof(Blocklist))),
};
Notifier = new AirbrakeNotifier(config);
- }
-
- private string RenderSimpleLayout(string simpleLayout, string propertyName)
- {
- try
- {
- return string.IsNullOrEmpty(simpleLayout) ? string.Empty : new SimpleLayout(simpleLayout).Render(LogEventInfo.CreateNullEvent());
- }
- catch
- {
- return simpleLayout;
- }
- }
+ }
+
+ private string RenderSimpleLayout(string simpleLayout, string propertyName)
+ {
+ try
+ {
+ return string.IsNullOrEmpty(simpleLayout) ? string.Empty : new SimpleLayout(simpleLayout).Render(LogEventInfo.CreateNullEvent());
+ }
+ catch
+ {
+ return simpleLayout;
+ }
+ }
///
diff --git a/test/Sharpbrake.Client.Tests/AirbrakeConfigTests.cs b/test/Sharpbrake.Client.Tests/AirbrakeConfigTests.cs
index 75fc9b2..8155f17 100644
--- a/test/Sharpbrake.Client.Tests/AirbrakeConfigTests.cs
+++ b/test/Sharpbrake.Client.Tests/AirbrakeConfigTests.cs
@@ -15,8 +15,8 @@ public void Ctor_ShouldInitializeListBasedProperties()
Assert.NotNull(config);
Assert.NotNull(config.IgnoreEnvironments);
- Assert.NotNull(config.WhitelistKeys);
- Assert.NotNull(config.BlacklistKeys);
+ Assert.NotNull(config.Allowlist);
+ Assert.NotNull(config.Blocklist);
}
[Fact]
@@ -28,7 +28,7 @@ public void Load_ShouldInitializeConfigFromDictionary()
{"Airbrake:ProjectKey", "e2046ca6e4e9214b24ad252e3c99a0f6"},
{"Airbrake:Environment", "test"},
{"IgnoreEnvironments", "test,dev" },
- {"BlacklistKeys", "password" },
+ {"Blocklist", "password" },
{"Environment", "dev"},
{"NonExistingProperty", "value"}
};
@@ -45,9 +45,9 @@ public void Load_ShouldInitializeConfigFromDictionary()
Assert.True(config.IgnoreEnvironments[0] == "test");
Assert.True(config.IgnoreEnvironments[1] == "dev");
- Assert.NotNull(config.BlacklistKeys);
- Assert.True(config.BlacklistKeys.Count == 1);
- Assert.True(config.BlacklistKeys[0] == "password");
+ Assert.NotNull(config.Blocklist);
+ Assert.True(config.Blocklist.Count == 1);
+ Assert.True(config.Blocklist[0] == "password");
}
}
}