Skip to content

Conversation

@cgwalters
Copy link
Collaborator

Add cargo xtask local-rust-deps which uses cargo metadata to find local path dependencies outside the workspace (e.g., from [patch] sections) and outputs podman bind mount arguments.

This enables a cleaner workflow for local development against modified dependencies like composefs-rs:

  1. Add a [patch] section to Cargo.toml with real local paths
  2. Run just build - the Justfile auto-detects and bind-mounts them

Benefits over the previous BOOTC_extra_src approach:

  • No manual env var needed
  • Paths work for both local cargo build and container builds
  • No /run/extra-src indirection or Cargo.toml path munging required
  • Auto-detection means it Just Works™

The Justfile's build target now calls cargo xtask local-rust-deps to get bind mount args, falling back gracefully if there are no external deps. The old BOOTC_extra_src mechanism is still supported for backwards compat.

Assisted-by: Claude Sonnet 4 (via OpenCode)

@bootc-bot bootc-bot bot requested a review from jeckersb January 22, 2026 23:07
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new "cargo xtask local-rust-deps" command to automatically detect and configure bind mounts for local path dependencies, significantly improving the local development workflow. However, the current implementation is vulnerable to command and argument injection due to unsafe interpolation in the Justfile and improper escaping of file paths in the xtask tool. Additionally, there are suggestions to improve debuggability and code clarity, such as avoiding error message swallowing in the Justfile and refactoring podman argument generation in the Rust code.

if [[ -z "{{no_auto_local_deps}}" ]]; then
local_deps_args=$(cargo xtask local-rust-deps 2>/dev/null || true)
fi
podman build {{base_buildargs}} --build-arg=SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} --build-arg=pkgversion=${VERSION} -t localhost/bootc-pkg --target=build $local_deps_args .
Copy link
Contributor

Choose a reason for hiding this comment

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

security-high high

The shell variable $local_deps_args is used unquoted in a podman build command. This variable contains the output of cargo xtask local-rust-deps, which includes file paths to local dependencies. If any of these paths contain spaces or shell metacharacters (like ;, &, or |), it will lead to argument injection or arbitrary command execution. Since these paths are derived from Cargo.toml files that could be located outside the workspace, this poses a significant security risk in environments where dependency paths might be untrusted or maliciously crafted.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Man, the Gemini review rule for shell injection is one of those things where 20% of the time it's probably absolutely critical, and 50% it's pointless noise.

Rust crates I don't think can even have shell metacharacters.

args_out.push("--security-opt=label=disable".to_string());
}
if !args_out.is_empty() {
println!("{}", args_out.join(" "));
Copy link
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The local_rust_deps function constructs a string of space-separated arguments for podman without performing any escaping or quoting on the paths. This is a command injection vulnerability, as paths with spaces or shell metacharacters could be incorrectly parsed by the shell in the Justfile. Paths should be properly escaped for shell consumption, for example, by using the shlex crate to quote each argument. Additionally, consider refactoring the --security-opt=label=disable argument to be specified only once for all volumes for cleaner command generation.

Justfile Outdated
# Auto-detect local Rust path dependencies (e.g., from [patch] sections)
local_deps_args=""
if [[ -z "{{no_auto_local_deps}}" ]]; then
local_deps_args=$(cargo xtask local-rust-deps 2>/dev/null || true)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Suppressing stderr with 2>/dev/null can hide important error messages if cargo xtask local-rust-deps fails for an unexpected reason (e.g., a malformed Cargo.toml or issues running cargo metadata). This can make debugging difficult. Since you're already using || true to prevent the script from failing, it would be better to let stderr be printed so the user is aware of any issues with local dependency detection.

        local_deps_args=$(cargo xtask local-rust-deps || true)

Add `cargo xtask local-rust-deps` which uses `cargo metadata` to find
local path dependencies outside the workspace (e.g., from [patch] sections)
and outputs podman bind mount arguments.

This enables a cleaner workflow for local development against modified
dependencies like composefs-rs:

1. Add a [patch] section to Cargo.toml with real local paths
2. Run `just build` - the Justfile auto-detects and bind-mounts them

Benefits over the previous BOOTC_extra_src approach:
- No manual env var needed
- Paths work for both local `cargo build` and container builds
- No /run/extra-src indirection or Cargo.toml path munging required
- Auto-detection means it Just Works™

The Justfile's build target now calls `cargo xtask local-rust-deps` to
get bind mount args, falling back gracefully if there are no external deps.
The old BOOTC_extra_src mechanism is still supported for backwards compat.

Assisted-by: OpenCode (Opus 4.5)
Signed-off-by: Colin Walters <walters@verbum.org>
Tests with equal numbers were getting unstable sorting, causing
the generated file to flap.

Signed-off-by: Colin Walters <walters@verbum.org>
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.

1 participant