Skip to content

fix(coreutils-port): allow safe clap macros in uu_app validator#1620

Merged
chaliy merged 1 commit into
mainfrom
2026-05-09-propose-fix-for-macro-rejection-issue
May 9, 2026
Merged

fix(coreutils-port): allow safe clap macros in uu_app validator#1620
chaliy merged 1 commit into
mainfrom
2026-05-09-propose-fix-for-macro-rejection-issue

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 9, 2026

Motivation

  • The uu_app validator ran after rewriting and unconditionally rejected every macro, which broke legitimate rewritten/expected macros like env!("CARGO_PKG_VERSION") and clap::value_parser! used in generated clap builders.
  • Keep the security hardening (single-expression + Command::new root + disallowed side-effect methods) while restoring regeneration availability for normal coreutils sources.

Description

  • Relax visit_expr_macro in crates/bashkit-coreutils-port/src/args.rs to allowlist safe builder macros by deferring to a new is_allowed_command_builder_macro helper instead of rejecting all macros.
  • Add is_allowed_command_builder_macro which permits env!, unqualified value_parser!, and clap::value_parser! paths used by the rewriter and uutils sources.
  • Preserve existing hardening: single-expression check in validate_uu_app_body, root Command::new requirement, and is_disallowed_chain_method side-effect method blacklist.
  • Add regression tests accepts_expected_builder_macros and rejects_unexpected_macro_in_builder_chain to cover the rewritten uucore::crate_version!()env! case and to ensure unexpected macros (e.g. format!) are still rejected.

Testing

  • Ran cargo fmt --all which completed successfully.
  • Ran cargo test -p bashkit-coreutils-port and all tests passed (27 passed, 0 failed), including the new regression tests which validate allowed and disallowed macro behaviors.

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 9, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit d6f1bed Commit Preview URL May 09 2026, 01:46 AM

@chaliy chaliy merged commit 2a124f7 into main May 9, 2026
16 checks passed
@chaliy chaliy deleted the 2026-05-09-propose-fix-for-macro-rejection-issue branch May 9, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant