Ejemplo n.º 1
0
        /// <summary>
        /// Validates Dexter configuration
        /// </summary>
        /// <param name="config">configuration</param>
        /// <returns>true, if validation was successfull </returns>
        private bool ValidateConfiguration(Configuration config)
        {
            DexterInfo dexterInfo = DexterInfo.fromConfiguration(config);
            string     validationResult;

            if (!dexterInfoValidator.ValidateDexterPath(dexterInfo))
            {
                MessageBox.Show("Dexter wasn't found in given path. You cannot perform analysis until you set a proper path.", "Dexter error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (!config.standalone && !dexterInfoValidator.ValidateServerConnection(dexterInfo, out validationResult))
            {
                DialogResult result = MessageBox.Show("Couldn't connect to Dexter server. Please check server address in Dexter/Settings window. Continue in standalone mode?", "Dexter warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (result == DialogResult.OK)
                {
                    config.standalone = true;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (!config.standalone && !dexterInfoValidator.ValidateUserCredentials(dexterInfo, out validationResult))
                {
                    DialogResult result = MessageBox.Show("Couldn't login to Dexter server. Please check user credentials in Dexter/Settings window. Continue in standalone mode?", "Dexter warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if (result == DialogResult.OK)
                    {
                        config.standalone = true;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public void ValidateConfigurationAndAnalyse()
        {
            Configuration config = ConfigurationProvider.Load();

            if (!ValidateConfiguration(config))
            {
                return;
            }

            OutputWindowPane outputPane = CreatePane("Dexter");

            outputPane.Clear();
            outputPane.Activate();

            System.Threading.Tasks.Task.Run(() =>
            {
                dexter = new DexterLegacyAnalyzer(config);
                DataReceivedEventHandler writeToOutputPane = (s, e1) => outputPane.OutputString(e1.Data + Environment.NewLine);
                dexter.OutputDataReceived += writeToOutputPane;
                dexter.ErrorDataReceived  += writeToOutputPane;
                OnAnalysisStarted(EventArgs.Empty);

                try
                {
                    Result result = dexter.Analyse();
                    ReportResult(result);
                }
                catch (Exception ex)
                {
                    outputPane.OutputString("Error during analysis: " + ex.Message);
                }
                finally
                {
                    OnAnalysisFinished(EventArgs.Empty);
                }
            });
        }