Skip to content

pwnshop: require explicit relative paths - #106

Merged
ConnorNelson merged 1 commit into
mainfrom
refactor-relative-env
Mar 26, 2026
Merged

pwnshop: require explicit relative paths#106
ConnorNelson merged 1 commit into
mainfrom
refactor-relative-env

Conversation

@ConnorNelson

@ConnorNelson ConnorNelson commented Feb 12, 2026

Copy link
Copy Markdown
Member

This simplifies pwnshop to no longer do an implicit lookup through ancestor paths to find the first common/ for "common" directories. Instead, we require explicit paths. As an example, instead of {% include "common/server.py" %}, it is now {% include "../../common/server.py" %} (assuming common/ is two directories up).

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 211a4cd8f0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if start.is_file():
start = start.parent
for candidate in (start, *start.parents):
if (candidate / ".git").exists():

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Ignore nested .git artifacts when locating repo root

_find_git_root returns the first ancestor containing a .git entry, so if a challenge directory intentionally contains a .git artifact (a realistic CTF case), render() will treat that challenge folder as the repo root and then fail template.relative_to(git_root / "challenges"), breaking rendering/build for that challenge. The root detection should verify it found the actual project root (e.g., by checking expected repo layout) instead of any .git path.

Useful? React with 👍 / 👎.

@ConnorNelson

Copy link
Copy Markdown
Member Author

@zardus I'm curious what you think about something like this? Trivial codex generation, so no hard feelings if you hate it, but it feels like being explicit is better than the implicit recursive lookup.

Alternatively, we could lay out the full paths starting from challenges/, e.g. {% extends "challenges/common/Dockerfile.j2" %} or {% challenges/computing-101/common/Dockerfile.j2 %} if you don't like ../../; not sure which I prefer.

I was put on to this idea because the current existing recursive lookup fails it seems in the case where A extends B which extends C (not exactly sure of the specifics, but I ran into a bug that required using unique names for files because it was failing). We could of course try to go down the route of fixing this instead if you really like the implicit behavior, but I think I personally lean towards explicit.

And of course we can merge #83 before we consider this, just figured it's about as easy to open a PR to do this as it is to write up the idea these days.

@zardus

zardus commented Feb 12, 2026 via email

Copy link
Copy Markdown
Member

@ConnorNelson
ConnorNelson force-pushed the refactor-relative-env branch from 88b6649 to d4a4975 Compare March 26, 2026 15:03
@ConnorNelson
ConnorNelson merged commit f11dc3d into main Mar 26, 2026
19 checks passed
@ConnorNelson
ConnorNelson deleted the refactor-relative-env branch March 26, 2026 15:58
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.

2 participants