Пример #1
0
        public static void ProcessAssemblies(ScannerConfiguration configuration)
        {
            foreach (var instrumentationSet in configuration.InstrumentationSets)
            {
                // load the instrumentation.xml and create InstrumentationModel
                var instrumentationModel = ReadInstrumentationFile(instrumentationSet);

                // nuget assemblies
                var downloadedNugetInfoList = GetNugetAssemblies(instrumentationSet, instrumentationModel.UniqueAssemblies);

                foreach (var downloadedNugetInfo in downloadedNugetInfoList)
                {
                    foreach (var intrumentedDllFileLocation in downloadedNugetInfo.InstrumentedDllFileLocations)
                    {
                        // Builds a model from the files
                        Console.WriteLine($"Starting scan of '{intrumentedDllFileLocation}'");
                        var assemblyAnalyzer = new AssemblyAnalyzer();
                        var assemblyAnalysis = assemblyAnalyzer.RunAssemblyAnalysis(intrumentedDllFileLocation);

                        var instrumentationValidator = new InstrumentationValidator(assemblyAnalysis);

                        // just some debugging writes
                        Console.WriteLine($"Found {assemblyAnalysis.ClassesCount} classes");
                        Console.WriteLine("Scan complete");

                        var targetFramework = Path.GetFileName(Path.GetDirectoryName(intrumentedDllFileLocation));

                        // run the validation
                        var report = instrumentationValidator.CheckInstrumentation(instrumentationModel, instrumentationSet.Name, targetFramework, downloadedNugetInfo.PackageVersion, downloadedNugetInfo.PackageName);
                        _instrumentationReports.Add(report);
                    }
                }
            }
        }
Пример #2
0
        public static void ProcessAssemblies(ScannerConfiguration configuration)
        {
            foreach (var instrumentationSet in configuration.InstrumentationSets)
            {
                // TODO: deal with duplicate assembly names

                // load the instrumentation.xml and create InstrumentationModel
                var instrumentationModel = ReadInstrumentationFile(instrumentationSet);

                List <string> dllFileLocations = new List <string>();

                // nuget assemblies
                var nugetDllFileLocations = GetNugetAssemblies(instrumentationSet, instrumentationModel.UniqueAssemblies);
                if (nugetDllFileLocations != null)
                {
                    dllFileLocations.AddRange(nugetDllFileLocations);
                }

                // local assemblies
                var localDllFileLocations = GetLocalAssemblies(instrumentationSet);
                if (localDllFileLocations != null)
                {
                    dllFileLocations.AddRange(localDllFileLocations);
                }
                var dllFileNames = dllFileLocations.ToArray();

                // Builds a model from the files
                Console.WriteLine($"Starting scan of '{string.Join(',', dllFileNames)}'");
                var assemblyAnalyzer = new AssemblyAnalyzer();
                var assemblyAnalysis = assemblyAnalyzer.RunAssemblyAnalysis(dllFileNames);

                var instrumentationValidator = new InstrumentationValidator(assemblyAnalysis);

                // just some debugging writes
                Console.WriteLine($"Found {assemblyAnalysis.ClassesCount} classes");
                Console.WriteLine("Scan complete");

                // run the validation
                var report = instrumentationValidator.CheckInstrumentation(instrumentationModel, instrumentationSet.Name);
                _instrumentationReports.Add(report);
            }
        }
Пример #3
0
        public static void Main(string[] args)
        {
            if (args.Length != 1 || string.IsNullOrWhiteSpace(args[0]))
            {
                Console.WriteLine("ERROR Missing argument: Must supply path to configuration file.");
                return;
            }

            var configFilePath = args[0];

            if (!File.Exists(configFilePath))
            {
                Console.WriteLine("ERROR File not found: Provide path was incorrect or file missing.");
                return;
            }

            // deserialize configuration from .yml
            var configuration = ScannerConfiguration.GetScannerConfiguration(configFilePath);

            ProcessAssemblies(configuration);

            PrintReport();
        }