Automating bulk challenge import with ctfd-cli

I’ve built a script that automates the building of a CTFd sever and I’ve installed the ctfd-cli. I am a bit confused on how exactly I can import all of my challenges into the CTFd server. This was my workflow:

I have a csv with all of the columns possible for a challenge. Each row is a challenge. I created a script called ‘csv2yaml.py’ which converts those challenges into one yaml with what was described in the format needed for the challenges under challenge specifications. I am getting a massive error when I try the following:
docker exec ${CONTAINER_PREFIX}-ctfd-1 bash -c "cd /opt/ctfcli_project && ctf challenge add /CTFd/embedded_CTFd && ctf challenge install /CTFd/embedded_CTFd"

that location is where my challenge.yml is. I think I’m confused on this part. Is every challenge supposed to have its own yaml or can I have them all in one yaml file? If so, then is it a formatting issue? If not, How can I possibly go by importing all of my challenges then? Am I to create a directory for every challenge with the challenge name, then have a subdirectory ‘Files’ and a ‘challenge.yml’ for each challenge? If that is so, what would the workflow be? Do I have to add that challenge directory to the config file under [challenges] and then import each directory individually? Or can I have one primary directory named “Challenges” and then have the subdirectories for every challenge? Any help would be greatly appreciated.

There is one challenge.yaml per challenge, therefore a directory per challenge.
Here is a script we then use.

ls -1 | xargs -L 1 ctfcli challenge install

Can you share your build scripts as well? We have a setup plugin that kind of does that. Could send by DM.

1 Like

would you still need to add the challenge directory to the config with

ctf add [challenge-dir]

before installing the challenges?

I tried DM’ing but couldn’t find the function. I’m new to this. I’ve been researching and building on my own for the past year on the CTFd we use. I want to automate this process as much as I can from the start as we have to create a CTFd server per class. That’s why I haven’t wanted to go the plugin route for importing challenges.