public void OnCompilationEnd(PumaCompilationAnalysisContext pumaContext) { var context = pumaContext.RosylnContext; if (!context.Options.AdditionalFiles.Any()) { return; } var srcFiles = _mvcMarkupFileFilter.GetFiles(context.Options.AdditionalFiles).ToList(); if (!srcFiles.Any()) { return; } foreach (var file in srcFiles) { var document = file.GetText(); var source = document.ToString(); if (!_htmlRawRegexHelper.HasMatch(source)) { continue; } foreach (Match match in _htmlRawRegexHelper.GetMatches(source)) { VulnerableAdditionalText.Push(new DiagnosticInfo(file.Path, document.Lines.GetLinePosition(match.Index).Line, source.Substring(match.Index, match.Length))); } } }
public IEnumerable <DiagnosticInfo> GetDiagnosticInfo(IEnumerable <AdditionalText> srcFiles, CancellationToken cancellationToken) { var result = new List <DiagnosticInfo>(); foreach (var file in srcFiles) { var document = file.GetText(cancellationToken); var source = document.ToString(); if (!_dataBindingExpressionRegexHelper.HasMatch(source)) { continue; } foreach (Match match in _dataBindingExpressionRegexHelper.GetMatches(source)) { result.Add(new DiagnosticInfo(file.Path, document.Lines.GetLinePosition(match.Index).Line, source.Substring(match.Index, match.Length))); } } return(result); }