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
74a2bcd9
Commit
74a2bcd9
authored
Jun 15, 2020
by
lwilms
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ips and uris
parent
9cb69d05
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
42 deletions
+48
-42
main.tex
pdf_generator/templates/new_template/main.tex
+6
-38
template_engine.py
pdf_generator/tex_generation/template_engine.py
+42
-4
No files found.
pdf_generator/templates/new_template/main.tex
View file @
74a2bcd9
...
@@ -91,48 +91,16 @@
...
@@ -91,48 +91,16 @@
\end{twentyshort}
\end{twentyshort}
\BLOCK
{
endif
}
\BLOCK
{
endif
}
% ----------------------------------------------------------------------------------------------------------------------
% ----------------------------------------------------------------------------------------------------------------------
% ELF ANALYSIS
% ----------------------------------------------------------------------------------------------------------------------
%\BLOCK{if 'elf_analysis' in analysis }
% \section{ELF Analysis}
%
% \begin{twentyshort}
% \BLOCK{for ELF in analysis['elf_analysis']['summary'] | top_five(20)}
% \twentyitemshort{\VAR{analysis['elf_analysis']['summary'][ELF] | elements_count}}{\VAR{ELF | filter_chars}}
% \BLOCK{endfor}
% \end{twentyshort}
%\BLOCK{endif}
% ----------------------------------------------------------------------------------------------------------------------
% IP & URI
% IP & URI
% ----------------------------------------------------------------------------------------------------------------------
% ----------------------------------------------------------------------------------------------------------------------
\BLOCK
{
if ('ips
_
v4' in analysis or 'ips
_
v6' in analysis or 'uris' in analysis)
}
\BLOCK
{
if 'ip
_
and
_
uri
_
finder' in analysis
}
\section
{
IPs
\&
URIs
}
\section
{
IPs and URIs
}
{
\begin{longtable}
{
|p
{
3cm
}
|p
{
11.5cm
}
|
}
\BLOCK
{
if 'ips
_
v4' in analysis
}
\hline
IPs v4
\BLOCK
{
for ip in analysis['ips
_
v4'] | check
_
list | filter
_
list
}
&
\VAR
{
ip
}
\\
\BLOCK
{
endfor
}
\BLOCK
{
elif 'ips
_
v6' in analysis
}
\hline
IPs v6
\begin{twentyshort}
\BLOCK
{
for
ip in analysis['ips
_
v6'] | check
_
list | filter
_
lis
t
}
\BLOCK
{
for
selected
_
analysis in analysis['ip
_
and
_
uri
_
finder']['summary'] | triple
t
}
&
\VAR
{
ip
}
\\
\twentyitemshort
{
\VAR
{
selected
_
analysis
}}
\BLOCK
{
endfor
}
\BLOCK
{
endfor
}
\BLOCK
{
elif 'uris' in analysis
}
\end{twentyshort}
\hline
URIs
\BLOCK
{
for uri in analysis['uris'] | check
_
list | filter
_
list
}
&
\VAR
{
uri
}
\\
\BLOCK
{
endfor
}
\BLOCK
{
endif
}
\hline
\end{longtable}
}
\BLOCK
{
endif
}
\BLOCK
{
endif
}
%----------------------------------------------------------------------------------------
%----------------------------------------------------------------------------------------
...
...
pdf_generator/tex_generation/template_engine.py
View file @
74a2bcd9
...
@@ -5,6 +5,8 @@ from contextlib import suppress
...
@@ -5,6 +5,8 @@ from contextlib import suppress
from
pathlib
import
Path
from
pathlib
import
Path
from
time
import
localtime
,
strftime
from
time
import
localtime
,
strftime
from
random
import
choice
import
socket
import
jinja2
import
jinja2
from
common_helper_files
import
human_readable_file_size
from
common_helper_files
import
human_readable_file_size
...
@@ -182,6 +184,8 @@ def count_this_mitigation(summary, mitigation):
...
@@ -182,6 +184,8 @@ def count_this_mitigation(summary, mitigation):
def
software_components
(
software_string
):
def
software_components
(
software_string
):
# analysis['software_components']['summary']
# analysis['software_components']['summary']
software
=
software_string
ver_number
=
''
if
' '
in
software_string
:
if
' '
in
software_string
:
if
len
(
software_string
.
split
(
' '
))
>
2
:
if
len
(
software_string
.
split
(
' '
))
>
2
:
software
=
''
.
join
(
software_string
.
split
(
' '
)[:
-
1
])
software
=
''
.
join
(
software_string
.
split
(
' '
)[:
-
1
])
...
@@ -196,13 +200,46 @@ def software_components(software_string):
...
@@ -196,13 +200,46 @@ def software_components(software_string):
int
(
ver_number
[
0
])
int
(
ver_number
[
0
])
except
ValueError
:
except
ValueError
:
ver_number
,
software
=
software
,
ver_number
ver_number
,
software
=
software
,
ver_number
else
:
software
=
software_string
ver_number
=
''
return
'{}{}{}{}'
.
format
(
ver_number
,
'}'
,
'{'
,
software
)
return
'{}{}{}{}'
.
format
(
ver_number
,
'}'
,
'{'
,
software
)
def
get_triples
(
analysis
):
combined_triples
=
[]
for
desired
in
[
'IPv4'
,
'IPv6'
,
'URI '
]:
combined_triples
.
append
(
get_desired_triple
(
analysis
,
desired
))
return
combined_triples
def
get_desired_triple
(
seleced_summary
,
which_desired
):
desired_list
=
ip_or_uri
(
seleced_summary
,
which_desired
)
chosen_one
=
'x x'
*
60
while
len
(
chosen_one
)
>
40
:
chosen_one
=
choice
(
desired_list
)
return
'{2}{1}{0}{3}{5} {4}'
.
format
(
'{'
,
'}'
,
len
(
desired_list
),
which_desired
,
replace_special_characters
(
chosen_one
),
'
\
quad'
*
10
)
def
ip_or_uri
(
summary
,
which_select
):
new_list
=
[]
for
data
in
summary
:
if
(
'URI '
in
which_select
and
not
_validate_ip
(
data
,
socket
.
AF_INET
)
and
not
_validate_ip
(
data
,
socket
.
AF_INET6
)):
new_list
.
append
(
data
)
elif
'IPv4'
in
which_select
and
_validate_ip
(
data
,
socket
.
AF_INET
):
new_list
.
append
(
data
)
elif
'IPv6'
in
which_select
and
_validate_ip
(
data
,
socket
.
AF_INET6
):
new_list
.
append
(
data
)
return
new_list
# imported from ip & uri
def
_validate_ip
(
ip
,
address_format
):
try
:
_
=
socket
.
inet_pton
(
address_format
,
ip
)
return
True
except
OSError
:
return
False
def
_add_filters_to_jinja
(
environment
):
def
_add_filters_to_jinja
(
environment
):
environment
.
filters
[
'number_format'
]
=
render_number_as_size
environment
.
filters
[
'number_format'
]
=
render_number_as_size
environment
.
filters
[
'nice_unix_time'
]
=
render_unix_time
environment
.
filters
[
'nice_unix_time'
]
=
render_unix_time
...
@@ -220,6 +257,7 @@ def _add_filters_to_jinja(environment):
...
@@ -220,6 +257,7 @@ def _add_filters_to_jinja(environment):
environment
.
filters
[
'sort'
]
=
sorted
environment
.
filters
[
'sort'
]
=
sorted
environment
.
filters
[
'call_for_mitigations'
]
=
exploit_mitigation
environment
.
filters
[
'call_for_mitigations'
]
=
exploit_mitigation
environment
.
filters
[
'split_space'
]
=
software_components
environment
.
filters
[
'split_space'
]
=
software_components
environment
.
filters
[
'triplet'
]
=
get_triples
class
TemplateEngine
:
class
TemplateEngine
:
...
...
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