Skip to content

File key not respecting null keys #163

@jimender2

Description

@jimender2

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

if challenge.get("tags"):

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?

local_files = {f.split("/")[-1]: f for f in self.get("files", [])}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions