Skip to content

Commit

Permalink
Fix Size on Disk bugs (#449)
Browse files Browse the repository at this point in the history
* Fix #435 
* Fix #448
  • Loading branch information
gfs authored May 19, 2020
1 parent e7dc898 commit fee5e76
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 222 deletions.
4 changes: 2 additions & 2 deletions Lib/Collectors/BaseCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace AttackSurfaceAnalyzer.Collectors
public abstract class BaseCollector : IPlatformRunnable
{
public ConcurrentStack<CollectObject> Results { get; } = new ConcurrentStack<CollectObject>();
internal CollectCommandOptions? opts;
internal CollectCommandOptions opts = new CollectCommandOptions();
public void Execute()
{
if (!CanRunOnPlatform())
Expand All @@ -39,7 +39,7 @@ public void Execute()

public void StallIfHighMemoryUsageAndLowMemoryModeEnabled()
{
if (opts?.LowMemoryUsage ?? false)
if (opts.LowMemoryUsage)
{
int stallCount = 0;
while (Results.Count > LOW_MEMORY_CUTOFF)
Expand Down
8 changes: 3 additions & 5 deletions Lib/Collectors/ComObjectCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ namespace AttackSurfaceAnalyzer.Collectors
/// </summary>
public class ComObjectCollector : BaseCollector
{
readonly CollectCommandOptions opts;

public ComObjectCollector(CollectCommandOptions opts)
{
this.opts = opts;
Expand Down Expand Up @@ -98,7 +96,7 @@ public static IEnumerable<CollectObject> ParseComObjects(RegistryKey SearchKey,
{
if (SearchKey == null) { return new List<CollectObject>(); }
List<ComObject> comObjects = new List<ComObject>();

var fsc = new FileSystemCollector(new CollectCommandOptions() { SingleThread = SingleThreaded });
Action<string> ParseComObjectsIn = SubKeyName =>
{
try
Expand Down Expand Up @@ -136,7 +134,7 @@ public static IEnumerable<CollectObject> ParseComObjects(RegistryKey SearchKey,
BinaryPath32 = Path.Combine(Environment.SystemDirectory, BinaryPath32.Trim());
}

comObject.x86_Binary = FileSystemCollector.FilePathToFileSystemObject(BinaryPath32.Trim(), true);
comObject.x86_Binary = fsc.FilePathToFileSystemObject(BinaryPath32.Trim());
}
}
}
Expand All @@ -163,7 +161,7 @@ public static IEnumerable<CollectObject> ParseComObjects(RegistryKey SearchKey,
BinaryPath64 = Path.Combine(Environment.SystemDirectory, BinaryPath64.Trim());
}

comObject.x64_Binary = FileSystemCollector.FilePathToFileSystemObject(BinaryPath64.Trim(), true);
comObject.x64_Binary = fsc.FilePathToFileSystemObject(BinaryPath64.Trim());
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions Lib/Collectors/EventLogCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ namespace AttackSurfaceAnalyzer.Collectors
/// </summary>
public class EventLogCollector : BaseCollector
{

private readonly bool GatherVerboseLogs;
public EventLogCollector(CollectCommandOptions opts)
{
this.opts = opts;
GatherVerboseLogs = opts?.GatherVerboseLogs ?? false;
if (opts != null)
{
this.opts = opts;
}
}

public override void ExecuteInternal()
Expand Down Expand Up @@ -61,7 +61,7 @@ public void ExecuteWindows()
{
if (entry != null)
{
if (GatherVerboseLogs || entry.EntryType.ToString() == "Warning" || entry.EntryType.ToString() == "Error")
if (opts.GatherVerboseLogs || entry.EntryType.ToString() == "Warning" || entry.EntryType.ToString() == "Error")
{
var sentences = entry.Message.Split('.');

Expand Down Expand Up @@ -161,7 +161,7 @@ public void ExecuteMacOs()
StartInfo = new ProcessStartInfo
{
FileName = "log",
Arguments = (GatherVerboseLogs) ? "show" : "show --predicate \"messageType == 16 || messageType == 17\"",
Arguments = opts.GatherVerboseLogs ? "show" : "show --predicate \"messageType == 16 || messageType == 17\"",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
Expand Down
Loading

0 comments on commit fee5e76

Please sign in to comment.