From 65adf2109d66772e6d2f96af268159398f3a4c14 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 5 Jan 2023 10:53:06 -0800 Subject: [PATCH] Add content scanning flag in Scanner/Test --- BurnOutSharp/Scanner.cs | 39 ++++++++++++++++++++++++++------------- Test/Program.cs | 5 +++-- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/BurnOutSharp/Scanner.cs b/BurnOutSharp/Scanner.cs index f38f5c2b..a55789d5 100644 --- a/BurnOutSharp/Scanner.cs +++ b/BurnOutSharp/Scanner.cs @@ -20,6 +20,11 @@ namespace BurnOutSharp /// public bool ScanArchives { get; private set; } + /// + /// Determines if content matches are used or not + /// + public bool ScanContents { get; private set; } + /// /// Determines if packers are counted as detected protections or not /// @@ -46,13 +51,15 @@ namespace BurnOutSharp /// Constructor /// /// Enable scanning archive contents + /// Enable including content detections in output /// Enable including packers in output /// Enable including path detections in output /// Enable including debug information /// Optional progress callback - public Scanner(bool scanArchives, bool scanPackers, bool scanPaths, bool includeDebug, IProgress fileProgress = null) + public Scanner(bool scanArchives, bool scanContents, bool scanPackers, bool scanPaths, bool includeDebug, IProgress fileProgress = null) { ScanArchives = scanArchives; + ScanContents = scanContents; ScanPackers = scanPackers; ScanPaths = scanPaths; IncludeDebug = includeDebug; @@ -133,15 +140,18 @@ namespace BurnOutSharp } // Scan for content-detectable protections - var fileProtections = GetInternalProtections(file); - if (fileProtections != null && fileProtections.Any()) + if (ScanContents) { - foreach (string key in fileProtections.Keys) + var fileProtections = GetInternalProtections(file); + if (fileProtections != null && fileProtections.Any()) { - if (!protections.ContainsKey(key)) - protections[key] = new ConcurrentQueue(); + foreach (string key in fileProtections.Keys) + { + if (!protections.ContainsKey(key)) + protections[key] = new ConcurrentQueue(); - protections[key].AddRange(fileProtections[key]); + protections[key].AddRange(fileProtections[key]); + } } } @@ -171,15 +181,18 @@ namespace BurnOutSharp } // Scan for content-detectable protections - var fileProtections = GetInternalProtections(path); - if (fileProtections != null && fileProtections.Any()) + if (ScanContents) { - foreach (string key in fileProtections.Keys) + var fileProtections = GetInternalProtections(path); + if (fileProtections != null && fileProtections.Any()) { - if (!protections.ContainsKey(key)) - protections[key] = new ConcurrentQueue(); + foreach (string key in fileProtections.Keys) + { + if (!protections.ContainsKey(key)) + protections[key] = new ConcurrentQueue(); - protections[key].AddRange(fileProtections[key]); + protections[key].AddRange(fileProtections[key]); + } } } diff --git a/Test/Program.cs b/Test/Program.cs index 066994b6..a2388f7b 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -18,7 +18,7 @@ namespace Test p.ProgressChanged += Protector.Changed; // Set initial values for scanner flags - bool debug = false, archives = true, packers = true, paths = true, info = false, extract = false; + bool debug = false, archives = true, contents = true, packers = true, paths = true, info = false, extract = false; string outputPath = string.Empty; var inputPaths = new List(); @@ -88,7 +88,7 @@ namespace Test } // Create scanner for all paths - var scanner = new Scanner(archives, packers, paths, debug, p); + var scanner = new Scanner(archives, contents, packers, paths, debug, p); // If we have extraction, check the output path exists and is valid if (extract) @@ -148,6 +148,7 @@ namespace Test Console.WriteLine("Possible options:"); Console.WriteLine("-?, -h, --help Display this help text and quit"); Console.WriteLine("-d, --debug Enable debug mode"); + Console.WriteLine("-nc, --no-contents Disable scanning for content checks"); Console.WriteLine("-na, --no-archives Disable scanning archives"); Console.WriteLine("-np, --no-packers Disable scanning for packers"); Console.WriteLine("-ns, --no-paths Disable scanning for path checks");