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
0df12da0
Commit
0df12da0
authored
Jun 15, 2020
by
lwilms
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
max 10 software
parent
fe40bed6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
main.tex
pdf_generator/templates/new_template/main.tex
+5
-1
template_engine.py
pdf_generator/tex_generation/template_engine.py
+12
-4
No files found.
pdf_generator/templates/new_template/main.tex
View file @
0df12da0
...
...
@@ -85,11 +85,15 @@
\section
{
Software
}
\begin{twentyshort}
\BLOCK
{
for summary in analysis['software
_
components']['summary'] | sort
}
\BLOCK
{
for summary in analysis['software
_
components']['summary'] | sort
| x
_
entires
}
\twentyitemshort
{
\VAR
{
summary | split
_
space
}}
\BLOCK
{
endfor
}
\BLOCK
{
if analysis['software
_
components']['summary'] | elements
_
count > 10
}
\twentyitemshort
{}{
and
\VAR
{
analysis['software
_
components']['summary'] | elements
_
count - 10
}
others
}
\BLOCK
{
endif
}
\end{twentyshort}
\BLOCK
{
endif
}
% ----------------------------------------------------------------------------------------------------------------------
% IP & URI
% ----------------------------------------------------------------------------------------------------------------------
...
...
pdf_generator/tex_generation/template_engine.py
View file @
0df12da0
...
...
@@ -47,7 +47,7 @@ def replace_special_characters(data):
latex_character_escapes
=
OrderedDict
()
latex_character_escapes
[
'
\\
'
]
=
''
latex_character_escapes
[
'
\'
'
]
=
''
latex_character_escapes
[
'/'
]
=
'
'
latex_character_escapes
[
'/'
]
=
'
/
'
latex_character_escapes
[
'$'
]
=
'
\\
$'
latex_character_escapes
[
'('
]
=
'$($'
latex_character_escapes
[
')'
]
=
'$)$'
...
...
@@ -215,14 +215,15 @@ def get_desired_triple(seleced_summary, which_desired):
chosen_one
=
'x x'
*
60
while
len
(
chosen_one
)
>
50
:
chosen_one
=
choice
(
desired_list
)
return
'{2}{1}{0}{3}{4}
{5}'
.
format
(
'{'
,
'}'
,
len
(
desired_list
),
which_desired
,
'
\
quad'
*
5
,
return
'{2}{1}{0}{3}{4}
$
\
>$ (incl. {5})'
.
format
(
'{'
,
'}'
,
len
(
desired_list
),
which_desired
,
'
\
quad'
,
replace_special_characters
(
chosen_one
))
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
)):
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
)
...
...
@@ -231,7 +232,6 @@ def ip_or_uri(summary, which_select):
return
new_list
# imported from ip & uri
def
_validate_ip
(
ip
,
address_format
):
try
:
_
=
socket
.
inet_pton
(
address_format
,
ip
)
...
...
@@ -240,6 +240,13 @@ def _validate_ip(ip, address_format):
return
False
def
get_x_entries
(
summary
,
how_many
=
10
):
if
len
(
summary
)
<=
how_many
:
return
summary
else
:
return
summary
[:
how_many
]
def
_add_filters_to_jinja
(
environment
):
environment
.
filters
[
'number_format'
]
=
render_number_as_size
environment
.
filters
[
'nice_unix_time'
]
=
render_unix_time
...
...
@@ -258,6 +265,7 @@ def _add_filters_to_jinja(environment):
environment
.
filters
[
'call_for_mitigations'
]
=
exploit_mitigation
environment
.
filters
[
'split_space'
]
=
software_components
environment
.
filters
[
'triplet'
]
=
get_triples
environment
.
filters
[
'x_entires'
]
=
get_x_entries
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