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
d17c8508
Commit
d17c8508
authored
Feb 08, 2019
by
amateyna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tmp
parent
a8623c58
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
1 deletions
+79
-1
code_generation.py
src/latex_code_generation/code_generation.py
+12
-0
file_hashes.tex
src/templates/default/file_hashes.tex
+32
-0
meta_data.tex
src/templates/default/meta_data.tex
+24
-0
test_generate_code.py
src/test/unit/test_generate_code.py
+11
-1
No files found.
src/latex_code_generation/code_generation.py
View file @
d17c8508
import
jinja2
import
logging
from
pathlib
import
Path
def
generate_code
(
analysis_dict
,
output_path
):
jinja_env
=
_set_jinja_env
()
_render_template
(
analysis_dict
,
jinja_env
,
'meta_data'
)
def
_create_tex_files
(
analysis_dict
,
jinja_env
):
module_list
=
list
(
analysis_dict
[
'analysis'
]
.
keys
())
module_list
.
append
(
'meta_data'
)
for
module
in
module_list
:
try
:
_render_template
(
analysis_dict
,
jinja_env
,
module
)
except
Exception
as
e
:
logging
.
error
(
'Could not generate tex file: {} -> {}'
.
format
(
type
(
Exception
),
e
))
def
_set_jinja_env
(
templates_to_use
=
'default'
):
...
...
src/templates/default/file_hashes.tex
0 → 100644
View file @
d17c8508
\begin{tabular}
{
|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
imphash
&
\VAR
{
selected
_
analysis['imphash']
}
\\
\hline
md5
&
\VAR
{
selected
_
analysis['md5']
}
\\
\hline
ripemd160
&
\VAR
{
selected
_
analysis['ripemd160']
}
\\
\hline
sha1
&
\VAR
{
selected
_
analysis['sha1']
}
\\
\hline
sha256
&
\VAR
{
selected
_
analysis['sha256']
}
\\
\hline
sha512
&
\VAR
{
selected
_
analysis['sha512'] | split
_
hash
}
\\
\hline
ssdeep
&
\VAR
{
selected
_
analysis['ssdeep'] | split
_
hash
}
\\
\hline
whirpool
&
\VAR
{
selected
_
analysis['whirlpool'] | split
_
hash
}
\\
\hline
\end{tabular}
src/templates/default/meta_data.tex
0 → 100644
View file @
d17c8508
\begin{tabular}
{
|p
{
3cm
}
|p
{
11.5cm
}
|
}
\hline
HID
&
\VAR
{
meta
_
data['hid']
}
\\
\hline
Device Name
&
\VAR
{
meta
_
data['device
_
name']
}
\\
\hline
Vendor
&
\VAR
{
meta
_
data['vendor']
}
\\
\hline
Device Class
&
\VAR
{
meta
_
data['device
_
class']
}
\\
\hline
Version
&
\VAR
{
meta
_
data['version']
}
\\
\hline
Release Date
&
\VAR
{
meta
_
data['release
_
date']
}
\\
\hline
Size
&
\VAR
{
meta
_
data['size'] | number
_
format
}
\\
\hline
\end{tabular}
\ No newline at end of file
src/test/unit/test_generate_code.py
View file @
d17c8508
from
tempfile
import
TemporaryDirectory
from
pathlib
import
Path
from
latex_code_generation.code_generation
import
_set_jinja_env
,
_render_template
,
_write_file
from
latex_code_generation.code_generation
import
_set_jinja_env
,
_render_template
,
_write_file
,
_create_tex_files
def
test_render_template
():
...
...
@@ -15,3 +15,13 @@ def test_write_file():
file_path
=
Path
(
tmp_dir
.
name
,
'test.tex'
)
_write_file
(
'test'
,
file_path
)
assert
file_path
.
exists
()
def
test_create_tex_files
():
test_data
=
{
'analysis'
:
{
'file_hashes'
:
{
'ssdeep'
:
'bla'
,
'sha1'
:
'blah'
},
'meta_data'
:
dict
()}}
tmp_dir
=
TemporaryDirectory
()
jinja_env
=
_set_jinja_env
(
templates_to_use
=
'default'
)
for
template_name
in
test_data
[
'analysis'
]:
_create_tex_files
(
test_data
,
jinja_env
)
file_path
=
Path
(
tmp_dir
.
name
,
template_name
+
'.tex'
)
assert
file_path
.
exists
()
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