Exemplo n.º 1
0
        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.RegisterCompilationStartAction(
                context =>
            {
                Compilation compilation = context.Compilation;
                var xmlTypes            = new XxeSecurityTypes(compilation);

                if (!xmlTypes.IsAnyTypeReferenced())
                {
                    return;
                }

                Version version = compilation.GetDotNetFrameworkVersion();
                if (version == null)
                {
                    return;
                }

                context.RegisterCodeBlockStartAction <VB.SyntaxKind>(
                    c =>
                {
                    var analyzer = new XxeAnalyzerVBasic(xmlTypes, version);
                    analyzer.RegisterSyntaxNodeAction(c);
                    c.RegisterCodeBlockEndAction(analyzer.AnalyzeCodeBlockEnd);
                });
            });
        }
Exemplo n.º 2
0
        private void OnCompilationStartAction(CompilationStartAnalysisContext context)
        {
            Compilation compilation = context.Compilation;
            var         xmlTypes    = new XxeSecurityTypes(compilation);

            if (!xmlTypes.IsAnyTypeReferenced())
            {
                return;
            }

            (bool dotnetCore, Version version) = compilation.GetDotNetFrameworkVersion();
            if (!dotnetCore && version == null)
            {
                return;
            }

            context.RegisterCodeBlockStartAction <VB.SyntaxKind>(
                c =>
            {
                var analyzer = new XxeAnalyzerVBasic(xmlTypes, dotnetCore || version >= new Version(4, 5, 2));
                analyzer.RegisterSyntaxNodeAction(c);
                c.RegisterCodeBlockEndAction(analyzer.AnalyzeCodeBlockEnd);
            });
        }