Ejemplo n.º 1
0
        public DotNetInfo(
            IEnumerable <string> installedClrVersions,
            IEnumerable <string> installedDotNetVersions,
            int osVersionMajor)
        {
            ClrVersions         = (installedClrVersions ?? new List <string>()).ToList();
            DotNetVersions      = (installedDotNetVersions ?? new List <string>()).ToList();;
            IsAmsiSupportedByOs = osVersionMajor >= AmsiSupportedByOsMinVersion;

            LowestVersion  = DotNetVersions.Min(v => (new Version(v)));
            HighestVersion = DotNetVersions.Max(v => (new Version(v)));

            IsAmsiSupportedByDotNet = (HighestVersion.Major >= AmsiSupportedByDotNetMinMajorVersion) &&
                                      (LowestVersion.Minor >= AmsiSupportedByDotNetMinMinorVersion);
        }
Ejemplo n.º 2
0
        public static Models.Assembly ProcessSingleAssembly(string filePath)
        {
            var output = new Models.Assembly();

            AppDomainSetup appSetup = new AppDomainSetup();

            appSetup.ApplicationBase = Environment.CurrentDirectory; //@"C:\Projects\Store Trunk\trunk\PackageVerification\PackageVerification\PackageVerification.AssemblyScanner\bin\Debug";

            Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
            Evidence evidence     = new Evidence(baseEvidence);

            var sandbox = AppDomain.CreateDomain("Sandbox", evidence, appSetup);

            try
            {
                sandbox.SetData("filePath", filePath);

                sandbox.DoCallBack(MyCallBack);
                var imageRuntimeVersion  = (String)sandbox.GetData("imageRuntimeVersion");
                var assemblyName         = (String)sandbox.GetData("assemblyName");
                var referencedAssemblies = (AssemblyName[])sandbox.GetData("referencedAssemblies");
                //populate the base assembly info
                output = ProcessAssemblyInfo(output, assemblyName);

                //Let's get the base framework info
                foreach (var frameworkInfo in DotNetVersions.FrameworkList())
                {
                    if (imageRuntimeVersion == frameworkInfo.CLRVersion)
                    {
                        output.Framework = frameworkInfo;
                        break;
                    }
                }

                //populate the referenced assemblies list.
                foreach (var an in referencedAssemblies)
                {
                    var assembly = new Models.Assembly();
                    output.References.Add(ProcessAssemblyInfo(assembly, an.FullName));
                }
            }
            finally
            {
                AppDomain.Unload(sandbox);
            }

            return(output);
        }