CTFd / CTFd/ctfcli

File key not respecting null keys

Open
#163 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
215
Forks
95
Avg merge
2h 17m
Merged PRs (30d)
1

Description

Inside of most of the keys, it is optional to have values.

https://github.com/CTFd/ctfcli/blob/d8e08daedd6d22159f5978e1619b9d7073aa07f8/ctfcli/core/challenge.py#L583

For files, it is not optional and fails if you have no files under your key. Removing the key fixes the issue but this should be either documented in the spec better or fixed (preferred I think). Might be as simple as a better check?

https://github.com/CTFd/ctfcli/blob/d8e08daedd6d22159f5978e1619b9d7073aa07f8/ctfcli/core/challenge.py#L589

> Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.11.10/x64/bin/ctf", line 8, in
sys.exit(main())
^^^^^^
File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/ctfcli/__main__.py", line 136, in main
ret = fire.Fire(COMMANDS["cli"], serialize=lambda r: None if isinstance(r, int) else r)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/fire/core.py", line 475, in _Fire
component, remaining_args = _CallAndUpdateTrace(
^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/fire/core.py", line 691, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/ctfcli/cli/challenges.py", line 617, in install
challenge_instance.sync(ignore=ignore)
File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/ctfcli/core/challenge.py", line 589, in sync
local_files = {f.split("/")[-1]: f for f in self.get("files", [])}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.