fixed global search bug (table items were removed, so search didn't see them)

This commit is contained in:
Patrick Wardle
2016-02-25 22:08:59 -10:00
parent 905672341f
commit 5b3ca683dc
9 changed files with 50 additions and 186 deletions
+4 -5
View File
@@ -20,7 +20,6 @@
//TODO: autolayout vertically
//TODO: show 'from where' via quarantine attrz or database!! (simon email)
//TODO: detect as procs die via GCD (simon blog post)
//TODO: max'd out window ->set max? (dual monitors)
@implementation AppDelegate
@@ -1429,8 +1428,8 @@ bail:
//always hide 'no items' label
self.noItemsLabel.hidden = YES;
//clear out existing items
[self.bottomViewController.tableItems removeAllObjects];
//unset existing items
self.bottomViewController.tableItems = nil;
//when in a background thread
// ->perform UI stuff on main thread
@@ -1702,8 +1701,8 @@ bail:
if( (YES == self.taskTableController.isFiltered) &&
(0 == self.taskTableController.filteredItems.count) )
{
//remove bottom pane's items
[self.bottomViewController.tableItems removeAllObjects];
//unset bottom pane's items
self.bottomViewController.tableItems = nil;
//reset current task
self.currentTask = nil;
+28
View File
@@ -94,6 +94,34 @@
return;
}
//resolve a remote IP address to nice DNS name
// ->uses address and port, which are passed to getaddrinfo
// note: get thread to call this, cuz it can be slow!!
-(void)addressesForHost
{
/*
struct addrinfo hints = {.ai_family=PF_UNSPEC;.ai_socktype=SOCK_STREAM;.ai_protocol=IPPROTO_TCP};
struct addrinfo *res;
int gai_error = getaddrinfo(host.UTF8String, port.stringValue.UTF8String, &hints, &res);
if (gai_error) {
if (outError) *outError = [NSError errorWithDomain:@"MyDomain" code:gai_error userInfo:@{NSLocalizedDescriptionKey:@(gai_strerror(gai_error))}];
return nil;
}
NSMutableArray *addresses = [NSMutableArray array];
struct addrinfo *ai = res;
do {
NSData *address = [NSData dataWithBytes:ai->ai_addr length:ai->ai_addrlen];
[addresses addObject:address];
} while (ai = ai->ai_next);
freeaddrinfo(res);
return [addresses copy];
*/
}
//build nice string
-(void)setConnectionString
{
-3
View File
@@ -66,10 +66,7 @@ bail:
NSArray* parsedResults = nil;
//exec 'file' to get file type
//TODO: make const, and this ERRORS out a bunch?
results = [[NSString alloc] initWithData:execTask(FILE, @[self.path]) encoding:NSUTF8StringEncoding];
//sanity check
if(nil == results)
{
//bail
+12 -7
View File
@@ -6,14 +6,15 @@
// Copyright (c) 2015 Objective-See. All rights reserved.
//
#import <syslog.h>
#import "KKRow.h"
#import "Consts.h"
#import "Filter.h"
#import "ItemView.h"
#import "Utilities.h"
#import "AppDelegate.h"
#import "SearchWindowController.h"
#import "ItemView.h"
#import "KKRow.h"
#import "Filter.h"
#import "Utilities.h"
#import "Consts.h"
@implementation SearchWindowController
@@ -546,6 +547,7 @@ bail:
}
//1st: search for all matching tasks
//search for all matching tasks
[self.filterObj filterTasks:searchString items:allTasks results:matchingTasks];
@@ -556,6 +558,7 @@ bail:
[self.searchTable reloadData];
//2nd: search for all matching dylibs
//sync
@synchronized(allTasks)
{
@@ -598,6 +601,7 @@ bail:
[self.searchTable reloadData];
//3rd: search for all matching files
//sync
@synchronized(allTasks)
{
@@ -640,6 +644,7 @@ bail:
[self.searchTable reloadData];
//4th: search for all matching network comms
//sync
@synchronized(allTasks)
{
@@ -647,7 +652,7 @@ bail:
[matchingItems removeAllObjects];
//walk all tasks
// ->scan each for file matches, only processing first match
// ->scan each for connections matches, only processing first match
for(NSNumber* taskPid in allTasks)
{
//extract task
@@ -655,7 +660,7 @@ bail:
//filter
[self.filterObj filterConnections:searchString items:task.connections results:matchingItems];
//process all matching connections
// ->but first check if processed due to matching in another task already
for(Connection* connection in matchingItems)
+4 -7
View File
@@ -624,24 +624,21 @@ bail:
//remove any existing enum'd networking sockets/connections
[self.connections removeAllObjects];
//
//NSLog(@"found %d connections", networkItems.count);
//create/add all network sockets/connection
for(NSMutableDictionary* networkItem in networkItems)
{
//alloc/init File obj
connection = [[Connection alloc] initWithParams:networkItem];
//add File obj
//add connection obj
if(nil != connection)
{
//add
[self.connections addObject:connection];
}
}
//reload bottom pane
[((AppDelegate*)[[NSApplication sharedApplication] delegate]) reloadBottomPane:self itemView:NETWORKING_VIEW];
@@ -807,7 +804,7 @@ bail:
//sync
@synchronized(self.connections)
{
//convert all dylibs and add
//convert all connections and add
for(Connection* connection in self.connections)
{
//convert/add
+1 -1
View File
@@ -55,7 +55,7 @@
//enumerate all tasks
// ->calls back into app delegate to update task (top) table when pau
// TODO: existsing tasks w/ nil vtInfo, call [vtObject addItem:binary] ?
// TODO: existing tasks w/ nil vtInfo, call [vtObject addItem:binary] ?
-(void)enumerateTasks
{
//(new) task item
+1 -1
View File
@@ -25,7 +25,7 @@
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Objective-See, LLC. All rights reserved.</string>
<string>Copyright © 2016 Objective-See, LLC. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
@@ -2,166 +2,4 @@
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "TaskTableController.m"
timestampString = "462060397.604232"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "323"
endingLineNumber = "323"
landmarkName = "-refresh"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "VirusTotal.m"
timestampString = "466326232.812128"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "238"
endingLineNumber = "238"
landmarkName = "-getInfoForItem:scanID:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Task.m"
timestampString = "466317911.852232"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "433"
endingLineNumber = "433"
landmarkName = "-enumerateDylibs:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "AppDelegate.m"
timestampString = "466327590.310649"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "192"
endingLineNumber = "192"
landmarkName = "-applicationDidFinishLaunching:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Items/File.m"
timestampString = "466317911.852232"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "167"
endingLineNumber = "167"
landmarkName = "-toJSON"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Items/Connection.m"
timestampString = "466048200.98878"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "117"
endingLineNumber = "117"
landmarkName = "-toJSON"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Items/File.m"
timestampString = "466319352.039055"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "76"
endingLineNumber = "76"
landmarkName = "-setFileType"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "AppDelegate.m"
timestampString = "466327590.310649"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "653"
endingLineNumber = "653"
landmarkName = "-reloadBottomPane:itemView:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Exception.m"
timestampString = "477800890.177901"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "66"
endingLineNumber = "66"
landmarkName = "exceptionHandler()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Exception.m"
timestampString = "477800907.874623"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "109"
endingLineNumber = "109"
landmarkName = "signalHandler()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>