Fixed security issues

This commit is contained in:
2020-11-27 16:01:23 +01:00
parent a98917590f
commit 1c1d6bd29b
3 changed files with 10 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
import subprocess
import os.path
import subprocess # nosec: That's the whole point of this application
from flask import current_app
import werkzeug.exceptions
@@ -11,11 +12,15 @@ def run_abstract_converter(converter: str, source: str, destination: str) -> int
:param destination: destination file
:returns: exitcode of the converter
"""
completed_process = subprocess.run([converter, source, destination],
if not (os.path.isfile(source) and os.path.isfile(converter)):
raise FileNotFoundError("Source or converter binary does not exists")
completed_process = subprocess.run([converter, source, destination], # nosec: Concerning arguments checked above
timeout=current_app.config['CONVERSION_TIMEOUT'], env={})
return completed_process.returncode
def convert_caff_to_tga(source: str, destination: str):
"""
This function uses caff_previewer to convert a CAFF file into a TGA file