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))); } } }
private IEnumerable <ConfigurationFile> Parse(CompilationAnalysisContext context) { if (!context.Options.AdditionalFiles.Any()) { return(new List <ConfigurationFile>()); } var srcFiles = _configurationFileFilter.GetFiles(context.Options.AdditionalFiles).ToList(); if (!srcFiles.Any()) { return(new List <ConfigurationFile>()); } var workingDirectory = Utils.GetWorkingDirectory(context.Compilation.AssemblyName); var basePath = Utils.GetCommonRootPath(srcFiles); return(srcFiles.Select(src => { try { return _configurationFileParser.Parse(src, basePath, workingDirectory); } catch (XmlException ex) { // Failed to parse the XML Console.WriteLine($"Failed to parse the configuration file {src}."); Console.WriteLine(ex); } return null; }).Where(s => s != null).ToList()); }
private void onCompilation(CompilationAnalysisContext context) { if (!context.Options.AdditionalFiles.Any()) { return; } var srcFiles = FileFilter.GetFiles(context.Options.AdditionalFiles).ToList(); if (!srcFiles.Any()) { return; } foreach (IAdditionalTextAnalyzer analyzer in Analyzers) { var diagnosticInfo = analyzer.GetDiagnosticInfo(srcFiles, context.CancellationToken); foreach (var info in diagnosticInfo) { var supportedDiagnostic = GetSupportedDiagnosticAttribute(analyzer); var diagnostic = DiagnosticFactory.Create(supportedDiagnostic.GetDescriptor(), info); context.ReportDiagnostic(diagnostic); } } }
private IEnumerable <ConfigurationFile> Parse(CompilationAnalysisContext context) { if (!context.Options.AdditionalFiles.Any()) { return(new List <ConfigurationFile>()); } var srcFiles = _configurationFileFilter.GetFiles(context.Options.AdditionalFiles).ToList(); if (!srcFiles.Any()) { return(new List <ConfigurationFile>()); } var workingDirectory = Utils.GetWorkingDirectory(context.Compilation.AssemblyName); var basePath = Utils.GetCommonRootPath(srcFiles); return(srcFiles.Select(src => _configurationFileParser.Parse(src, basePath, workingDirectory)).ToList()); }