Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Healthcheck Implementation #151

Open
ColdHeat opened this issue Jul 14, 2024 · 5 comments
Open

Healthcheck Implementation #151

ColdHeat opened this issue Jul 14, 2024 · 5 comments

Comments

@ColdHeat
Copy link
Member

I believe our healthcheck implemtnation is currently lacking so just writing some notes on improving it.

I believe ctfcli should treat a solve script as a kind of template. Possibly a Jinja template and populate specific variables and then run the script.

For example we could have something like:

#!/usr/bin/python3
connect("{{ host }}", {{ port }})

ctfcli will render this to a temporary file and then execute it.

@ColdHeat
Copy link
Member Author

Likely, if the healthcheck file ends in .jinja

We can render it to the same folder with the extension removed and then execute the script.

So for example:

healthcheck: solve.py.jinja

This points to a solution script expecting jinja variables. It gets templated by ctfcli, then written to solve.py and then executed via subprocess.

@ColdHeat
Copy link
Member Author

Although likely it might just make more sense to just keep it reading as argument variables...

@reteps
Copy link
Contributor

reteps commented Sep 11, 2024

I like the current healthcheck system, I think jinja templates is an extra degree of unneeded complexity.

@ColdHeat
Copy link
Member Author

It looks at some point healthchecks changed to using a --connection-info switch. I think a better choice is to pass the information using envvars.

healthcheck_status = subprocess.call(
[healthcheck, "--connection-info", connection_info],
cwd=challenge_instance.challenge_directory,
)

@kjcolley7
Copy link

kjcolley7 commented Nov 18, 2024

Stopping by to say that I agree that jinja templating for solve scripts is over the top. If anything, jinja templating for the command to invoke the solve script would be nice, so you could do something like healthcheck_command: ./solve.py HOST={{host}} PORT={{port}} (which works nicely with pwntools args) or however your script expects it. To pass as env vars, just put them first, like any other shell command. So the expectation is this string will be passed to the shell to parse and execute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants