コード例 #1
0
        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);
        }
コード例 #2
0
        static AwsCredentialsValidator()
        {
            RegexEngine = RE2Regex.Instance;
            Instance    = new AwsCredentialsValidator();

            RegexEngine.IsMatch(string.Empty, AwsUserExpression);
        }
コード例 #3
0
 public static bool IsMatch(this IRegex c, string pattern)
 {
     return(c.IsMatch(pattern, RegexOptions.None));
 }