This commit is contained in:
adam-m 2013-06-27 17:32:22 -04:00
commit f563eb2e38
3 changed files with 81 additions and 63 deletions

View File

@ -60,31 +60,34 @@ import org.netbeans.junit.NbModuleSuite;
import org.openide.util.Exceptions; import org.openide.util.Exceptions;
import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.IngestManager;
import org.sleuthkit.autopsy.keywordsearch.*; import org.sleuthkit.autopsy.keywordsearch.*;
/** /**
* This test expects the following system properties to be set: * This test expects the following system properties to be set: img_path: The
* img_path: The fully qualified path to the image file (if split, the first file) * fully qualified path to the image file (if split, the first file) out_path:
* out_path: The location where the case will be stored * The location where the case will be stored nsrl_path: Path to the nsrl
* nsrl_path: Path to the nsrl database * database known_bad_path: Path to a database of known bad hashes keyword_path:
* known_bad_path: Path to a database of known bad hashes * Path to a keyword list xml file ignore_unalloc: Boolean whether to ignore
* keyword_path: Path to a keyword list xml file * unallocated space or not
* ignore_unalloc: Boolean whether to ignore unallocated space or not
* *
* Without these properties set, the test will fail to run correctly. * Without these properties set, the test will fail to run correctly. To run
* To run this test correctly, you should use the script 'regression.py' * this test correctly, you should use the script 'regression.py' located in the
* located in the 'script' directory of the Testing module. * 'script' directory of the Testing module.
*/ */
public class RegressionTest extends TestCase { public class RegressionTest extends TestCase {
private static final Logger logger = Logger.getLogger(RegressionTest.class.getName()); private static final Logger logger = Logger.getLogger(RegressionTest.class.getName());
long start; long start;
/** Constructor required by JUnit */ /**
* Constructor required by JUnit
*/
public RegressionTest(String name) { public RegressionTest(String name) {
super(name); super(name);
} }
/**
/** Creates suite from particular test cases. */ * Creates suite from particular test cases.
*/
public static Test suite() { public static Test suite() {
// run tests with specific configuration // run tests with specific configuration
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(RegressionTest.class). NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(RegressionTest.class).
@ -100,21 +103,24 @@ public class RegressionTest extends TestCase{
"testAddSourceWizard1", "testAddSourceWizard1",
"testIngest", "testIngest",
"testGenerateReportToolbar", "testGenerateReportToolbar",
"testGenerateReportButton" "testGenerateReportButton");
);
return NbModuleSuite.create(conf); return NbModuleSuite.create(conf);
} }
/** Method called before each test case. */ /**
* Method called before each test case.
*/
@Override @Override
public void setUp() { public void setUp() {
logger.info("######## " + System.getProperty("img_path") + " #######"); logger.info("######## " + System.getProperty("img_path") + " #######");
} }
/** Method called after each test case. */ /**
* Method called after each test case.
*/
@Override @Override
public void tearDown() { public void tearDown() {
} }
@ -146,7 +152,11 @@ public class RegressionTest extends TestCase{
logger.info("Starting Add Image process"); logger.info("Starting Add Image process");
WizardOperator wo = new WizardOperator("Add Data"); WizardOperator wo = new WizardOperator("Add Data");
JTextFieldOperator jtfo0 = new JTextFieldOperator(wo, 0); JTextFieldOperator jtfo0 = new JTextFieldOperator(wo, 0);
String imageDir = System.getProperty("img_path"); String img_path = System.getProperty("img_path");
if (img_path.startsWith("\\")) {
img_path = "\\" + img_path;
}
String imageDir = img_path;
((JTextField) jtfo0.getSource()).setText(imageDir); ((JTextField) jtfo0.getSource()).setText(imageDir);
wo.btNext().clickMouse(); wo.btNext().clickMouse();
} }
@ -324,8 +334,8 @@ public class RegressionTest extends TestCase{
} }
} }
private void setListForIngest()
{ private void setListForIngest() {
KeywordSearchListsXML curr = KeywordSearchListsXML.getCurrent(); KeywordSearchListsXML curr = KeywordSearchListsXML.getCurrent();
curr.setUseForIngest("URLs", true); curr.setUseForIngest("URLs", true);
} }

View File

@ -38,7 +38,11 @@ def send_email(parsed, errorem, attachl, passFail):
msg.attach(container) msg.attach(container)
Build_email(msg, attachl) Build_email(msg, attachl)
s = smtplib.SMTP(serverval) s = smtplib.SMTP(serverval)
try:
print('Sending Email')
s.sendmail(msg['From'], msg['To'], msg.as_string()) s.sendmail(msg['From'], msg['To'], msg.as_string())
except Exception as e:
print(str(e))
s.quit() s.quit()
def Build_email(msg, attachl): def Build_email(msg, attachl):

View File

@ -361,9 +361,12 @@ class Database:
except Exception as e: except Exception as e:
printerror(test_img, str(e)) printerror(test_img, str(e))
printerror(test_img, str(rw[3])) printerror(test_img, str(rw[3]))
errorem += "Artifact with id#" + str(rw[3]) + " encountered an error.\n" print(test_img.image_name)
errorem += test_img.image_name + ":Artifact with id#" + str(rw[3]) + " encountered an error.\n"
looptry = False looptry = False
print(test_img.artifact_fail)
test_img.artifact_fail += 1 test_img.artifact_fail += 1
print(test_img.artifact_fail)
if(looptry == True): if(looptry == True):
src = attributes[0][0] src = attributes[0][0]
for attr in attributes: for attr in attributes:
@ -404,10 +407,11 @@ class Database:
rw = autopsy_cur2.fetchone() rw = autopsy_cur2.fetchone()
srtcmdlst = ["sort", test_img.autopsy_data_file, "-o", test_img.sorted_data_file] srtcmdlst = ["sort", test_img.autopsy_data_file, "-o", test_img.sorted_data_file]
subprocess.call(srtcmdlst) subprocess.call(srtcmdlst)
except Exception as e: print(test_img.artifact_fail)
printerror(test_img, 'outer exception: ' + str(e))
if(test_img.artifact_fail > 0): if(test_img.artifact_fail > 0):
errorem += test_img.image_name + ":There were " + str(test_img.artifact_count) + " artifacts and " + str(test_img.artifact_fail) + " threw an exception while loading.\n" errorem += test_img.image_name + ":There were " + str(test_img.artifact_count) + " artifacts and " + str(test_img.artifact_fail) + " threw an exception while loading.\n"
except Exception as e:
printerror(test_img, 'outer exception: ' + str(e))
def _dbDump(test_img): def _dbDump(test_img):
autopsy_db_file = Emailer.make_path(test_case.output_dir, test_img.image_name, autopsy_db_file = Emailer.make_path(test_case.output_dir, test_img.image_name,