public override AnalysisApplicability CanAnalyze(AnalyzeContext context, out string reasonIfNotApplicable) { string filePath = context.TargetUri.GetFilePath(); reasonIfNotApplicable = null; foreach (MatchExpression matchExpression in _matchExpressions) { if (!string.IsNullOrEmpty(matchExpression.FileNameDenyRegex) && _engine.IsMatch(filePath, matchExpression.FileNameDenyRegex)) { continue; } if (!string.IsNullOrEmpty(matchExpression.FileNameAllowRegex) && !_engine.IsMatch(filePath, matchExpression.FileNameAllowRegex)) { continue; } reasonIfNotApplicable = null; return(AnalysisApplicability.ApplicableToSpecifiedTarget); } reasonIfNotApplicable = SpamResources.TargetDoesNotMeetFileNameCriteria; return(AnalysisApplicability.NotApplicableToSpecifiedTarget); }
static AwsCredentialsValidator() { RegexEngine = RE2Regex.Instance; Instance = new AwsCredentialsValidator(); RegexEngine.IsMatch(string.Empty, AwsUserExpression); }
public static bool IsMatch(this IRegex c, string pattern) { return(c.IsMatch(pattern, RegexOptions.None)); }