Commit 87e257d8 by dorp

refactored templates (step 1)

parent 989ea9e7
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time}\\
\hline
\subsection*{Binwalk (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version'] | filter_chars} \\
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
\multicolumn{2}{|p{14.5cm}|}{Signature Analysis:} \\
......@@ -22,4 +20,5 @@
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\ No newline at end of file
\end{longtable}
}
\ No newline at end of file
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
\subsection*{Exploit Mitigation (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
\BLOCK{if selected_analysis['summary']}
NX
&
......@@ -41,4 +38,5 @@
\hline
\BLOCK{endif}
\end{longtable}
\end{longtable}
}
\ No newline at end of file
\subsection*{hashes (v. \VAR{selected_analysis['plugin_version']})}
\subsection*{Hashes (v. \VAR{selected_analysis['plugin_version']})}
{\fontfamily{lmss}\selectfont
\begin{tabular}{|p{3cm}|p{11.5cm}|}
......
\subsection*{file type (v. \VAR{selected_analysis['plugin_version']})}
\subsection*{File Type (v. \VAR{selected_analysis['plugin_version']})}
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
......
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\subsection*{\VAR{plugin_name | plugin_name | filter_chars} (v. \VAR{selected_analysis['plugin_version'] | filter_chars})}
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
......@@ -13,4 +16,5 @@
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\ No newline at end of file
\end{longtable}
}
\ No newline at end of file
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
\subsection*{IPs and URIs (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version']}\\
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
IPs v4
\BLOCK{for ip in selected_analysis['ips_v4'] | check_list | filter_list}
& \VAR{ip} \\
......@@ -32,4 +29,5 @@
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\end{longtable}
}
\ No newline at end of file
\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
......@@ -37,102 +38,91 @@
\section*{Analysis}
\BLOCK{if "base64_decoder" in analysis}
\subsection*{base64 decoder}
{\fontfamily{lmss}\selectfont
\input{base64_decoder.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "binwalk" in analysis}
\subsection*{binwalk}
{\fontfamily{lmss}\selectfont
\input{binwalk.tex}
}
\BLOCK{endif}
\BLOCK{if "cpu_architcture" in analysis}
\subsection*{cpu architecture}
{\fontfamily{lmss}\selectfont
\newpage
\BLOCK{if "cpu_architecture" in analysis}
\input{cpu_architecture.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "crypto_material" in analysis}
\subsection*{crypto material}
{\fontfamily{lmss}\selectfont
\input{crypto_material.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "exploit_mitigations" in analysis}
\subsection*{exploit mitigations}
{\fontfamily{lmss}\selectfont
\input{exploit_mitigations.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "file_hashes" in analysis}
\input{file_hashes.tex}
\BLOCK{endif}
\newpage
\BLOCK{if "file_type" in analysis}
\input{file_type.tex}
\BLOCK{endif}
\newpage
\BLOCK{if "init_systems" in analysis}
\subsection*{init systems}
{\fontfamily{lmss}\selectfont
\input{init_systems.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "ip_and_uri_finder" in analysis}
\subsection*{ip and uri finder}
{\fontfamily{lmss}\selectfont
\input{ip_and_uri_finder.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "software_components" in analysis}
\subsection*{software components}
{\fontfamily{lmss}\selectfont
\input{software_components.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "printable_strings" in analysis}
\subsection*{printable strings}
{\fontfamily{lmss}\selectfont
\input{printable_strings.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "users_and_passwords" in analysis}
\subsection*{users and passwords}
{\fontfamily{lmss}\selectfont
\input{users_and_passwords.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "string_evaluator" in analysis}
\subsection*{string evaluator}
{\fontfamily{lmss}\selectfont
\input{string_evaluator.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "unpacker" in analysis}
\subsection*{unpacker}
{\fontfamily{lmss}\selectfont
\input{unpacker.tex}
}
\BLOCK{endif}
\newpage
\BLOCK{if "malware_scanner" in analysis}
\subsection*{malware scanner}
{\fontfamily{lmss}\selectfont
\input{malware_scanner.tex}
}
\BLOCK{endif}
\end{document}
......
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
\subsection*{Malware (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
MD5 & \VAR{selected_analysis['md5']} \\
......@@ -39,4 +37,5 @@
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\end{longtable}
}
\ No newline at end of file
\begin{tabular}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time}\\
\hline
\subsection*{String Stats (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version']}\\
{\fontfamily{lmss}\selectfont
\begin{tabular}{|p{3cm}|p{11.5cm}|}
\hline
String Count & \VAR{selected_analysis['strings'] | elements_count}\\
\hline
\end{tabular}
\ No newline at end of file
\end{tabular}
}
\ No newline at end of file
\begin{tabular}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time}\\
\hline
\subsection*{String Eval Stats (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version']}\\
{\fontfamily{lmss}\selectfont
\begin{tabular}{|p{3cm}|p{11.5cm}|}
\hline
String Count & \VAR{selected_analysis['string_eval'] | elements_count}\\
\hline
\end{tabular}
\ No newline at end of file
\end{tabular}
}
\ No newline at end of file
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
\subsection*{Unpacker (v. \VAR{selected_analysis['plugin_version']})}
Plugin Version & \VAR{selected_analysis['plugin_version'] | filter_chars} \\
{\fontfamily{lmss}\selectfont
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Plugin & \VAR{selected_analysis['plugin_used'] | filter_chars} \\
\hline
......@@ -21,4 +18,5 @@
Entropy & \VAR{selected_analysis['entropy'] | nice_number} \\
\hline
\end{longtable}
\ No newline at end of file
\end{longtable}
}
\ No newline at end of file
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time}\\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']}\\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\ No newline at end of file
......@@ -123,6 +123,11 @@ def create_jinja_environment(templates_to_use='default'):
return environment
def plugin_name(name):
parts = name.split('_')
return ' '.join(('{}{}'.format(part[0:1].upper(), part[1:]) for part in parts))
def _add_filters_to_jinja(environment):
environment.filters['number_format'] = byte_number_filter
environment.filters['nice_unix_time'] = nice_unix_time
......@@ -131,6 +136,7 @@ def _add_filters_to_jinja(environment):
environment.filters['elements_count'] = len
environment.filters['base64_to_png'] = convert_base64_to_png_filter
environment.filters['check_list'] = lambda x: x if x else ['list is empty']
environment.filters['plugin_name'] = plugin_name
environment.filters['filter_list'] = filter_chars_in_list
environment.filters['split_hash'] = split_hash
environment.filters['split_output_lines'] = split_output_lines
......@@ -156,4 +162,4 @@ class Engine:
except jinja2.TemplateNotFound:
logging.warning('Falling back on generic template for {}'.format(plugin))
template = self._environment.get_template(GENERIC_TEMPLATE)
return template.render(selected_analysis=analysis, tmp_dir=self._tmp_dir)
return template.render(plugin_name=plugin, selected_analysis=analysis, tmp_dir=self._tmp_dir)
......@@ -33,5 +33,5 @@ def test_request_firmware_data_bad_response(monkeypatch): # pylint: disable=inv
def test_create_request_url():
assert create_request_url('X', None) == '{}/rest/firmware/X'.format(DEFAULT_URL)
assert create_request_url('X', 'Y') == 'Y/rest/firmware/X'
assert create_request_url('X', None) == '{}/rest/firmware/X?summary=true'.format(DEFAULT_URL)
assert create_request_url('X', 'Y') == 'Y/rest/firmware/X?summary=true'
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