IsWindows() 공개 정적인 메소드

public static IsWindows ( this platform ) : bool
platform this
리턴 bool
        public /* for test purposes */ static bool ExecuteProcessorRunner(AnalysisConfig config, ILogger logger, string exeFileName, IEnumerable <string> userCmdLineArguments, string propertiesFileName, IProcessRunner runner)
        {
            Debug.Assert(File.Exists(exeFileName), "The specified exe file does not exist: " + exeFileName);
            Debug.Assert(File.Exists(propertiesFileName), "The specified properties file does not exist: " + propertiesFileName);

            logger.LogInfo(Resources.MSG_TFSProcessorCalling);

            Debug.Assert(!string.IsNullOrWhiteSpace(config.SonarScannerWorkingDirectory), "The working dir should have been set in the analysis config");
            Debug.Assert(Directory.Exists(config.SonarScannerWorkingDirectory), "The working dir should exist");

            var converterArgs = new ProcessRunnerArguments(exeFileName, !PlatformHelper.IsWindows())
            {
                CmdLineArgs      = userCmdLineArguments,
                WorkingDirectory = config.SonarScannerWorkingDirectory,
            };

            var success = runner.Execute(converterArgs);

            if (success)
            {
                logger.LogInfo(Resources.MSG_TFSProcessorCompleted);
            }
            else
            {
                logger.LogError(Resources.ERR_TFSProcessorExecutionFailed);
            }
            return(success);
        }
        private static string FindScannerExe()
        {
            var binFolder     = Path.GetDirectoryName(typeof(SonarScannerWrapper).Assembly.Location);
            var fileExtension = PlatformHelper.IsWindows() ? ".bat" : "";

            return(Path.Combine(binFolder, $"sonar-scanner-{SonarScannerVersion}", "bin", $"sonar-scanner{fileExtension}"));
        }
예제 #3
0
 public static string GetIconExtension()
 {
     if (PlatformHelper.IsWindows())
     {
         return(".png");
     }
     return(".svg");
 }
예제 #4
0
 public static Image GetAppIcon()
 {
     // TODO: Handle possible exceptions
     if (PlatformHelper.IsWindows())
     {
         return(Image.FromFile("./resources/app-icons/r7-webmate-128px.png"));
     }
     return(Image.FromFile("./resources/app-icons/r7-webmate-plain.svg"));
 }
예제 #5
0
 public static ToolkitType GetDefaultXwtToolkitType()
 {
     if (PlatformHelper.IsWindows())
     {
         return(ToolkitType.Wpf);
     }
     if (PlatformHelper.IsUnix())
     {
         return(ToolkitType.Gtk3);
     }
     return(ToolkitType.Gtk);
 }
        public /* for test purposes */ static bool ExecuteJavaRunner(AnalysisConfig config, IEnumerable <string> userCmdLineArguments, ILogger logger, string exeFileName, string propertiesFileName)
        {
            Debug.Assert(File.Exists(exeFileName), "The specified exe file does not exist: " + exeFileName);
            Debug.Assert(File.Exists(propertiesFileName), "The specified properties file does not exist: " + propertiesFileName);

            IgnoreSonarScannerHome(logger);

            var allCmdLineArgs = GetAllCmdLineArgs(propertiesFileName, userCmdLineArguments, config);

            var envVarsDictionary = GetAdditionalEnvVariables(logger);

            Debug.Assert(envVarsDictionary != null);

            logger.LogInfo(Resources.MSG_SonarScannerCalling);

            Debug.Assert(!string.IsNullOrWhiteSpace(config.SonarScannerWorkingDirectory), "The working dir should have been set in the analysis config");
            Debug.Assert(Directory.Exists(config.SonarScannerWorkingDirectory), "The working dir should exist");

            var scannerArgs = new ProcessRunnerArguments(exeFileName, PlatformHelper.IsWindows(), logger)
            {
                CmdLineArgs          = allCmdLineArgs,
                WorkingDirectory     = config.SonarScannerWorkingDirectory,
                EnvironmentVariables = envVarsDictionary
            };

            var runner = new ProcessRunner();

            // SONARMSBRU-202 Note that the Sonar Scanner may write warnings to stderr so
            // we should only rely on the exit code when deciding if it ran successfully
            var success = runner.Execute(scannerArgs);

            if (success)
            {
                logger.LogInfo(Resources.MSG_SonarScannerCompleted);
            }
            else
            {
                logger.LogError(Resources.ERR_SonarScannerExecutionFailed);
            }
            return(success);
        }
예제 #7
0
 private string GetShellCommandPrefix()
 {
     return(PlatformHelper.IsWindows() ? "/c " : "");
 }
예제 #8
0
 private string GetShellName()
 {
     return(PlatformHelper.IsWindows() ? "cmd" : "bash");
 }
예제 #9
0
        private X509Certificate2 SearchCertificate(string certname, string password, string path)
        {
            StoreName[]      stores;
            X509Certificate2 localCertificate = null;

            // Get the certificate from the operative system key store
            if (PlatformHelper.IsWindows())
            {
                stores = new StoreName[]
                {
                    StoreName.My
                };
            }
            else if (PlatformHelper.IsLinux())
            {
                stores = new StoreName[]
                {
                    StoreName.My,
                    StoreName.Root
                };
            }
            else
            {
                throw new PlatformNotSupportedException();
            }

            StoreLocation[] locations = { StoreLocation.CurrentUser, StoreLocation.LocalMachine };

            foreach (var location in locations)
            {
                foreach (var s in stores)
                {
                    var store = new X509Store(s, location);
                    store.Open(OpenFlags.ReadOnly);
                    foreach (var m in store.Certificates)
                    {
                        if (m.Subject.IndexOf("CN=" + certname, 0, StringComparison.InvariantCultureIgnoreCase) >= 0 ||
                            m.Issuer.IndexOf("CN=" + certname, 0, StringComparison.InvariantCultureIgnoreCase) >= 0)
                        {
                            store.Close();
                            localCertificate = m;
                        }
                    }

                    store.Close();
                }
            }

            // As fallback use application's filesystem
            if (localCertificate == null)
            {
                if (string.IsNullOrEmpty(path))
                {
                    throw new ConfigurationException(("en", "A path must be set if certificate is not installed on the system"),
                                                     ("es", "Se debe establecer una ruta si el certificado no está instalado en el sistema"));
                }

                var pathToCertificate = Path.GetFullPath(Path.Combine(path, $"{certname}.pfx"));

                using (var stream = File.Open(pathToCertificate, FileMode.Open))
                {
                    var certificatePassword = password;

                    var  cert   = new X509Certificate2(ReadStream(stream), certificatePassword, X509KeyStorageFlags.MachineKeySet);
                    bool result = cert.Verify();
                    return(cert);
                }
            }
            return(localCertificate);
        }