Added links to logs in the tester HTML output.

This commit is contained in:
devin148 2012-08-23 15:44:45 -04:00
parent 22e4d0e73e
commit ec4822d091

View File

@ -658,7 +658,7 @@ def compare_tsk_objects():
# Generate the "common log": a log of all exceptions and warnings # Generate the "common log": a log of all exceptions and warnings
# from each log file generated by Autopsy # from each log file generated by Autopsy
def generate_common_log(): def generate_common_log():
try: #try:
logs_path = make_local_path(case.output_dir, case.image_name, "logs") logs_path = make_local_path(case.output_dir, case.image_name, "logs")
common_log = open(case.common_log, "a") common_log = open(case.common_log, "a")
common_log.write("--------------------------------------------------\n") common_log.write("--------------------------------------------------\n")
@ -669,17 +669,17 @@ def generate_common_log():
lines = log.readlines() lines = log.readlines()
for line in lines: for line in lines:
if "exception" in line.lower(): if "exception" in line.lower():
common_log.write("From " + log.name[log.name.rfind("/")+1:] +":\n" + line + "\n") common_log.write("From " + file +":\n" + line + "\n")
if "warning" in line.lower(): if "warning" in line.lower():
common_log.write("From " + log.name[log.name.rfind("/")+1:] +":\n" + line + "\n") common_log.write("From " + file +":\n" + line + "\n")
if "error" in line.lower(): if "error" in line.lower():
common_log.write("From " + log.name[log.name.rfind("/")+1:] +":\n" + line + "\n") common_log.write("From " + file +":\n" + line + "\n")
log.close() log.close()
common_log.write("\n\n") common_log.write("\n\n")
common_log.close() common_log.close()
except Exception as e: #except Exception as e:
printerror("Error: Unable to generate the common log.") # printerror("Error: Unable to generate the common log.")
printerror(str(e)) # printerror(str(e))
# 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():
@ -781,6 +781,7 @@ def generate_csv(csv_path):
vars.append( str(case.ingest_messages) ) vars.append( str(case.ingest_messages) )
vars.append( str(case.indexed_files) ) vars.append( str(case.indexed_files) )
vars.append( str(case.indexed_chunks) ) vars.append( str(case.indexed_chunks) )
vars.append( str(len(search_log_set("autopsy", "Stopping ingest due to low disk space on disk"))) )
vars.append( str(database.autopsy_objects) ) vars.append( str(database.autopsy_objects) )
vars.append( str(database.get_artifacts_count()) ) vars.append( str(database.get_artifacts_count()) )
vars.append( str(database.autopsy_attributes) ) vars.append( str(database.autopsy_attributes) )
@ -826,6 +827,7 @@ def csv_header(csv_path):
titles.append("Ingest Messages Count") titles.append("Ingest Messages Count")
titles.append("Indexed Files Count") titles.append("Indexed Files Count")
titles.append("Indexed File Chunks Count") titles.append("Indexed File Chunks Count")
titles.append("Out Of Disk Space")
titles.append("Tsk Objects Count") titles.append("Tsk Objects Count")
titles.append("Artifacts Count") titles.append("Artifacts Count")
titles.append("Attributes Count") titles.append("Attributes Count")
@ -991,8 +993,10 @@ def generate_html():
<h2 align='center'>\ <h2 align='center'>\
<a href='#" + case.image_name + "-errors'>Errors and Warnings</a> |\ <a href='#" + case.image_name + "-errors'>Errors and Warnings</a> |\
<a href='#" + case.image_name + "-info'>Information</a> |\ <a href='#" + case.image_name + "-info'>Information</a> |\
<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>\
</h2>" </h2>"
# The script errors found # The script errors found
errors = "<div id='errors'>\ errors = "<div id='errors'>\
<h2><a name='" + case.image_name + "-errors'>Errors and Warnings</a></h2>\ <h2><a name='" + case.image_name + "-errors'>Errors and Warnings</a></h2>\
@ -1005,6 +1009,16 @@ def generate_html():
if "\n" in error: if "\n" in error:
errors += "<br />" errors += "<br />"
errors += "</div>" errors += "</div>"
# Links to the logs
logs = "<div id='logs'>\
<h2><a name='" + case.image_name + "-logs'>Logs</a></h2>\
<hr color='#00a00f'>"
logs_path = make_local_path(case.output_dir, case.image_name, "logs")
for file in os.listdir(logs_path):
logs += "<p><a href='file:\\" + make_path(logs_path, file) + "' target='_blank'>" + file + "</a></p>"
logs += "</div>"
# 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>\
@ -1049,6 +1063,9 @@ def generate_html():
info += "<td>" + str(case.indexed_files) + "</td></tr>" info += "<td>" + str(case.indexed_files) + "</td></tr>"
info += "<tr><td>Indexed File Chunks Count:</td>" info += "<tr><td>Indexed File Chunks Count:</td>"
info += "<td>" + str(case.indexed_chunks) + "</td></tr>" info += "<td>" + str(case.indexed_chunks) + "</td></tr>"
info += "<tr><td>Out Of Disk Space:\
<p style='font-size: 11px;'>(will skew other test results)</p></td>"
info += "<td>" + str(len(search_log_set("autopsy", "Stopping ingest due to low disk space on disk"))) + "</td></tr>"
info += "<tr><td>TSK Objects Count:</td>" info += "<tr><td>TSK Objects Count:</td>"
info += "<td>" + str(database.autopsy_objects) + "</td></tr>" info += "<td>" + str(database.autopsy_objects) + "</td></tr>"
info += "<tr><td>Artifacts Count:</td>" info += "<tr><td>Artifacts Count:</td>"
@ -1069,12 +1086,10 @@ def generate_html():
output += "<br />" output += "<br />"
output += "</div>" output += "</div>"
foot = "</body>\
</html>"
html.write(title) html.write(title)
html.write(errors) html.write(errors)
html.write(info) html.write(info)
html.write(logs)
html.write(output) html.write(output)
html.close() html.close()
except Exception as e: except Exception as e:
@ -1098,8 +1113,10 @@ def write_html_head():
#errors { background: #FFCFCF; border: 1px solid #FF0000; color: #FF0000; padding: 10px; margin: 20px; }\ #errors { background: #FFCFCF; border: 1px solid #FF0000; color: #FF0000; padding: 10px; margin: 20px; }\
#info { background: #D2D3FF; border: 1px solid #0005FF; color: #0005FF; padding: 10px; margin: 20px; }\ #info { background: #D2D3FF; border: 1px solid #0005FF; color: #0005FF; 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; }\
#errors p, #info p, #general p { pading: 0px; margin: 0px; margin-left: 5px; }\ #logs { background: #8cff97; border: 1px solid #00820c; color: #00820c; padding: 10px; margin: 20px; }\
#info table td { color: #0005FF; font-size: 12px; min-width: 215px; }\ #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; }\
#logs a { color: #00820c; }\
</style>\ </style>\
<body>" <body>"
html.write(head) html.write(head)