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")); }
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")); }
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")); }
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")); }