mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Replace armor guards that indicate isolated output
This commit is contained in:
parent
a0bcd12635
commit
9ec9cc5f87
3 changed files with 20 additions and 10 deletions
|
@ -11,8 +11,10 @@ from ..util import replace_control_chars
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
MAX_CONVERSION_LOG_CHARS = 150 * 50 # up to ~150 lines of 50 characters
|
MAX_CONVERSION_LOG_CHARS = 150 * 50 # up to ~150 lines of 50 characters
|
||||||
CONVERSION_LOG_START = "-----CONVERSION LOG START-----"
|
DOC_TO_PIXELS_LOG_START = "----- DOC TO PIXELS LOG START -----"
|
||||||
CONVERSION_LOG_END = "-----CONVERSION LOG END-----"
|
DOC_TO_PIXELS_LOG_END = "----- DOC TO PIXELS LOG END -----"
|
||||||
|
PIXELS_TO_PDF_LOG_START = "----- PIXELS TO PDF LOG START -----"
|
||||||
|
PIXELS_TO_PDF_LOG_END = "----- PIXELS TO PDF LOG END -----"
|
||||||
|
|
||||||
|
|
||||||
class IsolationProvider(ABC):
|
class IsolationProvider(ABC):
|
||||||
|
@ -90,8 +92,8 @@ class IsolationProvider(ABC):
|
||||||
conversion_string = replace_control_chars(untrusted_conversion_str)
|
conversion_string = replace_control_chars(untrusted_conversion_str)
|
||||||
|
|
||||||
# Add armor (gpg-style)
|
# Add armor (gpg-style)
|
||||||
armor_start = f"{CONVERSION_LOG_START}\n"
|
armor_start = f"{DOC_TO_PIXELS_LOG_START}\n"
|
||||||
armor_end = CONVERSION_LOG_END
|
armor_end = DOC_TO_PIXELS_LOG_END
|
||||||
return armor_start + conversion_string + armor_end
|
return armor_start + conversion_string + armor_end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,12 @@ from ..util import (
|
||||||
get_tmp_dir,
|
get_tmp_dir,
|
||||||
replace_control_chars,
|
replace_control_chars,
|
||||||
)
|
)
|
||||||
from .base import MAX_CONVERSION_LOG_CHARS, IsolationProvider
|
from .base import (
|
||||||
|
MAX_CONVERSION_LOG_CHARS,
|
||||||
|
PIXELS_TO_PDF_LOG_END,
|
||||||
|
PIXELS_TO_PDF_LOG_START,
|
||||||
|
IsolationProvider,
|
||||||
|
)
|
||||||
|
|
||||||
# Define startupinfo for subprocesses
|
# Define startupinfo for subprocesses
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
|
@ -339,9 +344,12 @@ class Container(IsolationProvider):
|
||||||
|
|
||||||
if getattr(sys, "dangerzone_dev", False):
|
if getattr(sys, "dangerzone_dev", False):
|
||||||
log_path = safe_dir / "captured_output.txt"
|
log_path = safe_dir / "captured_output.txt"
|
||||||
|
if log_path.exists(): # If first stage failed this may not exist
|
||||||
with open(log_path, "r", encoding="ascii", errors="replace") as f:
|
with open(log_path, "r", encoding="ascii", errors="replace") as f:
|
||||||
untrusted_log = f.read(MAX_CONVERSION_LOG_CHARS)
|
text = (
|
||||||
text = f"Container output: (pixels to PDF)\n{self.sanitize_conversion_str(untrusted_log)}"
|
f"Container output: (pixels to PDF)\n"
|
||||||
|
f"{PIXELS_TO_PDF_LOG_START}{f.read()}{PIXELS_TO_PDF_LOG_END}"
|
||||||
|
)
|
||||||
log.info(text)
|
log.info(text)
|
||||||
|
|
||||||
return success
|
return success
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 51419aa36bd4701927d1610fb544e18a4692f1db
|
Subproject commit 0068ffcb67f45fe9e3a082649493b7c8db5d1473
|
Loading…
Reference in a new issue