ctf challenge add fails
Hello. I am new to ctfcli, I just did ctf init and ctf challenge add https://github.com/misogihagi/my-ctf-challenges.git andgot the following error:
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: working tree has modifications. Cannot add.
Could not add the challenge repository. Please check git error messages above.
Is this a known bug?
I believe you have changes in your local repository which is causing the errors you're seeing. Try running the command after committing the changes and then it should work.
The above was running on raspberrypi, but I tried running it on docker as well. And the result is as follows, it doesn't work either way
$ docker run -it python:3.11 bash
root@56cbc83bd04e:/# pip install ctfcli
~~~
root@56cbc83bd04e:/# cd
root@56cbc83bd04e:~# ctf init
Please enter CTFd instance URL: http://127.0.0.1
Please enter CTFd Admin Access Token: xxxx
Do you want to continue with http://127.0.0.1 and xxxx [Y/n]:
Creating a git repo in /root
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /root/.git/
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'root@56cbc83bd04e.(none)')
root@56cbc83bd04e:~# ctf challenge add https://github.com/misogihagi/my-ctf-challenges.git
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: working tree has modifications. Cannot add.
Could not add the challenge repository. Please check git error messages above.
The clue here is:
fatal: unable to auto-detect email address (got 'root@56cbc83bd04e.(none)')
git is unable to detect an email address, and can't make the initial commit. When you try to add the challenge it detects that the working tree has modifications and fails.
I certainly don't have a git setup... Why do you use git in ctfcli?
@misogihagi, from the README:
Ctfcli turns the current folder into a CTF event git repo. It asks for the base url of the CTFd instance you're working with and an access token.
@VaiTon , thants forinformation.
I understand using git to do git clone though
For example, when uploading a challenge from a different directory, when setting up from the GUI, git should not to be necessary.
Why do we need git in the first place?
git is used by ctfcli to support versioning of challenges. CTFd itself does not do versioning so we use git to track how challenges change. We use a bit of a strange setup (that I doubt people will want to replicate) but I don't think using git to manage challenges is uncommon.
Certainly using git for version control of challenges is conventional. If I were you, I also did so.
But I don't think you need version control just to register a challenge, even though, we don't need our own user or email address because nobody cares about who did.
I think it's a good idea to make both the GUI experience and the CLI experience the same.