From db7dc86cf4ce5b4a40ddffd9af1f232166952f35 Mon Sep 17 00:00:00 2001 From: benyissa Date: Mon, 2 Dec 2024 17:07:30 +0100 Subject: [PATCH] OXO CLI: Support Args with values that has colons --- src/ostorlab/cli/types.py | 2 +- tests/cli/scan/run/run_test.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ostorlab/cli/types.py b/src/ostorlab/cli/types.py index 702b6582b..54d772c03 100644 --- a/src/ostorlab/cli/types.py +++ b/src/ostorlab/cli/types.py @@ -42,7 +42,7 @@ def convert( click.BadParameter: If the argument value cannot be parsed into the expected format. """ try: - arg_name, arg_value = arg_value.split(":") + arg_name, arg_value = arg_value.split(":", 1) return AgentArg(name=arg_name, value=arg_value) except ValueError: self.fail( diff --git a/tests/cli/scan/run/run_test.py b/tests/cli/scan/run/run_test.py index 4c6774d6a..c7aca67c9 100644 --- a/tests/cli/scan/run/run_test.py +++ b/tests/cli/scan/run/run_test.py @@ -391,6 +391,27 @@ def testOstorlabScanRunCLI_whenWrongArgsFormatProvided_showsErrorMessage() -> No ) +def testOstorlabScanRunCLI_whenAgentArgContainsThreeColons_doesNotCrash( + mocker: plugin.MockerFixture, +) -> None: + mocker.patch("ostorlab.runtimes.local.LocalRuntime.__init__", return_value=None) + runner = CliRunner() + + result = runner.invoke( + rootcli.rootcli, + [ + "scan", + "run", + "--agent=agent/ostorlab/nmap", + "--arg=proxy:arg_value:http://localhost:3000/", + "ip", + "8.8.8.8", + ], + ) + + assert result.output == "" + + @pytest.mark.parametrize( "invalid_agent_key", ["/nmap", "@agent/ostorlab/nmap/", "agent/ostorlab/nmap/"] )