< Summary

Line coverage
75%
Covered lines: 6
Uncovered lines: 2
Coverable lines: 8
Total lines: 113
Line coverage: 75%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: SensitiveWordsRegex()100%11100%
File 2: Info(...)100%11100%
File 2: Warning(...)100%210%
File 2: Error(...)100%11100%
File 2: SafeMessage(...)50%4475%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Platform.Integration/obj/Release/net10.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs

File '/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Platform.Integration/obj/Release/net10.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs' does not exist (any more).

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Platform.Integration/Services/PlatformDiagnosticSanitizer.cs

#LineLine coverage
 1using System.Text.RegularExpressions;
 2using Elsa.Platform.Integration.Models;
 3
 4namespace Elsa.Platform.Integration.Services;
 5
 6public static partial class PlatformDiagnosticSanitizer
 7{
 8    public static PlatformDiagnostic Info(string code, string message) =>
 19        new(code, PlatformDiagnosticSeverity.Info, SafeMessage(message));
 10
 11    public static PlatformDiagnostic Warning(string code, string message) =>
 012        new(code, PlatformDiagnosticSeverity.Warning, SafeMessage(message));
 13
 14    public static PlatformDiagnostic Error(string code, string message) =>
 115        new(code, PlatformDiagnosticSeverity.Error, SafeMessage(message));
 16
 17    public static string SafeMessage(string? message)
 18    {
 219        if (string.IsNullOrWhiteSpace(message))
 020            return "No diagnostic details were provided.";
 21
 222        var safe = SensitiveWordsRegex().Replace(message, "[redacted]");
 223        return safe.Length <= 500 ? safe : safe[..500];
 24    }
 25
 26    [GeneratedRegex("(api[-_ ]?key|bearer|client[-_ ]?secret|password|private[-_ ]?key|secret|token)", RegexOptions.Igno
 27    private static partial Regex SensitiveWordsRegex();
 28}