Repository navigation
feat: add --engine-path flag for local engine development - #11
Conversation
PR SummaryEnables local engine development and CI by bootstrapping against a filesystem path instead of a remote release.
Written by Cursor Bugbot for commit 2d373e8. This will update automatically on new commits. Configure here. |
Summary of ChangesHello @apotema, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable feature for local development and CI by adding support for a local engine path via the --engine-path flag and LABELLE_ENGINE_PATH environment variable. However, it also introduces a critical command injection vulnerability due to improper sanitization of the user-provided engine path, which could allow arbitrary code execution. Additionally, there are areas for improvement concerning cross-platform compatibility with path separators and environment variable access, and some unrelated changes to src/project_config.zig that should be moved to a separate pull request.
| } else { | ||
| // Already relative - just add ../ to go up from bootstrap dir | ||
| relative_path = try std.fmt.allocPrint(allocator, "../{s}", .{local_path}); | ||
| needs_free = true; | ||
| } |
There was a problem hiding this comment.
The local_path variable, which is user-controlled via the --engine-path argument or LABELLE_ENGINE_PATH environment variable, is used to construct a file path without proper sanitization. When a relative path is provided, it is prepended with ../, which allows for path traversal. An attacker could provide a malicious path (e.g., ../../../../../../tmp/evil-project) that points to an arbitrary location on the file system. This path is then written into the build.zig.zon file. Subsequently, the zig build run command is executed, which will use this malicious path, leading to arbitrary code execution. This is a critical command injection vulnerability.
|
|
||
| // Resolve engine path to absolute | ||
| var engine_buf: [std.fs.max_path_bytes]u8 = undefined; | ||
| const engine_abs = std.fs.cwd().realpath(local_path, &engine_buf) catch local_path; |
There was a problem hiding this comment.
|
|
||
| /// Compute relative path from `from` directory to `to` path. | ||
| /// Both paths must be absolute. | ||
| fn computeRelativePath(allocator: std.mem.Allocator, from: []const u8, to: []const u8) ![]const u8 { |
|
|
||
| // Check for LABELLE_ENGINE_PATH environment variable | ||
| if (options.engine_path == null) { | ||
| options.engine_path = std.posix.getenv("LABELLE_ENGINE_PATH"); |
| /// Create a bootstrap build.zig.zon using a local engine path. | ||
| /// The path needs to be relative to the bootstrap directory. | ||
| fn createBootstrapBuildZonWithLocalPath(allocator: std.mem.Allocator, dir: std.fs.Dir, local_path: []const u8) !void { | ||
| _ = dir; |
|
|
||
| /// Run the engine's generator using a local engine path. | ||
| /// This is useful for CI testing against a local checkout. | ||
| pub fn runEngineGeneratorWithLocalPath(allocator: std.mem.Allocator, local_path: []const u8, project_path: []const u8) !void { |
There was a problem hiding this comment.
The project_path parameter is unused in this function (discarded on the next line) and also in createBootstrapBuildZig which it calls. Please remove it from the function signatures to simplify the code. This will require updating the call site in src/main.zig.
pub fn runEngineGeneratorWithLocalPath(allocator: std.mem.Allocator, local_path: []const u8) !void {
| pub const WindowConfig = struct { | ||
| title: ?[]const u8 = null, | ||
| width: ?i32 = null, | ||
| height: ?i32 = null, | ||
| }; |
There was a problem hiding this comment.
62a34d2 to
a5c5507
Compare
| _ = result.pop(); | ||
| } | ||
|
|
||
| return try result.toOwnedSlice(allocator); |
There was a problem hiding this comment.
Cross-drive paths on Windows produce invalid relative paths
Low Severity
On Windows, computeRelativePath produces invalid paths when the source and destination are on different drives (e.g., project on C:\ and engine on D:\). Since no common root exists, the function generates output like ..\..\D:\engine which is not a valid relative path. There's no way to navigate between drives using relative paths, so the function would need to detect this case and either return an error or the absolute destination path.
a5c5507 to
b15ca10
Compare
Add support for using a local labelle-engine checkout instead of fetching from the package registry. This is useful for: - CI testing against the current branch of labelle-engine - Local development with modified engine code Usage: labelle build --engine-path=/path/to/labelle-engine LABELLE_ENGINE_PATH=/path/to/engine labelle build The implementation: - Adds --engine-path=PATH option to CLI - Adds LABELLE_ENGINE_PATH env var support - Creates bootstrap build.zig.zon with .path instead of .url/.hash - Computes relative path from bootstrap dir to engine path Closes #10 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
b15ca10 to
2d373e8
Compare
Point the CLI at the freshly-tagged labelle-assembler v0.6.0, which ships the full #8–#13 cluster of backend/ECS bug fixes plus the absorbed plugins and examples. Changes: - DEFAULT_ASSEMBLER_VERSION: 0.5.1 → 0.6.0 New projects scaffolded via \`labelle init\` now pin to v0.6.0 and auto-download that release binary on first generate. - build.zig.zon labelle_assembler dep: a610afd → 295021cd (the v0.6.0 tag's commit SHA). The Zig package hash happens to match the previous pin because the hash is content-hashed over the assembler's paths = {build.zig, build.zig.zon, src}, and the plugins/examples absorbs didn't touch src/. Assembler v0.6.0 fixes shipping to users: - #8 SDL portable paths (Linux/Windows/Intel Mac fixed) - #9 bgfx native window handle per platform - #10 sokol audio sample buffer leak on unload - #11 raylib audio slot recycling - #12 wgpu WAV parser integer overflow + truncation tolerance - #13 zig-ecs view zero-alloc (borrows storage slice) Plus: sokol HiDPI, Android detection via ABI, iOS build.zig 0.15 compat, sokol-zig / zbgfx / zglfw / nuklear / rlImGui / raylib-zig dep pinning. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Add support for using a local labelle-engine checkout instead of fetching from the package registry. This is useful for:
Changes
--engine-path=PATHoption to CLILABELLE_ENGINE_PATHenvironment variable supportbuild.zig.zonwith.pathinstead of.url/.hashwhen using local engineUsage
Example CI Usage
Test plan
--engine-pathflag with absolute pathLABELLE_ENGINE_PATHenvironment variablebuild.zig.zonhas correct relative pathCloses #10
🤖 Generated with Claude Code