Example #1
0
        public ActionResult RunAnalysisWithAnalyses(string SelectedBaseRunId, string SelectedCompareRunId, IFormFile AnalysisFilterFile)
        {
            var filePath = Path.GetTempFileName();

            CompareCommandOptions opts = new CompareCommandOptions();

            opts.FirstRunId     = SelectedBaseRunId;
            opts.SecondRunId    = SelectedCompareRunId;
            opts.Analyze        = true;
            opts.SaveToDatabase = true;

            if (AnalysisFilterFile != null)
            {
                using (var stream = System.IO.File.Create(filePath))
                {
                    AnalysisFilterFile.CopyTo(stream);
                }
                opts.AnalysesFile = filePath;
            }

            if (AttackSurfaceAnalyzerClient.GetComparators().Where(c => c.IsRunning() == RUN_STATUS.RUNNING).Any())
            {
                return(Json("Comparators already running!"));
            }

            if (DatabaseManager.GetComparisonCompleted(opts.FirstRunId, opts.SecondRunId))
            {
                return(Json("Using cached comparison calculations."));
            }

            Task.Factory.StartNew(() => AttackSurfaceAnalyzerClient.CompareRuns(opts));

            return(Json("Started Analysis"));
        }
Example #2
0
        public ActionResult RunAnalysis(string firstId, string secondId)
        {
            CompareCommandOptions opts = new CompareCommandOptions();

            opts.FirstRunId  = firstId;
            opts.SecondRunId = secondId;
            opts.Analyze     = true;
            foreach (BaseCompare c in AttackSurfaceAnalyzerClient.GetComparators())
            {
                // The GUI *should* prevent us from getting here. But this is extra protection.
                // We won't start new collections while existing ones are ongoing.
                if (c.IsRunning() == RUN_STATUS.RUNNING)
                {
                    return(Json("Comparators already running!"));
                }
            }


            using (var cmd = new SqliteCommand(SQL_CHECK_IF_COMPARISON_PREVIOUSLY_COMPLETED, DatabaseManager.Connection, DatabaseManager.Transaction))
            {
                cmd.Parameters.AddWithValue("@base_run_id", opts.FirstRunId);
                cmd.Parameters.AddWithValue("@compare_run_id", opts.SecondRunId);
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        return(Json("Using cached comparison calculations."));
                    }
                }
            }

            Task.Factory.StartNew <Dictionary <string, object> >(() => AttackSurfaceAnalyzerClient.CompareRuns(opts));

            return(Json("Started Analysis"));
        }
Example #3
0
        public ActionResult RunAnalysis(string firstId, string secondId)
        {
            CompareCommandOptions opts = new CompareCommandOptions();

            opts.FirstRunId  = firstId;
            opts.SecondRunId = secondId;
            opts.Analyze     = true;
            if (AttackSurfaceAnalyzerClient.GetComparators().Where(c => c.IsRunning() == RUN_STATUS.RUNNING).Any())
            {
                return(Json("Comparators already running!"));
            }

            using (var cmd = new SqliteCommand(SQL_CHECK_IF_COMPARISON_PREVIOUSLY_COMPLETED, DatabaseManager.Connection, DatabaseManager.Transaction))
            {
                cmd.Parameters.AddWithValue("@base_run_id", opts.FirstRunId);
                cmd.Parameters.AddWithValue("@compare_run_id", opts.SecondRunId);
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        return(Json("Using cached comparison calculations."));
                    }
                }
            }

            Task.Factory.StartNew(() => AttackSurfaceAnalyzerClient.CompareRuns(opts));

            return(Json("Started Analysis"));
        }
Example #4
0
        public ActionResult GetComparators()
        {
            Dictionary <string, RUN_STATUS> dict = new Dictionary <string, RUN_STATUS>();

            foreach (BaseCompare c in AttackSurfaceAnalyzerClient.GetComparators())
            {
                var fullString = c.GetType().ToString();
                var splits     = fullString.Split('.');
                dict.Add(splits[splits.Length - 1], c.IsRunning());
            }

            //@TODO: Also return the RunId
            return(Json(JsonConvert.SerializeObject(dict)));
        }
        public ActionResult RunAnalysisWithAnalyses(string SelectedBaseRunId, string SelectedCompareRunId, IFormFile AnalysisFilterFile)
        {
            var filePath = Path.GetTempFileName();

            CompareCommandOptions opts = new CompareCommandOptions();

            opts.FirstRunId     = SelectedBaseRunId;
            opts.SecondRunId    = SelectedCompareRunId;
            opts.Analyze        = true;
            opts.SaveToDatabase = true;

            if (AnalysisFilterFile != null)
            {
                using (var stream = System.IO.File.Create(filePath))
                {
                    AnalysisFilterFile.CopyTo(stream);
                }
                opts.AnalysesFile = filePath;
            }

            if (AttackSurfaceAnalyzerClient.GetComparators().Where(c => c.IsRunning() == RUN_STATUS.RUNNING).Any())
            {
                return(Json("Comparators already running!"));
            }

            using (var cmd = new SqliteCommand(SQL_CHECK_IF_COMPARISON_PREVIOUSLY_COMPLETED, DatabaseManager.Connection, DatabaseManager.Transaction))
            {
                cmd.Parameters.AddWithValue("@base_run_id", opts.FirstRunId);
                cmd.Parameters.AddWithValue("@compare_run_id", opts.SecondRunId);
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        return(Json("Using cached comparison calculations."));
                    }
                }
            }

            Task.Factory.StartNew(() => AttackSurfaceAnalyzerClient.CompareRuns(opts));

            return(Json("Started Analysis"));
        }