< Summary

Information
Class: AspxLint.Core.Rules.Sec001ViewStateMacFalse
Assembly: AspxLint.Core
File(s): D:\a\claude-aspx-lint\claude-aspx-lint\src\AspxLint.Core\Rules\Sec001ViewStateMacFalse.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 33
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_Name()100%11100%
get_Severity()100%11100%
get_Description()100%11100%
get_HasFix()100%11100%
.cctor()100%11100%
Fix(...)100%11100%

File(s)

D:\a\claude-aspx-lint\claude-aspx-lint\src\AspxLint.Core\Rules\Sec001ViewStateMacFalse.cs

#LineLine coverage
 1using System.Text.RegularExpressions;
 2
 3namespace AspxLint.Core.Rules;
 4
 5public sealed class Sec001ViewStateMacFalse : IRule
 6{
 2037    public string Id => "SEC-001";
 288    public string Name => "EnableViewStateMac=\"false\" — risque de securite";
 259    public Severity Severity => Severity.Error;
 10    public string Description =>
 2511        "Desactiver EnableViewStateMac expose a des attaques par injection de ViewState. Cette option ne doit jamais etr
 4612    public bool HasFix => true;
 13
 514    private static readonly Regex DetectRegex = new(
 515        @"EnableViewStateMac\s*=\s*[""']?false[""']?",
 516        RegexOptions.IgnoreCase | RegexOptions.Compiled);
 17
 18    public IEnumerable<Issue> Detect(string content, string[] lines, RuleContext ctx)
 19    {
 20        for (int i = 0; i < lines.Length; i++)
 21        {
 22            foreach (Match m in DetectRegex.Matches(lines[i]))
 23            {
 24                yield return new Issue(Id, Name, Severity,
 25                    i + 1, m.Index + 1, m.Value,
 26                    "Retirer ou repasser EnableViewStateMac a true.");
 27            }
 28        }
 29    }
 30
 31    public string? Fix(string content, RuleContext ctx) =>
 2132        DetectRegex.Replace(content, "EnableViewStateMac=\"true\"");
 33}