Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fact_pdf_report
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
fact_pdf_report
Commits
41e76907
Commit
41e76907
authored
Jul 06, 2019
by
dorp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed some more escaping errors
parent
68da4ad4
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
14 deletions
+25
-14
filter.py
src/jinja_filters/filter.py
+6
-0
code_generation.py
src/latex_code_generation/code_generation.py
+9
-3
pdf_generator.py
src/pdf_generator.py
+1
-2
ip_and_uri_finder.tex
src/templates/default/ip_and_uri_finder.tex
+3
-3
main.tex
src/templates/default/main.tex
+1
-1
meta_data.tex
src/templates/default/meta_data.tex
+5
-5
No files found.
src/jinja_filters/filter.py
View file @
41e76907
...
...
@@ -94,6 +94,12 @@ def check_if_list_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
):
if
len
(
hash_value
)
>
61
:
hash_value
=
hash_value
[:
61
]
+
' '
+
hash_value
[
61
:]
...
...
src/latex_code_generation/code_generation.py
View file @
41e76907
...
...
@@ -8,7 +8,7 @@ import jinja2
from
common_helper_process
import
execute_shell_command_get_return_code
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
)
from
rest_import.rest
import
create_request_url
,
request_firmware_data
...
...
@@ -41,6 +41,7 @@ def _setup_jinja_filters(environment):
environment
.
filters
[
'elements_count'
]
=
count_elements_in_list
environment
.
filters
[
'base64_to_png'
]
=
convert_base64_to_png_filter
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_output_lines'
]
=
split_output_lines
...
...
@@ -102,10 +103,13 @@ def execute_pdflatex(tmp_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
)
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
()
_setup_jinja_filters
(
environment
=
jinja_environment
)
...
...
@@ -124,3 +128,5 @@ def generate_pdf_report(firmware_uid="bab8d95fc42176abc9126393b6035e4012ebccc82c
pdf_filename
=
create_report_filename
(
firmware_meta_data
)
shutil
.
move
(
Path
(
tmp_dir
,
'main.pdf'
),
Path
(
'.'
,
pdf_filename
))
return
None
src/pdf_generator.py
View file @
41e76907
...
...
@@ -78,7 +78,6 @@ if __name__ == '__main__':
_setup_logging
(
config
,
args
.
debug
)
logging
.
info
(
args
.
config_file
)
# insert your program here
generate_pdf_report
(
args
.
UID
)
sys
.
exit
()
sys
.
exit
(
0
)
src/templates/default/ip_and_uri_finder.tex
View file @
41e76907
...
...
@@ -7,19 +7,19 @@
\hline
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
}
\\
\BLOCK
{
endfor
}
\hline
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
}
\\
\BLOCK
{
endfor
}
\hline
URIs
\BLOCK
{
for uri in selected
_
analysis['uris'] | check
_
list
}
\BLOCK
{
for uri in selected
_
analysis['uris'] | check
_
list
| filter
_
list
}
&
\VAR
{
uri
}
\\
\BLOCK
{
endfor
}
\hline
...
...
src/templates/default/main.tex
View file @
41e76907
...
...
@@ -22,7 +22,7 @@
\HRule
\\
[0.4cm]
{
\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]
...
...
src/templates/default/meta_data.tex
View file @
41e76907
\begin{tabular}
{
|p
{
3cm
}
|p
{
11.5cm
}
|
}
\hline
HID
&
\VAR
{
meta
_
data['hid']
}
\\
HID
&
\VAR
{
meta
_
data['hid']
| filter
_
chars
}
\\
\hline
Device Name
&
\VAR
{
meta
_
data['device
_
name']
}
\\
Device Name
&
\VAR
{
meta
_
data['device
_
name']
| filter
_
chars
}
\\
\hline
Vendor
&
\VAR
{
meta
_
data['vendor']
}
\\
Vendor
&
\VAR
{
meta
_
data['vendor']
| filter
_
chars
}
\\
\hline
Device Class
&
\VAR
{
meta
_
data['device
_
class']
}
\\
Device Class
&
\VAR
{
meta
_
data['device
_
class']
| filter
_
chars
}
\\
\hline
Version
&
\VAR
{
meta
_
data['version']
}
\\
Version
&
\VAR
{
meta
_
data['version']
| filter
_
chars
}
\\
\hline
Release Date
&
\VAR
{
meta
_
data['release
_
date']
}
\\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment