fix(coreutils-port): constrain uu_app builder macro arguments#1629
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 5d46588 | Commit Preview URL | May 15 2026, 11:52 PM |
|
Deep-review note (defence-in-depth gap in
That means Tightening suggestion in let ty: syn::Type = syn::parse2(mac.tokens.clone())
.context("value_parser! in command builder must contain a type path")?;
if matches!(ty, syn::Type::Macro(_)) {
bail!("value_parser! must contain a plain type path, not a macro");
}Worth a regression test mirroring Generated by Claude Code |
syn::Type accepts Type::Macro, so the prior parse2::<Type> check let
value_parser!(env!("...")) slip past validation. Add an explicit
Type::Macro rejection plus a regression test exercising
value_parser!(env!("CI_SECRET")). Closes the defence-in-depth gap
flagged in PR review against TM-INF-025.
Motivation
uu_appsources from smuggling compile-time macros through name-only allowlisting (e.g.env!(include_str!(...))) that can leak build-host files or environment secrets.env!("CARGO_PKG_VERSION")and safevalue_parser!forms should be allowed in emitted clap builder chains.Description
visit_expr_macronow callsvalidate_allowed_command_builder_macro(mac: &syn::Macro)which returns structured errors for unsafe payloads.validate_env_macroto requireenv!tokens parse as a string literal and equal exactly"CARGO_PKG_VERSION", rejecting arbitrary env names and nested macros.validate_value_parser_macroto requirevalue_parser!/clap::value_parser!tokens parse as a RustType, preventing arbitrary token payloads.rejects_non_pkg_version_env_macroandrejects_env_macro_with_nested_macro_tokensand keep the existingaccepts_expected_builder_macrostest to ensure intended behavior is preserved.Testing
cargo fmt --allwhich completed successfully.cargo test -p bashkit-coreutils-portand all tests passed:29 passed, 0 failed(includes the new regression tests).Codex Task