Merge branch 'develop' of github.com:sleuthkit/autopsy into 7291-hostsManagement

This commit is contained in:
Greg DiCristofaro 2021-02-22 11:39:15 -05:00
commit c56ded6fb6
3 changed files with 7 additions and 56 deletions

View File

@ -24,7 +24,6 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.logging.Level; import java.util.logging.Level;
import org.openide.nodes.ChildFactory; import org.openide.nodes.ChildFactory;
@ -101,7 +100,7 @@ public class HostNode extends DisplayableItemNode {
@Override @Override
protected boolean createKeys(List<DataSourceGrouping> toPopulate) { protected boolean createKeys(List<DataSourceGrouping> toPopulate) {
Set<DataSource> dataSources = null; List<DataSource> dataSources = null;
try { try {
dataSources = Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().getDataSourcesForHost(host); dataSources = Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().getDataSourcesForHost(host);
} catch (NoCurrentCaseException | TskCoreException ex) { } catch (NoCurrentCaseException | TskCoreException ex) {

View File

@ -770,61 +770,10 @@ public class Server {
/** /**
* Checks to see if a specific port is available. * Checks to see if a specific port is available.
* *
* @param port the port to check for availability * @param port The port to check for availability.
* @return True if the port is available and false if not.
*/ */
static boolean isPortAvailable(int port) { static boolean isPortAvailable(int port) {
final String osName = PlatformUtil.getOSName().toLowerCase();
if (osName != null && osName.toLowerCase().startsWith("mac")) {
return isPortAvailableOSX(port);
} else {
return isPortAvailableDefault(port);
}
}
/**
* Checks to see if a specific port is available.
*
* NOTE: This is used on non-OS X systems as of right now but could be
* replaced with the OS X version.
*
* @param port the port to check for availability
*/
static boolean isPortAvailableDefault(int port) {
ServerSocket ss = null;
try {
ss = new ServerSocket(port, 0, java.net.Inet4Address.getByName("localhost")); //NON-NLS
if (ss.isBound()) {
ss.setReuseAddress(true);
ss.close();
return true;
}
} catch (IOException e) {
} finally {
if (ss != null) {
try {
ss.close();
} catch (IOException e) {
/*
* should not be thrown
*/
}
}
}
return false;
}
/**
* Checks to see if a specific port is available.
*
* NOTE: This is only used on OSX for now, but could replace default
* implementation in the future.
*
* @param port The port to check for availability.
* @throws IllegalArgumentException If port is outside range of possible ports.
*/
static boolean isPortAvailableOSX(int port) {
// implementation taken from https://stackoverflow.com/a/435579 // implementation taken from https://stackoverflow.com/a/435579
if (port < 1 || port > 65535) { if (port < 1 || port > 65535) {
throw new IllegalArgumentException("Invalid start port: " + port); throw new IllegalArgumentException("Invalid start port: " + port);

View File

@ -344,10 +344,13 @@ class TestRunner(object):
""" """
copied = False copied = False
# string for whether or it is single user or multi user for diff
mu_su_str = "multi" if test_data.isMultiUser else "single"
for file in glob.glob(test_data.output_path + "/*-Diff.txt"): for file in glob.glob(test_data.output_path + "/*-Diff.txt"):
# Eg. copies HTML-Report-Diff.txt to <Image-name>-HTML-Report-Diff.txt # Eg. copies HTML-Report-Diff.txt to <Image-name>-HTML-Report-Diff.txt
shutil.copy(file, test_data.main_config.args.diff_files_output_folder + shutil.copy(file, test_data.main_config.args.diff_files_output_folder +
"/" + test_data.image + "-" + os.path.basename(file)) "/" + test_data.image + "-" + mus_su_str + "-" + os.path.basename(file))
copied = True copied = True
if not copied: if not copied:
print_report([], "NO DIFF FILES COPIED FROM " + test_data.output_path, "") print_report([], "NO DIFF FILES COPIED FROM " + test_data.output_path, "")