Commit 41e76907 by dorp

fixed some more escaping errors

parent 68da4ad4
...@@ -94,6 +94,12 @@ def check_if_list_empty(ls): ...@@ -94,6 +94,12 @@ def check_if_list_empty(ls):
return empty_ls return empty_ls
def filter_chars_in_list(list_of_strings):
return [
filter_latex_special_chars(item) for item in list_of_strings
]
def split_hash(hash_value): def split_hash(hash_value):
if len(hash_value) > 61: if len(hash_value) > 61:
hash_value = hash_value[:61] + ' ' + hash_value[61:] hash_value = hash_value[:61] + ' ' + hash_value[61:]
......
...@@ -8,7 +8,7 @@ import jinja2 ...@@ -8,7 +8,7 @@ import jinja2
from common_helper_process import execute_shell_command_get_return_code from common_helper_process import execute_shell_command_get_return_code
from jinja_filters.filter import ( from jinja_filters.filter import (
nice_unix_time, nice_number_filter, filter_latex_special_chars, count_elements_in_list, nice_unix_time, nice_number_filter, filter_latex_special_chars, count_elements_in_list, filter_chars_in_list,
convert_base64_to_png_filter, check_if_list_empty, split_hash, split_output_lines, byte_number_filter convert_base64_to_png_filter, check_if_list_empty, split_hash, split_output_lines, byte_number_filter
) )
from rest_import.rest import create_request_url, request_firmware_data from rest_import.rest import create_request_url, request_firmware_data
...@@ -41,6 +41,7 @@ def _setup_jinja_filters(environment): ...@@ -41,6 +41,7 @@ def _setup_jinja_filters(environment):
environment.filters['elements_count'] = count_elements_in_list environment.filters['elements_count'] = count_elements_in_list
environment.filters['base64_to_png'] = convert_base64_to_png_filter environment.filters['base64_to_png'] = convert_base64_to_png_filter
environment.filters['check_list'] = check_if_list_empty environment.filters['check_list'] = check_if_list_empty
environment.filters['filter_list'] = filter_chars_in_list
environment.filters['split_hash'] = split_hash environment.filters['split_hash'] = split_hash
environment.filters['split_output_lines'] = split_output_lines environment.filters['split_output_lines'] = split_output_lines
...@@ -102,10 +103,13 @@ def execute_pdflatex(tmp_dir): ...@@ -102,10 +103,13 @@ def execute_pdflatex(tmp_dir):
os.chdir(current_dir) os.chdir(current_dir)
def generate_pdf_report(firmware_uid="bab8d95fc42176abc9126393b6035e4012ebccc82c91e521b91d3bcba4832756_3801088" def generate_pdf_report(firmware_uid):
""):
request_url = create_request_url(firmware_uid) request_url = create_request_url(firmware_uid)
firmware_analyses, firmware_meta_data = request_firmware_data(request_url) try:
firmware_analyses, firmware_meta_data = request_firmware_data(request_url)
except KeyError:
logging.warning('No firmware found with UID {}'.format(firmware_uid))
return None
jinja_environment = _set_jinja_env() jinja_environment = _set_jinja_env()
_setup_jinja_filters(environment=jinja_environment) _setup_jinja_filters(environment=jinja_environment)
...@@ -124,3 +128,5 @@ def generate_pdf_report(firmware_uid="bab8d95fc42176abc9126393b6035e4012ebccc82c ...@@ -124,3 +128,5 @@ def generate_pdf_report(firmware_uid="bab8d95fc42176abc9126393b6035e4012ebccc82c
pdf_filename = create_report_filename(firmware_meta_data) pdf_filename = create_report_filename(firmware_meta_data)
shutil.move(Path(tmp_dir, 'main.pdf'), Path('.', pdf_filename)) shutil.move(Path(tmp_dir, 'main.pdf'), Path('.', pdf_filename))
return None
...@@ -78,7 +78,6 @@ if __name__ == '__main__': ...@@ -78,7 +78,6 @@ if __name__ == '__main__':
_setup_logging(config, args.debug) _setup_logging(config, args.debug)
logging.info(args.config_file) logging.info(args.config_file)
# insert your program here
generate_pdf_report(args.UID) generate_pdf_report(args.UID)
sys.exit() sys.exit(0)
...@@ -7,19 +7,19 @@ ...@@ -7,19 +7,19 @@
\hline \hline
IPs v4 IPs v4
\BLOCK{for ip in selected_analysis['ips_v4'] | check_list} \BLOCK{for ip in selected_analysis['ips_v4'] | check_list | filter_list}
& \VAR{ip} \\ & \VAR{ip} \\
\BLOCK{endfor} \BLOCK{endfor}
\hline \hline
IPs v6 IPs v6
\BLOCK{for ip in selected_analysis['ips_v6'] | check_list} \BLOCK{for ip in selected_analysis['ips_v6'] | check_list | filter_list}
& \VAR{ip} \\ & \VAR{ip} \\
\BLOCK{endfor} \BLOCK{endfor}
\hline \hline
URIs URIs
\BLOCK{for uri in selected_analysis['uris'] | check_list} \BLOCK{for uri in selected_analysis['uris'] | check_list | filter_list}
& \VAR{uri} \\ & \VAR{uri} \\
\BLOCK{endfor} \BLOCK{endfor}
\hline \hline
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
\HRule \\[0.4cm] \HRule \\[0.4cm]
{\fontfamily{lmss}\selectfont {\fontfamily{lmss}\selectfont
{\Large \bfseries Firmware Analysis of \VAR{meta_data['hid']}}\\[0.4cm] {\Large \bfseries Firmware Analysis of \VAR{meta_data['hid'] | filter_chars }}\\[0.4cm]
} }
\HRule \\[1.5cm] \HRule \\[1.5cm]
......
\begin{tabular}{|p{3cm}|p{11.5cm}|} \begin{tabular}{|p{3cm}|p{11.5cm}|}
\hline \hline
HID & \VAR{meta_data['hid']}\\ HID & \VAR{meta_data['hid'] | filter_chars}\\
\hline \hline
Device Name & \VAR{meta_data['device_name']}\\ Device Name & \VAR{meta_data['device_name'] | filter_chars}\\
\hline \hline
Vendor & \VAR{meta_data['vendor']}\\ Vendor & \VAR{meta_data['vendor'] | filter_chars}\\
\hline \hline
Device Class & \VAR{meta_data['device_class']}\\ Device Class & \VAR{meta_data['device_class'] | filter_chars}\\
\hline \hline
Version & \VAR{meta_data['version']}\\ Version & \VAR{meta_data['version'] | filter_chars}\\
\hline \hline
Release Date & \VAR{meta_data['release_date']}\\ Release Date & \VAR{meta_data['release_date']}\\
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment