Skip to content

Zip handout files by default, add zip option to challenge schema to disable. Respect handout_dir - #16

Open
Nigma1337 wants to merge 2 commits into
ctfpilot:mainfrom
Nigma1337:nigma/ZipAndRespectHandout
Open

Zip handout files by default, add zip option to challenge schema to disable. Respect handout_dir#16
Nigma1337 wants to merge 2 commits into
ctfpilot:mainfrom
Nigma1337:nigma/ZipAndRespectHandout

Conversation

@Nigma1337

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings July 24, 2026 11:35
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

All Contributors have signed the CLA. Thank you for your cooperation!
Posted by the CLA Assistant Lite bot.

@Nigma1337

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes how challenge handout files are collected and uploaded to CTFd: it now walks the handout directory recursively and (by default) uploads a single zip archive, with a new per-challenge schema option to disable zipping and a handout_dir override.

Changes:

  • Add recursive GitHub directory walking to include nested handout subdirectories.
  • Zip handout files by default before uploading to CTFd; add zip schema option to opt out.
  • Respect a configurable handout_dir in the challenge schema (defaulting to handout).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/github.go Adds recursive directory traversal helper to enumerate files under a handout directory.
src/ctfd-challenges.go Switches to recursive file collection and optionally zips handouts before uploading to CTFd.
src/challenge.go Extends challenge schema with handout_dir and zip, and updates handout directory resolution helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/github.go
Comment on lines +74 to +85
nested, err := getGithubDirContentsRecursive(repo, branch, entryPath)
if err != nil {
return nil, err
}
files = append(files, nested...)
continue
}

files = append(files, RemoteFile{
Path: entryPath,
RelPath: strings.TrimPrefix(entryPath, path+"/"),
})
Comment thread src/challenge.go
Comment on lines +65 to 69
if challengeConfig.Challenge.HandoutDir != "" {
return challengeConfig.Challenge.HandoutDir
}
return "handout"
}

@The0mikkel The0mikkel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I like the approach, however there are some elements I would have liked to be changed, before diving deeper into the code.

First, as ctfpilot/challenge-schema#17 is not being implemented, the zipping functionality should be ctfd-manager wide. This should make the ctfd-manager follow the handout_dir in the challenge config, and zip those files into a single zip that can be uploaded.

The part of the code, handling zipping, I would like to have in a seperate file, such that it may be reused across code if needed, and generalle abstract the zipping process out of this part of the code.

With this, the ctfd-manager will not zip on challenge specific, but will be application wide.

As a note on the zipping process, it should put the files in the following format: <category>_<slug>
Such that when the zip is extracted, a folder named <category>_<slug> is presented.
The zip file should be named in the same way.

@Nigma1337

Copy link
Copy Markdown
Author

Updated the PR to always zip for multiple files and have the correct file name @The0mikkel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants