lint method

List<DVWafFinding> lint()

Rules that match every request, and rules that have matched nothing for staleAfter: a rule nobody can explain is a rule nobody dares delete.

Matches are remembered for the life of this DVWaf; a rule that has not matched is measured from when it was constructed.

Implementation

List<DVWafFinding> lint() {
  final now = _clock();
  return <DVWafFinding>[
    for (final rule in rules)
      if (rule.matchesEverything)
        DVWafFinding(rule.name, 'matches every request')
      else if (now.difference(_lastMatched[rule.name] ?? _since) >
          staleAfter)
        DVWafFinding(
          rule.name,
          'has matched nothing for ${staleAfter.inDays} days',
        ),
  ];
}