diff --git a/src/SQLInsight.Core/SyntheticChecks/SyntheticCheckDefinitions.cs b/src/SQLInsight.Core/SyntheticChecks/SyntheticCheckDefinitions.cs
index 7b08d2d..e4a2c94 100644
--- a/src/SQLInsight.Core/SyntheticChecks/SyntheticCheckDefinitions.cs
+++ b/src/SQLInsight.Core/SyntheticChecks/SyntheticCheckDefinitions.cs
@@ -162,6 +162,9 @@ public static class SyntheticCheckLimits
public static class SyntheticCheckValidation
{
+ /// What API v1 shows instead of a login or a URL query (a value sent back unchanged is refused).
+ public const string RedactedValue = "[udeladt]";
+
/// The longest HTTP address a check may have.
public const int MaxUrlLength = 2000;
@@ -253,6 +256,12 @@ public static class SyntheticCheckValidation
return $"Adressen må højst være {MaxUrlLength} tegn.";
}
+ // API v1 shows the query as [udeladt]: a GET sent back as it is must not replace the real address.
+ if (Uri.UnescapeDataString(url.Query).Contains(RedactedValue, StringComparison.Ordinal))
+ {
+ return "Adressen indeholder [udeladt] fra API'et. Angiv hele adressen igen.";
+ }
+
if (!string.IsNullOrEmpty(url.UserInfo))
{
return "Adressen må ikke indeholde brugernavn eller adgangskode.";
@@ -283,6 +292,11 @@ public static class SyntheticCheckValidation
return "Angiv SQL-login'et (højst 128 tegn).";
}
+ if (settings.UserName == RedactedValue)
+ {
+ return "Login'et er [udeladt] fra API'et. Angiv det rigtige login igen.";
+ }
+
if (settings.Encryption is not ("Mandatory" or "Optional"))
{
return "Kryptering skal være Mandatory eller Optional.";
diff --git a/tests/SQLInsight.Core.Tests/SyntheticCheckTests.cs b/tests/SQLInsight.Core.Tests/SyntheticCheckTests.cs
index a38dd7c..85ef41f 100644
--- a/tests/SQLInsight.Core.Tests/SyntheticCheckTests.cs
+++ b/tests/SQLInsight.Core.Tests/SyntheticCheckTests.cs
@@ -68,6 +68,14 @@ public class SyntheticCheckTests
Assert.Equal(@"sql01\AX / AXDB", new SyntheticCheckSettings { Server = @"sql01\AX", Database = "AXDB" }.Target(SyntheticCheckKind.Sql));
}
+ [Fact]
+ public void Redacted_values_from_the_api_are_not_saved_back()
+ {
+ Assert.Contains("[udeladt]", Validate(SyntheticCheckKind.Sql, new() { Server = "sql01", Authentication = "SqlLogin", UserName = "[udeladt]" }), StringComparison.Ordinal);
+ Assert.Contains("[udeladt]", Validate(SyntheticCheckKind.Http, new() { Url = new Uri("https://ep/side?[udeladt]") }), StringComparison.Ordinal);
+ Assert.Null(Validate(SyntheticCheckKind.Http, new() { Url = new Uri("https://ep/side?a=1") }));
+ }
+
[Fact]
public void A_sql_password_is_bound_to_the_server_and_login()
{