From 96f927718af5f5ad5b355d28fffc8d5ebd8df02e Mon Sep 17 00:00:00 2001 From: Tom Plant <21111317+pl4nty@users.noreply.github.com> Date: Wed, 15 Mar 2023 12:56:26 +0000 Subject: [PATCH 1/2] Add `--args` to `ctf challenge deploy` for extra `docker run` arguments --- ctfcli/utils/deploy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctfcli/utils/deploy.py b/ctfcli/utils/deploy.py index 087874c..fd6c771 100644 --- a/ctfcli/utils/deploy.py +++ b/ctfcli/utils/deploy.py @@ -53,7 +53,7 @@ def ssh(challenge, host, protocol): [ "ssh", host.netloc, - f"docker run -d -p{exposed_port}:{exposed_port} --name {image_name} --restart always {image_name}", + f"docker run -d -p{exposed_port}:{exposed_port} --name {image_name} --restart always {image_name}{' '+args if args else ''}", ] ) From 7c46525380347b0239b477afa5684387585166b3 Mon Sep 17 00:00:00 2001 From: Tom Plant <21111317+pl4nty@users.noreply.github.com> Date: Wed, 15 Mar 2023 21:34:14 +0000 Subject: [PATCH 2/2] Swap `challenge deploy` argument for `deploy_args` in challenge.yml --- ctfcli/spec/challenge-example.yml | 3 +++ ctfcli/utils/deploy.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ctfcli/spec/challenge-example.yml b/ctfcli/spec/challenge-example.yml index 62a92f7..aa1fd29 100644 --- a/ctfcli/spec/challenge-example.yml +++ b/ctfcli/spec/challenge-example.yml @@ -39,6 +39,9 @@ host: null # Optional settings +# Specify command-line arguments for deploying the challenge. Currently supports SSH deployments, ie `docker run [deploy_args]` +deploy_args: null + # connection_info is used to provide a link, hostname, or instructions on how to connect to a challenge connection_info: nc hostname 12345 diff --git a/ctfcli/utils/deploy.py b/ctfcli/utils/deploy.py index fd6c771..93033c7 100644 --- a/ctfcli/utils/deploy.py +++ b/ctfcli/utils/deploy.py @@ -53,7 +53,7 @@ def ssh(challenge, host, protocol): [ "ssh", host.netloc, - f"docker run -d -p{exposed_port}:{exposed_port} --name {image_name} --restart always {image_name}{' '+args if args else ''}", + f"docker run -d -p{exposed_port}:{exposed_port} --name {image_name} --restart always {image_name} {challenge.get('deploy_args', '')}", ] )