Unverified Commit e572b646 by Johannes vom Dorp Committed by GitHub

Merge pull request #6 from fkie-cad/SD1262-move-chown-into-pdf-container

Sd1262 move chown into pdf container
parents 2b920d40 83839822
......@@ -26,17 +26,23 @@ from tempfile import TemporaryDirectory
from pdf_generator.generator import compile_pdf, create_templates
def get_data():
return json.loads(Path('/tmp', 'interface', 'data', 'analysis.json').read_text()), json.loads(
Path('/tmp', 'interface', 'data', 'meta.json').read_text())
INPUT_DIR = Path('/tmp/interface')
def move_pdf_report(pdf_path):
shutil.move(str(pdf_path.absolute()), str(Path('/tmp', 'interface', 'pdf', pdf_path.name)))
def _load_data(file_name: str) -> dict:
return json.loads((INPUT_DIR / 'data' / file_name).read_text())
def move_pdf_report(pdf_path: Path):
output_path = INPUT_DIR / 'pdf' / pdf_path.name
shutil.move(pdf_path, output_path)
file_stats = INPUT_DIR.lstat()
shutil.chown(output_path, user=file_stats.st_uid, group=file_stats.st_gid)
def main(template_style='default'):
analysis, meta_data = get_data()
analysis = _load_data('analysis.json')
meta_data = _load_data('meta.json')
with TemporaryDirectory() as tmp_dir:
create_templates(analysis, meta_data, tmp_dir, template_style)
......
......@@ -76,7 +76,7 @@
\section{Software}
\begin{twentyshort}
\BLOCK{for summary in analysis['software_components']['summary'] | sort | x_entires}
\BLOCK{for summary in analysis['software_components']['summary'] | sort | x_entries}
\twentyitemshort{\VAR{summary | split_space}}
\BLOCK{endfor}
\BLOCK{if analysis['software_components']['summary'] | elements_count > 10}
......
......@@ -170,8 +170,8 @@ def get_triples(analysis):
return combined_triples
def _get_desired_triple(seleced_summary, which_desired):
desired_list = _ip_or_uri(seleced_summary, which_desired)
def _get_desired_triple(selected_summary, which_desired):
desired_list = _ip_or_uri(selected_summary, which_desired)
chosen_one = 'x x' * 60
while len(chosen_one) > 50:
chosen_one = choice(desired_list)
......@@ -227,7 +227,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
environment.filters['x_entries'] = get_x_entries
environment.filters['cve_crits'] = cve_criticals
......
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