Skip to content

Commit

Permalink
OXO CLI: Support Args with values that has colons
Browse files Browse the repository at this point in the history
  • Loading branch information
benyissa committed Dec 2, 2024
1 parent f71298f commit db7dc86
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ostorlab/cli/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
21 changes: 21 additions & 0 deletions tests/cli/scan/run/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"]
)
Expand Down

0 comments on commit db7dc86

Please sign in to comment.