/// <summary> /// Part of post processing to test for matches against app defined properties /// defined in MetaData class /// Exludes a match if specified in preferences as a counted tag with exclude true /// </summary> /// <param name="matchRecord"></param> public bool AddStandardProperties(ref MatchRecord matchRecord) { bool includeAsMatch = true; //testing for presence of a tag against the specified set in preferences for report org foreach (string key in _propertyTagSearchPatterns.Keys) { var tagPatternRegex = new Regex(_propertyTagSearchPatterns[key], RegexOptions.IgnoreCase); if (matchRecord.Issue.Rule.Tags.Any(v => tagPatternRegex.IsMatch(v))) { KeyedPropertyLists[key].Add(matchRecord.TextSample); } } // Author etc. or STANDARD METADATA properties we capture from any supported file type; others just captured as general tag matches... if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Author"))) { this.Authors = ExtractValue(matchRecord.TextSample); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Publisher"))) { this.Authors = ExtractValue(matchRecord.TextSample); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Description"))) { this.Description = ExtractValue(matchRecord.TextSample); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Name"))) { this.ApplicationName = ExtractValue(matchRecord.TextSample); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Version"))) { this.SourceVersion = ExtractValue(matchRecord.TextSample); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Target.Processor"))) { this.CPUTargets.Add(ExtractValue(matchRecord.TextSample).ToLower()); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Output.Type"))) { this.Outputs.Add(ExtractValue(matchRecord.TextSample).ToLower()); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Platform.OS"))) { this.OSTargets.Add(ExtractValue(matchRecord.TextSample).ToLower()); } //Special handling; attempt to detect app types...review for multiple pattern rule limitation String solutionType = Utils.DetectSolutionType(matchRecord); if (!string.IsNullOrEmpty(solutionType)) { AppTypes.Add(solutionType); } //Update metric counters for default or user specified tags foreach (TagCounter counter in TagCounters) { if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains(counter.Tag))) { counter.Count++; includeAsMatch = counter.IncludeAsMatch;//Exclude as feature matches per preferences from reporting full match details } } //once patterns checked; prepare text for output blocking browser xss matchRecord.TextSample = System.Net.WebUtility.HtmlEncode(matchRecord.TextSample); return(includeAsMatch); }
/// <summary> /// Part of post processing to test for matches against app defined properties /// defined in MetaData class /// Exludes a match if specified in preferences as a counted tag with exclude true /// </summary> /// <param name="matchRecord"></param> public bool AddStandardProperties(MatchRecord matchRecord) { bool includeAsMatch = true; //testing for presence of a tag against the specified set in preferences for report org foreach (string key in _propertyTagSearchPatterns.Keys) { var tagPatternRegex = new Regex(_propertyTagSearchPatterns[key], RegexOptions.IgnoreCase); if (matchRecord.Issue.Rule.Tags.Any(v => tagPatternRegex.IsMatch(v))) { KeyedPropertyLists[key].Add(matchRecord.TextSample); } } //update counts for default or user specified tags foreach (TagCounter counter in TagCounters) { if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains(counter.Tag))) { counter.Count++; includeAsMatch = counter.IncludeAsMatch; } } // Author etc. or standard properties we capture if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Author"))) { this.Authors = ExtractJSONValue(matchRecord.TextSample); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Publisher"))) { this.Authors = ExtractXMLValue(matchRecord.TextSample); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Description"))) { this.Description = ExtractJSONValue(matchRecord.TextSample); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Name"))) { this.ApplicationName = ExtractJSONValue(matchRecord.TextSample); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.Version"))) { this.SourceVersion = ExtractJSONValue(matchRecord.TextSample); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Hardware.Processor"))) { this.CPUTargets.Add(ExtractJSONValue(matchRecord.TextSample).ToLower()); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Metadata.Application.BuildOutput.Category"))) { this.Outputs.Add(ExtractXMLValue(matchRecord.TextSample).ToLower()); } if (matchRecord.Issue.Rule.Tags.Any(v => v.Contains("Platform.OS"))) { this.OSTargets.Add(ExtractJSONValue(matchRecord.TextSample).ToLower()); } //special handling; attempt to detect app types...review for multiple pattern rule limitation String solutionType = Utils.DetectSolutionType(matchRecord); if (!string.IsNullOrEmpty(solutionType)) { AppTypes.Add(solutionType); } return(includeAsMatch); }