From 5b04504b0eb3919a1d121ee7205f52be102a3c08 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Mar 2026 12:22:34 +0000 Subject: [PATCH] test(convert_to_pdfa): assert -- terminates option parsing before file paths Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/DocuElevate/sessions/5223074c-1ebf-4fc0-bf80-0de8462c16a2 --- tests/test_convert_to_pdfa.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_convert_to_pdfa.py b/tests/test_convert_to_pdfa.py index 12ee6243..9f4fd12a 100644 --- a/tests/test_convert_to_pdfa.py +++ b/tests/test_convert_to_pdfa.py @@ -38,6 +38,11 @@ class TestConvertPdfToPdfa: assert "pdfa-2" in cmd assert "--quiet" in cmd assert "--invalidate-digital-signatures" in cmd + # "--" must be present to terminate option parsing and prevent paths + # starting with "-" from being interpreted as flags (command injection guard) + assert "--" in cmd + assert cmd.index("--") < cmd.index("/input.pdf") + assert cmd.index("--") < cmd.index("/output.pdf") assert "/input.pdf" in cmd assert "/output.pdf" in cmd @@ -72,6 +77,8 @@ class TestConvertPdfToPdfa: _convert_pdf_to_pdfa("/input.pdf", "/output.pdf", fmt) cmd = mock_run.call_args[0][0] assert f"pdfa-{fmt}" in cmd + assert "--" in cmd + assert cmd.index("--") < cmd.index("/input.pdf") def test_invalid_pdfa_format_rejected(self): """Test that invalid PDF/A format values are rejected."""