-
Notifications
You must be signed in to change notification settings - Fork 1
fix: replace <PACK> placeholders, harden path traversal checks, strengthen empty-list tests
#52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a50e714
8e136f6
9adb152
765a9a3
121562d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -119,12 +119,21 @@ def render_cmd( | |||||||
|
|
||||||||
| if out is None: | ||||||||
| name = spec_data["name"] | ||||||||
| if not name or "/" in name or "\\" in name: | ||||||||
| stripped_name = name.strip() if isinstance(name, str) else "" | ||||||||
| if ( | ||||||||
| not stripped_name | ||||||||
| or "/" in stripped_name | ||||||||
| or "\\" in stripped_name | ||||||||
| or ".." in stripped_name | ||||||||
| or stripped_name.startswith(".") | ||||||||
| ): | ||||||||
| raise click.ClickException( | ||||||||
| f"Unsafe spec name {name!r} cannot be used as output directory. " | ||||||||
| "Name must be a non-empty single path segment, must not start with " | ||||||||
| "'.', and must not contain '..' or path separators. " | ||||||||
| "Use --out to specify an explicit output path." | ||||||||
| ) | ||||||||
| output_dir = Path(name) | ||||||||
| output_dir = Path(stripped_name) | ||||||||
| else: | ||||||||
|
Comment on lines
120
to
137
|
||||||||
| output_dir = out | ||||||||
|
|
||||||||
|
|
@@ -577,12 +586,19 @@ def new( | |||||||
| ) -> None: | ||||||||
| """Create a new Python project with operational infrastructure.""" | ||||||||
| # Validate name before using as path | ||||||||
| if not name or "/" in name or "\\" in name or name.startswith("."): | ||||||||
| stripped_name = name.strip() if name else "" | ||||||||
| if ( | ||||||||
| not stripped_name | ||||||||
| or "/" in stripped_name | ||||||||
| or "\\" in stripped_name | ||||||||
| or ".." in stripped_name | ||||||||
| or stripped_name.startswith(".") | ||||||||
| ): | ||||||||
| raise click.ClickException( | ||||||||
| f"Unsafe project name {name!r}. " | ||||||||
| "Names must not contain path separators or start with a dot." | ||||||||
| "Names must not contain path separators, '..', or start with a dot." | ||||||||
|
||||||||
| "Names must not contain path separators, '..', or start with a dot." | |
| "Surrounding whitespace is stripped, and the resulting name must not be empty, " | |
| "contain path separators, contain '..', or start with a dot." |
Copilot
AI
Apr 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new() strips whitespace into stripped_name for output_dir, but later uses the original name when building the spec (build_spec_for_new(name, ...)). If the user passes leading/trailing whitespace, the directory created and the spec’s internal name (and derived paths like src_dir) can diverge, potentially creating unexpected paths in the generated project. Consider normalizing once (e.g., replace name with stripped_name) and using the normalized value consistently for both output_dir and the spec construction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation snippet creates an absolute scratch path via
mktemp -d ...and then runsnboot new "$scratch", butnboot newrejects names containing path separators (seesrc/navi_bootstrap/cli.py:new), so this command chain will fail as written. Adjust the instructions to create a scratch parent directory and runnboot new <project-name>inside it (or otherwise ensure thenameargument is a single path segment), then point--targetat the created project directory.