Merge pull request #187 from Smoss/master

Autopsy testing improvements
This commit is contained in:
adam 2013-05-02 06:45:24 -07:00
commit 6d82ab6c00
8 changed files with 170 additions and 81 deletions

4
.gitignore vendored
View File

@ -46,8 +46,10 @@ genfiles.properties
/branding/nbproject/* /branding/nbproject/*
!/branding/nbproject/project.xml !/branding/nbproject/project.xml
!/branding/nbproject/project.properties !/branding/nbproject/project.properties
/test/input/
/test/input/* /test/input/*
!/test/input/notablehashes.txt-md5.idx
!/test/input/notablekeywords.xml
!/test/input/NSRL.txt-md5.idx
/test/output/* /test/output/*
!/test/output/gold !/test/output/gold
/test/output/gold/tmp /test/output/gold/tmp

View File

@ -27,6 +27,7 @@ import re
import zipfile import zipfile
import zlib import zlib
import Emailer import Emailer
import srcupdater
# #
# Please read me... # Please read me...
@ -71,6 +72,7 @@ class Args:
self.contin = False self.contin = False
self.gold_creation = False self.gold_creation = False
self.daily = False self.daily = False
self.fr = False
def parse(self): def parse(self):
global nxtproc global nxtproc
@ -139,6 +141,9 @@ class Args:
elif arg == "-d" or arg == "--daily": elif arg == "-d" or arg == "--daily":
printout("Running daily") printout("Running daily")
self.daily = True self.daily = True
elif arg == "-fr" or arg == "--forcerun":
printout("Not downloading new images")
self.fr = True
else: else:
printout(usage()) printout(usage())
return False return False
@ -295,7 +300,8 @@ class Database:
global failedbool global failedbool
global errorem global errorem
failedbool = True failedbool = True
errorem += "There was a difference in the number of artifacts for " + case.image + ".\n" global imgfail
imgfail = True
return "; ".join(self.artifact_comparison) return "; ".join(self.artifact_comparison)
def get_attribute_comparison(self): def get_attribute_comparison(self):
@ -304,7 +310,8 @@ class Database:
global failedbool global failedbool
global errorem global errorem
failedbool = True failedbool = True
errorem += "There was a difference in the number of attributes for " + case.image + ".\n" global imgfail
imgfail = True
list = [] list = []
for error in self.attribute_comparison: for error in self.attribute_comparison:
list.append(error) list.append(error)
@ -351,6 +358,8 @@ class Database:
def generate_gold_artifacts(self): def generate_gold_artifacts(self):
if not self.gold_artifacts: if not self.gold_artifacts:
gold_db_file = Emailer.make_path(case.gold, case.image_name, "autopsy.db") gold_db_file = Emailer.make_path(case.gold, case.image_name, "autopsy.db")
if(not file_exists(gold_db_file)):
gold_db_file = Emailer.make_path(case.gold_parse, case.image_name, "autopsy.db")
gold_con = sqlite3.connect(gold_db_file) gold_con = sqlite3.connect(gold_db_file)
gold_cur = gold_con.cursor() gold_cur = gold_con.cursor()
gold_cur.execute("SELECT COUNT(*) FROM blackboard_artifact_types") gold_cur.execute("SELECT COUNT(*) FROM blackboard_artifact_types")
@ -367,6 +376,8 @@ class Database:
def generate_gold_attributes(self): def generate_gold_attributes(self):
if self.gold_attributes == 0: if self.gold_attributes == 0:
gold_db_file = Emailer.make_path(case.gold, case.image_name, "autopsy.db") gold_db_file = Emailer.make_path(case.gold, case.image_name, "autopsy.db")
if(not file_exists(gold_db_file)):
gold_db_file = Emailer.make_path(case.gold_parse, case.image_name, "autopsy.db")
gold_con = sqlite3.connect(gold_db_file) gold_con = sqlite3.connect(gold_db_file)
gold_cur = gold_con.cursor() gold_cur = gold_con.cursor()
gold_cur.execute("SELECT COUNT(*) FROM blackboard_attributes") gold_cur.execute("SELECT COUNT(*) FROM blackboard_attributes")
@ -375,6 +386,8 @@ class Database:
def generate_gold_objects(self): def generate_gold_objects(self):
if self.gold_objects == 0: if self.gold_objects == 0:
gold_db_file = Emailer.make_path(case.gold, case.image_name, "autopsy.db") gold_db_file = Emailer.make_path(case.gold, case.image_name, "autopsy.db")
if(not file_exists(gold_db_file)):
gold_db_file = Emailer.make_path(case.gold_parse, case.image_name, "autopsy.db")
gold_con = sqlite3.connect(gold_db_file) gold_con = sqlite3.connect(gold_db_file)
gold_cur = gold_con.cursor() gold_cur = gold_con.cursor()
gold_cur.execute("SELECT COUNT(*) FROM tsk_objects") gold_cur.execute("SELECT COUNT(*) FROM tsk_objects")
@ -392,21 +405,30 @@ class Database:
def run_config_test(config_file): def run_config_test(config_file):
try: try:
global parsed global parsed
global errorem
global attachl
count = 0 count = 0
parsed = parse(config_file) parsed = parse(config_file)
case
counts = {} counts = {}
if parsed.getElementsByTagName("indir"): if parsed.getElementsByTagName("indir"):
case.input_dir = parsed.getElementsByTagName("indir")[0].getAttribute("value").encode().decode("utf_8") case.input_dir = parsed.getElementsByTagName("indir")[0].getAttribute("value").encode().decode("utf_8")
if parsed.getElementsByTagName("global_csv"): if parsed.getElementsByTagName("global_csv"):
case.global_csv = parsed.getElementsByTagName("global_csv")[0].getAttribute("value").encode().decode("utf_8") case.global_csv = parsed.getElementsByTagName("global_csv")[0].getAttribute("value").encode().decode("utf_8")
case.global_csv = Emailer.make_local_path(case.global_csv) case.global_csv = Emailer.make_local_path(case.global_csv)
if parsed.getElementsByTagName("golddir"):
case.gold_parse = parsed.getElementsByTagName("golddir")[0].getAttribute("value").encode().decode("utf_8")
case.gold_parse = Emailer.make_path(case.gold_parse, "tmp")
else:
case.gold_parse = case.gold
# Generate the top navbar of the HTML for easy access to all images # Generate the top navbar of the HTML for easy access to all images
values = [] values = []
for element in parsed.getElementsByTagName("image"): for element in parsed.getElementsByTagName("image"):
value = element.getAttribute("value").encode().decode("utf_8") value = element.getAttribute("value").encode().decode("utf_8")
if file_exists(value): if file_exists(value):
values.append(value) values.append(value)
else:
print("File: ", value, " doesn't exist")
count = len(values) count = len(values)
archives = Emailer.make_path(case.gold, "..") archives = Emailer.make_path(case.gold, "..")
arcount = 0 arcount = 0
@ -430,6 +452,8 @@ def run_config_test(config_file):
#Begin infiniloop #Begin infiniloop
if(newDay()): if(newDay()):
global daycount global daycount
setDay()
srcupdater.compile(errorem, attachl, parsed)
if(daycount > 0): if(daycount > 0):
print("starting process") print("starting process")
outputer = open("ScriptLog.txt", "a") outputer = open("ScriptLog.txt", "a")
@ -457,7 +481,8 @@ def run_config_test(config_file):
# The path must be guarenteed to be a correct path. # The path must be guarenteed to be a correct path.
def run_test(image_file, count): def run_test(image_file, count):
global parsed global parsed
print(args.config_file) global imgfail
imgfail = False
if image_type(image_file) == IMGTYPE.UNKNOWN: if image_type(image_file) == IMGTYPE.UNKNOWN:
printerror("Error: Image type is unrecognized:") printerror("Error: Image type is unrecognized:")
printerror(image_file + "\n") printerror(image_file + "\n")
@ -525,6 +550,10 @@ def run_test(image_file, count):
gold_path = case.gold gold_path = case.gold
img_gold = Emailer.make_path(case.gold, case.image_name) img_gold = Emailer.make_path(case.gold, case.image_name)
img_archive = Emailer.make_local_path("..", "output", "gold", case.image_name+"-archive.zip") img_archive = Emailer.make_local_path("..", "output", "gold", case.image_name+"-archive.zip")
if(not file_exists(img_archive)):
img_archive = Emailer.make_path(case.gold_parse, "..", case.image_name+"-archive.zip")
gold_path = case.gold_parse
img_gold = Emailer.make_path(gold_path, case.image_name)
extrctr = zipfile.ZipFile(img_archive, 'r', compression=zipfile.ZIP_DEFLATED) extrctr = zipfile.ZipFile(img_archive, 'r', compression=zipfile.ZIP_DEFLATED)
extrctr.extractall(gold_path) extrctr.extractall(gold_path)
extrctr.close extrctr.close
@ -616,17 +645,19 @@ def image_type(image_file):
def rebuild(): def rebuild():
# Errors to print # Errors to print
errors = [] errors = []
if(case.gold_parse == None):
case.gold_parse = case.gold
# Delete the current gold standards # Delete the current gold standards
gold_dir = Emailer.make_path(case.gold, case.image_name) gold_dir = Emailer.make_path(case.gold_parse)
clear_dir(gold_dir) clear_dir(gold_dir)
dbinpth = Emailer.make_path(case.output_dir, case.image_name, "AutopsyTestCase", "autopsy.db") dbinpth = Emailer.make_path(case.output_dir, case.image_name, "AutopsyTestCase", "autopsy.db")
dboutpth = Emailer.make_path(case.gold, case.image_name, "autopsy.db") dboutpth = Emailer.make_path(gold_dir, "autopsy.db")
if not os.path.exists(case.gold): if not os.path.exists(case.gold_parse):
os.makedirs(case.gold) os.makedirs(case.gold_parse)
if not os.path.exists(gold_dir): if not os.path.exists(gold_dir):
os.makedirs(gold_dir) os.makedirs(gold_dir)
copy_file(dbinpth, dboutpth) copy_file(dbinpth, dboutpth)
error_pth = Emailer.make_path(case.gold, case.image_name, case.image_name+"SortedErrors.txt") error_pth = Emailer.make_path(gold_dir, case.image_name+"SortedErrors.txt")
copy_file(case.sorted_log, error_pth) copy_file(case.sorted_log, error_pth)
# Rebuild the HTML report # Rebuild the HTML report
htmlfolder = "" htmlfolder = ""
@ -638,9 +669,9 @@ def rebuild():
html_path = Emailer.make_path(case.output_dir, case.image_name, html_path = Emailer.make_path(case.output_dir, case.image_name,
"AutopsyTestCase", "Reports") "AutopsyTestCase", "Reports")
try: try:
os.makedirs(os.path.join(case.gold, case.image_name, htmlfolder)) os.makedirs(os.path.join(gold_dir, htmlfolder))
for file in os.listdir(autopsy_html_path): for file in os.listdir(autopsy_html_path):
html_to = Emailer.make_path(case.gold, case.image_name, file.replace("HTML Report", "Report")) html_to = Emailer.make_path(gold_dir, file.replace("HTML Report", "Report"))
copy_dir(get_file_in_dir(autopsy_html_path, file), html_to) copy_dir(get_file_in_dir(autopsy_html_path, file), html_to)
except FileNotFoundException as e: except FileNotFoundException as e:
errors.append(e.error) errors.append(e.error)
@ -648,10 +679,9 @@ def rebuild():
errors.append("Error: Unknown fatal error when rebuilding the gold html report.") errors.append("Error: Unknown fatal error when rebuilding the gold html report.")
errors.append(str(e) + "\n") errors.append(str(e) + "\n")
oldcwd = os.getcwd() oldcwd = os.getcwd()
zpdir = case.gold zpdir = case.gold_parse
os.chdir(zpdir) os.chdir(zpdir)
img_gold = case.image_name img_gold = case.image_name
print(img_gold)
img_archive = Emailer.make_path("..", case.image_name+"-archive.zip") img_archive = Emailer.make_path("..", case.image_name+"-archive.zip")
comprssr = zipfile.ZipFile(img_archive, 'w',compression=zipfile.ZIP_DEFLATED) comprssr = zipfile.ZipFile(img_archive, 'w',compression=zipfile.ZIP_DEFLATED)
zipdir(img_gold, comprssr) zipdir(img_gold, comprssr)
@ -673,6 +703,8 @@ def zipdir(path, zip):
def compare_to_gold_db(): def compare_to_gold_db():
# SQLITE needs unix style pathing # SQLITE needs unix style pathing
gold_db_file = Emailer.make_path(case.gold, case.image_name, "autopsy.db") gold_db_file = Emailer.make_path(case.gold, case.image_name, "autopsy.db")
if(not file_exists(gold_db_file)):
gold_db_file = Emailer.make_path(case.gold_parse, case.image_name, "autopsy.db")
autopsy_db_file = Emailer.make_path(case.output_dir, case.image_name, autopsy_db_file = Emailer.make_path(case.output_dir, case.image_name,
"AutopsyTestCase", "autopsy.db") "AutopsyTestCase", "autopsy.db")
# Try to query the databases. Ignore any exceptions, the function will # Try to query the databases. Ignore any exceptions, the function will
@ -728,6 +760,8 @@ def compare_to_gold_db():
# the regression test against the gold standard html report # the regression test against the gold standard html report
def compare_to_gold_html(): def compare_to_gold_html():
gold_html_file = Emailer.make_path(case.gold, case.image_name, "Report", "index.html") gold_html_file = Emailer.make_path(case.gold, case.image_name, "Report", "index.html")
if(not file_exists(gold_html_file)):
gold_html_file = Emailer.make_path(case.gold_parse, case.image_name, "Report", "index.html")
htmlfolder = "" htmlfolder = ""
for fs in os.listdir(Emailer.make_path(case.output_dir, case.image_name, "AutopsyTestCase", "Reports")): for fs in os.listdir(Emailer.make_path(case.output_dir, case.image_name, "AutopsyTestCase", "Reports")):
if os.path.isdir(Emailer.make_path(case.output_dir, case.image_name, "AutopsyTestCase", "Reports", fs)): if os.path.isdir(Emailer.make_path(case.output_dir, case.image_name, "AutopsyTestCase", "Reports", fs)):
@ -752,9 +786,15 @@ def compare_to_gold_html():
ListGoldHTML.append(os.path.join(case.output_dir, case.image_name, "AutopsyTestCase", "Reports", htmlfolder, fs)) ListGoldHTML.append(os.path.join(case.output_dir, case.image_name, "AutopsyTestCase", "Reports", htmlfolder, fs))
#Find all new .html files belonging to this case #Find all new .html files belonging to this case
ListNewHTML = [] ListNewHTML = []
for fs in os.listdir(Emailer.make_path(case.gold, case.image_name)): if(os.path.exists(Emailer.make_path(case.gold, case.image_name))):
if (fs.endswith(".html")): for fs in os.listdir(Emailer.make_path(case.gold, case.image_name)):
ListNewHTML.append(Emailer.make_path(case.gold, case.image_name, fs)) if (fs.endswith(".html")):
ListNewHTML.append(Emailer.make_path(case.gold, case.image_name, fs))
if(not case.gold_parse == None or case.gold == case.gold_parse):
if(file_exists(Emailer.make_path(case.gold_parse, case.image_name))):
for fs in os.listdir(Emailer.make_path(case.gold_parse, case.image_name)):
if (fs.endswith(".html")):
ListNewHTML.append(Emailer.make_path(case.gold_parse, case.image_name, fs))
#ensure both reports have the same number of files and are in the same order #ensure both reports have the same number of files and are in the same order
if(len(ListGoldHTML) != len(ListNewHTML)): if(len(ListGoldHTML) != len(ListNewHTML)):
printerror("The reports did not have the same number of files. One of the reports may have been corrupted") printerror("The reports did not have the same number of files. One of the reports may have been corrupted")
@ -788,18 +828,21 @@ def compare_to_gold_html():
def compare_bb_artifacts(): def compare_bb_artifacts():
exceptions = [] exceptions = []
try: try:
global failedbool
global errorem
if database.gold_artifacts != database.autopsy_artifacts:
failedbool = True
global imgfail
imgfail = True
errorem += "There was a difference in the number of artifacts for " + case.image + ".\n"
for type_id in range(1, 13): for type_id in range(1, 13):
if database.gold_artifacts != database.autopsy_artifacts: if database.gold_artifacts[type_id] != database.autopsy_artifacts[type_id]:
error = str("Artifact counts do not match for type id %d. " % type_id) error = str("Artifact counts do not match for type id %d. " % type_id)
error += str("Gold: %d, Test: %d" % error += str("Gold: %d, Test: %d" %
(database.gold_artifacts[type_id], (database.gold_artifacts[type_id],
database.autopsy_artifacts[type_id])) database.autopsy_artifacts[type_id]))
exceptions.append(error) exceptions.append(error)
global failedbool return exceptions
global errorem
failedbool = True
errorem += "There was a difference in the number of artifacts for " + case.image + ".\n"
return exceptions
except Exception as e: except Exception as e:
exceptions.append("Error: Unable to compare blackboard_artifacts.\n") exceptions.append("Error: Unable to compare blackboard_artifacts.\n")
return exceptions return exceptions
@ -816,6 +859,8 @@ def compare_bb_attributes():
global failedbool global failedbool
global errorem global errorem
failedbool = True failedbool = True
global imgfail
imgfail = True
errorem += "There was a difference in the number of attributes for " + case.image + ".\n" errorem += "There was a difference in the number of attributes for " + case.image + ".\n"
return exceptions return exceptions
except Exception as e: except Exception as e:
@ -834,6 +879,8 @@ def compare_tsk_objects():
global failedbool global failedbool
global errorem global errorem
failedbool = True failedbool = True
global imgfail
imgfail = True
errorem += "There was a difference between the tsk object counts for " + case.image + " .\n" errorem += "There was a difference between the tsk object counts for " + case.image + " .\n"
return exceptions return exceptions
except Exception as e: except Exception as e:
@ -863,17 +910,15 @@ def generate_common_log():
for line in log: for line in log:
line = line.replace(rep_path, "CASE") line = line.replace(rep_path, "CASE")
if line.startswith("Exception"): if line.startswith("Exception"):
common_log.write("From " + file +":\n" + line + "\n") common_log.write(file +": " + line)
elif line.startswith("WARNING"):
common_log.write("From " + file +":\n" + line + "\n")
elif line.startswith("Error"): elif line.startswith("Error"):
common_log.write("From " + file +":\n" + line + "\n") common_log.write(file +": " + line)
elif line.startswith("SEVERE"): elif line.startswith("SEVERE"):
common_log.write("From " + file +":\n" + line + "\n") common_log.write(file +":" + line)
else: else:
warning_log.write("From " + file +":\n" + line + "\n") warning_log.write(file +": " + line)
log.close() log.close()
common_log.write("\n\n") common_log.write("\n")
common_log.close() common_log.close()
case.sorted_log = Emailer.make_local_path(case.output_dir, case.image_name, case.image_name + "SortedErrors.txt") case.sorted_log = Emailer.make_local_path(case.output_dir, case.image_name, case.image_name + "SortedErrors.txt")
srtcmdlst = ["sort", case.common_log_path, "-o", case.sorted_log] srtcmdlst = ["sort", case.common_log_path, "-o", case.sorted_log]
@ -883,25 +928,30 @@ def generate_common_log():
printerror(str(e) + "\n") printerror(str(e) + "\n")
logging.critical(traceback.format_exc()) logging.critical(traceback.format_exc())
def compare_errors(): def compare_errors():
gold_dir = Emailer.make_path(case.gold, case.image_name, case.image_name + "SortedErrors.txt") gold_dir = Emailer.make_path(case.gold, case.image_name, case.image_name + "SortedErrors.txt")
if(not file_exists(gold_dir)):
gold_dir = Emailer.make_path(case.gold_parse, case.image_name, case.image_name + "SortedErrors.txt")
common_log = codecs.open(case.sorted_log, "r", "utf_8") common_log = codecs.open(case.sorted_log, "r", "utf_8")
gold_log = codecs.open(gold_dir, "r", "utf_8") gold_log = codecs.open(gold_dir, "r", "utf_8")
gold_dat = gold_log.read() gold_dat = gold_log.read()
common_dat = common_log.read() common_dat = common_log.read()
patrn = re.compile("\d") patrn = re.compile("\d")
if (not((re.sub(patrn, 'd', gold_dat)) == (re.sub(patrn, 'd', common_dat)))): if (not((re.sub(patrn, 'd', gold_dat)) == (re.sub(patrn, 'd', common_dat)))):
diff_dir = Emailer.make_local_path(case.output_dir, case.image_name, "ErrorDiff.txt") diff_dir = Emailer.make_local_path(case.output_dir, case.image_name, case.image_name+"_AutopsyErrors-Diff.txt")
diff_file = open(diff_dir, "w") diff_file = open(diff_dir, "w")
dffcmdlst = ["diff", case.sorted_log, gold_dir] dffcmdlst = ["diff", case.sorted_log, gold_dir]
subprocess.call(dffcmdlst, stdout = diff_file) subprocess.call(dffcmdlst, stdout = diff_file)
global attachl global attachl
global errorem global errorem
global failedbool global failedbool
attachl.append(case.sorted_log)
attachl.append(diff_dir) attachl.append(diff_dir)
errorem += "There was a difference in the exceptions Log.\n" errorem += "There was a difference in the exceptions Log for " + case.image_name + ".\n"
print("Exceptions didn't match.\n") print("Exceptions didn't match.\n")
failedbool = True failedbool = True
global imgfail
imgfail = True
# Fill in the global case's variables that require the log files # Fill in the global case's variables that require the log files
def fill_case_data(): def fill_case_data():
@ -1203,6 +1253,7 @@ def printout(string):
def generate_html(): def generate_html():
# If the file doesn't exist yet, this is the first case to run for # If the file doesn't exist yet, this is the first case to run for
# this test, so we need to make the start of the html log # this test, so we need to make the start of the html log
global imgfail
if not file_exists(case.html_log): if not file_exists(case.html_log):
write_html_head() write_html_head()
try: try:
@ -1217,9 +1268,12 @@ def generate_html():
<a href='#" + case.image_name + "-general'>General Output</a> |\ <a href='#" + case.image_name + "-general'>General Output</a> |\
<a href='#" + case.image_name + "-logs'>Logs</a>\ <a href='#" + case.image_name + "-logs'>Logs</a>\
</h2>" </h2>"
# The script errors found # The script errors found
errors = "<div id='errors'>\ if imgfail:
ids = 'errors1'
else:
ids = 'errors'
errors = "<div id='" + ids + "'>\
<h2><a name='" + case.image_name + "-errors'>Errors and Warnings</a></h2>\ <h2><a name='" + case.image_name + "-errors'>Errors and Warnings</a></h2>\
<hr color='#FF0000'>" <hr color='#FF0000'>"
# For each error we have logged in the case # For each error we have logged in the case
@ -1234,7 +1288,7 @@ def generate_html():
# Links to the logs # Links to the logs
logs = "<div id='logs'>\ logs = "<div id='logs'>\
<h2><a name='" + case.image_name + "-logs'>Logs</a></h2>\ <h2><a name='" + case.image_name + "-logs'>Logs</a></h2>\
<hr color='#00a00f'>" <hr color='#282828'>"
logs_path = Emailer.make_local_path(case.output_dir, case.image_name, "logs") logs_path = Emailer.make_local_path(case.output_dir, case.image_name, "logs")
for file in os.listdir(logs_path): for file in os.listdir(logs_path):
logs += "<p><a href='file:\\" + Emailer.make_path(logs_path, file) + "' target='_blank'>" + file + "</a></p>" logs += "<p><a href='file:\\" + Emailer.make_path(logs_path, file) + "' target='_blank'>" + file + "</a></p>"
@ -1243,7 +1297,7 @@ def generate_html():
# All the testing information # All the testing information
info = "<div id='info'>\ info = "<div id='info'>\
<h2><a name='" + case.image_name + "-info'>Information</a></h2>\ <h2><a name='" + case.image_name + "-info'>Information</a></h2>\
<hr color='#0005FF'>\ <hr color='#282828'>\
<table cellspacing='5px'>" <table cellspacing='5px'>"
# The individual elements # The individual elements
info += "<tr><td>Image Path:</td>" info += "<tr><td>Image Path:</td>"
@ -1332,13 +1386,14 @@ def write_html_head():
h1 span { font-size: 12px; font-weight: 100; }\ h1 span { font-size: 12px; font-weight: 100; }\
h2 { font-family: Tahoma; padding: 0px; margin: 0px; }\ h2 { font-family: Tahoma; padding: 0px; margin: 0px; }\
hr { width: 100%; height: 1px; border: none; margin-top: 10px; margin-bottom: 10px; }\ hr { width: 100%; height: 1px; border: none; margin-top: 10px; margin-bottom: 10px; }\
#errors { background: #FFCFCF; border: 1px solid #FF0000; color: #FF0000; padding: 10px; margin: 20px; }\ #errors { background: #CCCCCC; border: 1px solid #282828; color: #282828; padding: 10px; margin: 20px; }\
#info { background: #D2D3FF; border: 1px solid #0005FF; color: #0005FF; padding: 10px; margin: 20px; }\ #errors1 { background: #CC0000; border: 1px solid #282828; color: #282828; padding: 10px; margin: 20px; }\
#info { background: #CCCCCC; border: 1px solid #282828; color: #282828; padding: 10px; margin: 20px; }\
#general { background: #CCCCCC; border: 1px solid #282828; color: #282828; padding: 10px; margin: 20px; }\ #general { background: #CCCCCC; border: 1px solid #282828; color: #282828; padding: 10px; margin: 20px; }\
#logs { background: #8cff97; border: 1px solid #00820c; color: #00820c; padding: 10px; margin: 20px; }\ #logs { background: #CCCCCC; border: 1px solid #282828; color: #282828; padding: 10px; margin: 20px; }\
#errors p, #info p, #general p, #logs p { pading: 0px; margin: 0px; margin-left: 5px; }\ #errors p, #info p, #general p, #logs p { pading: 0px; margin: 0px; margin-left: 5px; }\
#info table td { color: #0005FF; font-size: 12px; min-width: 225px; }\ #info table td { color: ##282828; font-size: 12px; min-width: 225px; }\
#logs a { color: #00820c; }\ #logs a { color: ##282828; }\
</style>\ </style>\
<body>" <body>"
html.write(head) html.write(head)
@ -1361,7 +1416,7 @@ def html_add_images(full_image_names):
links = [] links = []
for full_name in full_image_names: for full_name in full_image_names:
name = case.get_image_name(full_name) name = case.get_image_name(full_name)
links.append("<a href='#" + name + "'>" + name + "</a>") links.append("<a href='#" + name + "(0)'>" + name + "</a>")
html.write("<p align='center'>" + (" | ".join(links)) + "</p>") html.write("<p align='center'>" + (" | ".join(links)) + "</p>")
@ -1538,6 +1593,7 @@ Options:
-e ex Prints out all errors containing ex. -e ex Prints out all errors containing ex.
-l cfg Runs from configuration file cfg. -l cfg Runs from configuration file cfg.
-c Runs in a loop over the configuration file until canceled. Must be used in conjunction with -l -c Runs in a loop over the configuration file until canceled. Must be used in conjunction with -l
-fr Will not try download gold standard images
""" """
@ -1587,6 +1643,8 @@ def execute_test():
global failedbool global failedbool
global html global html
global attachl global attachl
if(not dir_exists(Emailer.make_path("..", "output", "results"))):
os.makedirs(Emailer.make_path("..", "output", "results",))
case.output_dir = Emailer.make_path("..", "output", "results", time.strftime("%Y.%m.%d-%H.%M.%S")) case.output_dir = Emailer.make_path("..", "output", "results", time.strftime("%Y.%m.%d-%H.%M.%S"))
os.makedirs(case.output_dir) os.makedirs(case.output_dir)
case.common_log = "AutopsyErrors.txt" case.common_log = "AutopsyErrors.txt"
@ -1626,6 +1684,8 @@ def execute_test():
logres = search_common_log("TskCoreException") logres = search_common_log("TskCoreException")
if (len(logres)>0): if (len(logres)>0):
failedbool = True failedbool = True
global imgfail
imgfail = True
global errorem global errorem
errorem += "Autopsy Nightly test failed.\n" errorem += "Autopsy Nightly test failed.\n"
passFail = False passFail = False
@ -1633,6 +1693,7 @@ def execute_test():
errorem += lm errorem += lm
html.close() html.close()
if failedbool: if failedbool:
passFail = False
attachl.append(case.common_log_path) attachl.append(case.common_log_path)
attachl.insert(0, html.name) attachl.insert(0, html.name)
else: else:
@ -1641,7 +1702,7 @@ def execute_test():
passFail = True passFail = True
attachl = [] attachl = []
if not args.gold_creation: if not args.gold_creation:
Emailer.send_email(parsed, errorem, attachl, html) Emailer.send_email(parsed, errorem, attachl, passFail)
def secs_till_tommorow(): def secs_till_tommorow():
seconds = (23*3600)-(int(strftime("%H", localtime()))*3600) seconds = (23*3600)-(int(strftime("%H", localtime()))*3600)
@ -1664,17 +1725,6 @@ def main():
global daycount global daycount
global redo global redo
global passed global passed
inpvar = raw_input("Your input images may be out of date, do you want to update?(y/n): ")
if(inpvar.lower() == 'y' or inpvar.lower() == 'yes'):
antin = ["ant"]
antin.append("-f")
antin.append(os.path.join("..","..","build.xml"))
antin.append("test-download-imgs")
if SYS is OS.CYGWIN:
subprocess.call(antin)
elif SYS is OS.WIN:
theproc = subprocess.Popen(antin, shell = True, stdout=subprocess.PIPE)
theproc.communicate()
daycount = 0 daycount = 0
failedbool = False failedbool = False
redo = False redo = False
@ -1688,21 +1738,29 @@ def main():
# The arguments were given wrong: # The arguments were given wrong:
if not args.parse(): if not args.parse():
case.reset() case.reset()
pass return
if(not args.fr):
antin = ["ant"]
antin.append("-f")
antin.append(os.path.join("..","..","build.xml"))
antin.append("test-download-imgs")
if SYS is OS.CYGWIN:
subprocess.call(antin)
elif SYS is OS.WIN:
theproc = subprocess.Popen(antin, shell = True, stdout=subprocess.PIPE)
theproc.communicate()
# Otherwise test away! # Otherwise test away!
else: execute_test()
if(args.daily and args.contin):
time.sleep(secs_till_tommorow())
while args.contin:
redo = False
attachl = []
errorem = "The test standard didn't match the gold standard.\n"
failedbool = False
passed = False
execute_test() execute_test()
if(args.daily and args.contin): case = TestAutopsy()
time.sleep(secs_till_tommorow())
while args.contin:
redo = False
attachl = []
errorem = "The test standard didn't match the gold standard.\n"
failedbool = False
passed = False
execute_test()
case = TestAutopsy()
class OS: class OS:
LINUX, MAC, WIN, CYGWIN = range(4) LINUX, MAC, WIN, CYGWIN = range(4)

View File

@ -0,0 +1,6 @@
00000000000000000000000000000000000000000|md5sum
00000000000000000000000000000000000000001|NSRLcreator.txt
0D4A1C9ED5A49CAF22FD5F52C666DE2C|0000000000000045
35BA15EC1C3CF03531282147DB10A089|0000000000000100
91C66396EEC4BCEEAF6EDE7A48F60C63|0000000000000152
A99F69068F958CF412E7F8B8A0142B41|0000000000000000

View File

@ -0,0 +1,6 @@
00000000000000000000000000000000000000000|md5sum
00000000000000000000000000000000000000001|notablehashescreator.txt
48199F51973F317459E80E18DC744B12|0000000000000000
5CCB10AEA1EC335139715D4AA44D0EE0|0000000000000062
94610B03A4295300AA29C3364DB18683|0000000000000108
A06B65C36E0E5A8229749375C3AAC4B1|0000000000000160

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<keyword_lists>
<keyword_list created="2012-03-23 11:06:17" modified="2012-03-23 11:08:48" name="notable_keywords" use_for_ingest="true">
<keyword literal="true">Jean</keyword>
<keyword literal="true">Personalized</keyword>
<keyword literal="true">DIRT</keyword>
<keyword literal="true">Osama</keyword>
<keyword literal="true">bomb</keyword>
<keyword literal="true">hacking</keyword>
<keyword literal="true">molotov</keyword>
<keyword literal="true">nuclear</keyword>
<keyword literal="true">صحافة و إعلام</keyword>
<keyword literal="true">مطلوبا</keyword>
</keyword_list>
</keyword_lists>

View File

@ -25,12 +25,12 @@ def send_email(parsed, errorem, attachl, passFail):
# Create the container (outer) email message. # Create the container (outer) email message.
msg = MIMEMultipart() msg = MIMEMultipart()
if(passFail): if(passFail):
msg['Subject'] = 'Autopsy Nightly test passed.' msg['Subject'] = '[Test]Autopsy test passed.'
else: else:
msg['Subject'] = 'Autopsy Nightly test failed.' msg['Subject'] = '[Test]Autopsy test failed.'
# me == the sender's email address # me == the sender's email address
# family = the list of all recipients' email addresses # family = the list of all recipients' email addresses
msg['From'] = 'AutopsyContinuousTest' msg['From'] = 'AutopsyTest'
msg['To'] = toval msg['To'] = toval
msg.preamble = 'This is a test' msg.preamble = 'This is a test'
container = MIMEText(errorem, 'plain') container = MIMEText(errorem, 'plain')

View File

@ -15,14 +15,17 @@ import xml
from xml.dom.minidom import parse, parseString from xml.dom.minidom import parse, parseString
import Emailer import Emailer
def compile(): def compile(errore, attachli, parsedin):
global redo global redo
global tryredo global tryredo
global failedbool global failedbool
global errorem global errorem
errorem = errore
global attachl global attachl
attachl = attachli
global passed global passed
global parsed global parsed
parsed = parsedin
passed = True passed = True
tryredo = False tryredo = False
redo = True redo = True
@ -79,9 +82,11 @@ def vsBuild():
global passed global passed
global parsed global parsed
#Please ensure that the current working directory is $autopsy/testing/script #Please ensure that the current working directory is $autopsy/testing/script
oldpath = os.getcwd()
os.chdir(os.path.join("..", "..", "..","sleuthkit", "win32"))
vs = [] vs = []
vs.append("/cygdrive/c/windows/microsoft.NET/framework/v4.0.30319/MSBuild.exe") vs.append("/cygdrive/c/windows/microsoft.NET/framework/v4.0.30319/MSBuild.exe")
vs.append(os.path.join("..", "..", "..","sleuthkit", "win32", "Tsk-win.sln")) vs.append(os.path.join("Tsk-win.sln"))
vs.append("/p:configuration=release") vs.append("/p:configuration=release")
vs.append("/p:platform=win32") vs.append("/p:platform=win32")
vs.append("/t:clean") vs.append("/t:clean")
@ -91,6 +96,7 @@ def vsBuild():
VSout = open(VSpth, 'a') VSout = open(VSpth, 'a')
subprocess.call(vs, stdout=VSout) subprocess.call(vs, stdout=VSout)
VSout.close() VSout.close()
os.chdir(oldpath)
chk = os.path.join("..", "..", "..","sleuthkit", "win32", "Release", "libtsk_jni.dll") chk = os.path.join("..", "..", "..","sleuthkit", "win32", "Release", "libtsk_jni.dll")
try: try:
open(chk) open(chk)
@ -152,18 +158,14 @@ def antBuild(which, Build):
def main(): def main():
global parsed errore = ""
global errorem attachli = []
global attachl
errorem = ""
attachl = []
config_file = "" config_file = ""
arg = sys.argv.pop(0) arg = sys.argv.pop(0)
arg = sys.argv.pop(0) arg = sys.argv.pop(0)
config_file = arg config_file = arg
print(config_file) parsedin = parse(config_file)
parsed = parse(config_file) compile(errore, attachli, parsedin)
compile()
class OS: class OS:
LINUX, MAC, WIN, CYGWIN = range(4) LINUX, MAC, WIN, CYGWIN = range(4)