mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-04 05:35:49 +00:00
Add flag for SafeGetFiles
This commit is contained in:
@@ -11,17 +11,22 @@
|
||||
public bool ScanArchives { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if content matches are used or not
|
||||
/// Determines if content matches are used
|
||||
/// </summary>
|
||||
public bool ScanContents { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if path matches are used or not
|
||||
/// Determines if path matches are used
|
||||
/// </summary>
|
||||
public bool ScanPaths { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if debug information is output or not
|
||||
/// Determines if subdirectories are scanned
|
||||
/// </summary>
|
||||
public bool ScanSubdirectories { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if debug information is output
|
||||
/// </summary>
|
||||
public bool IncludeDebug { get; set; }
|
||||
}
|
||||
|
||||
@@ -31,11 +31,13 @@ namespace BinaryObjectScanner
|
||||
/// <param name="scanArchives">Enable scanning archive contents</param>
|
||||
/// <param name="scanContents">Enable including content detections in output</param>
|
||||
/// <param name="scanPaths">Enable including path detections in output</param>
|
||||
/// <param name="scanSubdirectories">Enable scanning subdirectories</param>
|
||||
/// <param name="includeDebug">Enable including debug information</param>
|
||||
/// <param name="fileProgress">Optional progress callback</param>
|
||||
public Scanner(bool scanArchives,
|
||||
bool scanContents,
|
||||
bool scanPaths,
|
||||
bool scanSubdirectories,
|
||||
bool includeDebug,
|
||||
IProgress<ProtectionProgress>? fileProgress = null)
|
||||
{
|
||||
@@ -44,6 +46,7 @@ namespace BinaryObjectScanner
|
||||
ScanArchives = scanArchives,
|
||||
ScanContents = scanContents,
|
||||
ScanPaths = scanPaths,
|
||||
ScanSubdirectories = scanSubdirectories,
|
||||
IncludeDebug = includeDebug,
|
||||
};
|
||||
|
||||
@@ -93,7 +96,8 @@ namespace BinaryObjectScanner
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
// Enumerate all files at first for easier access
|
||||
List<string> files = [.. IOExtensions.SafeGetFiles(path, "*", SearchOption.AllDirectories)];
|
||||
SearchOption searchOption = _options.ScanSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||
List<string> files = [.. IOExtensions.SafeGetFiles(path, "*", searchOption)];
|
||||
|
||||
// Scan for path-detectable protections
|
||||
if (_options.ScanPaths)
|
||||
|
||||
@@ -29,11 +29,17 @@ namespace ProtectionScan
|
||||
/// Scan file contents during protection scanning
|
||||
/// </summary>
|
||||
public bool ScanContents { get; private set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Scan file paths during protection scanning
|
||||
/// </summary>
|
||||
public bool ScanPaths { get; private set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Scan subdirectories during protection scanning
|
||||
/// </summary>
|
||||
public bool ScanSubdirectories { get; set; } = true;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@@ -74,11 +80,16 @@ namespace ProtectionScan
|
||||
options.ScanContents = false;
|
||||
break;
|
||||
|
||||
case "-ns":
|
||||
case "-np":
|
||||
case "--no-paths":
|
||||
options.ScanPaths = false;
|
||||
break;
|
||||
|
||||
case "-ns":
|
||||
case "--no-subdirs":
|
||||
options.ScanSubdirectories = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
options.InputPaths.Add(arg);
|
||||
break;
|
||||
@@ -109,7 +120,8 @@ namespace ProtectionScan
|
||||
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("-ns, --no-paths Disable scanning for path checks");
|
||||
Console.WriteLine("-np, --no-paths Disable scanning for path checks");
|
||||
Console.WriteLine("-ns, --no-subdirs Disable scanning subdirectories");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ namespace ProtectionScan
|
||||
options.ScanArchives,
|
||||
options.ScanContents,
|
||||
options.ScanPaths,
|
||||
options.ScanSubdirectories,
|
||||
options.Debug,
|
||||
fileProgress);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user