CTFd/ctfcli

Ability to set CTFd config

ColdHeat opened this issue · 6 comments

We need a way to share CTFd configuration between events. It's too easy to forget that a configuration setting needs to be set.

I have interest in this specific issue and may be able to help. Would you accept a PR on this? If so, do you have any recommendations regarding potential implementations?

@SmylerMC yes I would accept a PR for this.

I don't think there's much trick to it but I am concerned that in the .ctf/config file we already use the config key.

Ideally I think that we would want this to be something like:

[config]
ctf_name = CTFd
challenge_visibility = public

Perhaps that means that we rename the top level config to something else.

What about using YAML for the CTFd config file? I feel like that would make things more coherent, ctfcli related files being in TOML and CTFd related files in YAML.

Regarding the commands, I like the idea of changing ctf config to work with CTFd's config if you are ok with that. I assumed it was what it did the first time had a look at ctfcli.

Another solution I was tinkering with for the commands would be to keep ctf config as it is and add a new ctf instance command that would manage CTFd's state as a whole through sub-commands.

Example sub-commands could be:

  • ctf instance config save -> Save the current CTFd configuration to a local file
  • ctf instance config apply -> Apply the configuration specified in a dedicated file in the project
  • ctf instance config get [key] -> Get a single config entry
  • ctf instance config set [key] [value] -> Set a single config entry
  • ctf instance reset [accounts|submissions|challenges|pages|notification] -> Delete all selected data
  • ctf instance export -> Backup CTFd
  • ctf instance import -> Restore CTFd backup

I am working on this now. I like the idea of the instance subcommand.

The issue I've run into now is that the .ctf/config structure is pretty bad because it is ini based and the server config stores a variety of things.

Well by the structure of the Configs model both key and value should be strings or null so I suppose we can work with that.