Scan even partial extractions, simplify branches

This commit is contained in:
Matt Nadareski
2025-09-20 16:20:17 -04:00
parent 9639f40e55
commit d6708a0cbe

View File

@@ -328,12 +328,21 @@ namespace BinaryObjectScanner
// Extract and get the output path
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(tempPath);
bool extracted = extractable.Extract(tempPath, _includeDebug);
_ = extractable.Extract(tempPath, _includeDebug);
// Collect and format all found protections
ProtectionDictionary? subProtections = null;
if (extracted)
subProtections = GetProtectionsImpl(tempPath, depth + 1);
// Check if any files extracted
if (IOExtensions.SafeGetFiles(tempPath).Length > 0)
{
// Scan the output path
var subProtections = GetProtectionsImpl(tempPath, depth + 1);
// Prepare the returned values
subProtections.StripFromKeys(tempPath);
subProtections.PrependToKeys(fileName);
// Append the values
protections.Append(subProtections);
}
// If temp directory cleanup fails
try
@@ -345,14 +354,6 @@ namespace BinaryObjectScanner
{
if (_includeDebug) Console.Error.WriteLine(ex);
}
// Prepare the returned protections
if (subProtections != null)
{
subProtections.StripFromKeys(tempPath);
subProtections.PrependToKeys(fileName);
protections.Append(subProtections);
}
}
catch (Exception ex)
{