From 12e2d0ca965fce8e5e575c45dda278bc31e7dc74 Mon Sep 17 00:00:00 2001 From: Gabe Stocco <98900+gfs@users.noreply.github.com> Date: Fri, 11 Mar 2022 00:32:44 -0800 Subject: [PATCH 1/2] Rename analysis file cli parameter to be AnalysisFile instead of "filename" --- Lib/Objects/CommandOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/Objects/CommandOptions.cs b/Lib/Objects/CommandOptions.cs index a08236a8..3533dba2 100644 --- a/Lib/Objects/CommandOptions.cs +++ b/Lib/Objects/CommandOptions.cs @@ -231,7 +231,7 @@ public class ExportGuidedCommandOptions : ExportMonitorCommandOptions public class ExportOptions : CommandOptions { - [Option("filename", HelpText = "Custom analysis rules file.")] + [Option(HelpText = "Custom analysis rules file.")] public string? AnalysesFile { get; set; } [Option(HelpText = "Set to Disable Analysis.")] From e8748addf94ab86d83899a988d620348658e18b1 Mon Sep 17 00:00:00 2001 From: Gabe Stocco <98900+gfs@users.noreply.github.com> Date: Fri, 11 Mar 2022 14:02:05 -0800 Subject: [PATCH 2/2] Clean up leftovers from debugging #638 --- Cli/AttackSurfaceAnalyzerClient.cs | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/Cli/AttackSurfaceAnalyzerClient.cs b/Cli/AttackSurfaceAnalyzerClient.cs index 439f146c..f2572b65 100644 --- a/Cli/AttackSurfaceAnalyzerClient.cs +++ b/Cli/AttackSurfaceAnalyzerClient.cs @@ -1140,7 +1140,7 @@ public static List GetComparators() Dictionary EndEvent = new(); BaseCompare c = new(); - var watch = System.Diagnostics.Stopwatch.StartNew(); + Stopwatch watch = Stopwatch.StartNew(); if (!c.TryCompare(opts.FirstRunId, opts.SecondRunId, DatabaseManager)) { Log.Warning(Strings.Get("Err_Comparing") + " : {0}", c.GetType().Name); @@ -1179,10 +1179,6 @@ public static List GetComparators() { if (c.Results[key] is IEnumerable queue) { - if (queue.Any(x => x is null)) - { - Console.WriteLine("found em"); - } IEnumerable platformRules = opts.AnalysesFile.Rules.Where(rule => rule.Platforms == null || rule.Platforms.Contains(platform)); if (opts.SingleThreadAnalysis) { @@ -1204,22 +1200,8 @@ void PopulateAnalysisForResult(CompareResult res) var selectedRules = platformRules.Where((rule) => (rule.ChangeTypes == null || rule.ChangeTypes.Contains(res.ChangeType)) && (rule.ResultType == res.ResultType)); - if (res is null) - { - return; - } - Log.Verbose("Type: {0}", res.ResultType); - Log.Verbose("Base: {0}", JsonConvert.SerializeObject(res.Base)); - Log.Verbose("Compare: {0}", JsonConvert.SerializeObject(res.Compare)); - Log.Verbose("Num Rules: {0}", selectedRules.Count()); - try - { - res.Rules = analyzer.Analyze(selectedRules, res.Base, res.Compare).ToList(); - } - catch(Exception ex) - { - Log.Debug("Exception while analyzing object {3}. Use --verbose for object details. {0}:{1}. {2}.", ex.GetType().Name, ex.Message, ex.StackTrace, res.Identity); - } + + res.Rules = analyzer.Analyze(selectedRules, res.Base, res.Compare).ToList(); Log.Verbose("Applied Rules: {0}", res.Rules); res.Analysis = res.Rules.Count