feat(external_commands): wire ExternalCommands env filtering into run() - #1278
feat(external_commands): wire ExternalCommands env filtering into run()#1278smoparth wants to merge 1 commit into
ExternalCommands env filtering into run()#1278Conversation
…run()` Add `env_filter` parameter to `external_commands.run()` and thread it through all call sites that execute untrusted third-party code (PEP 517 build hooks, wheel metadata) and uv cache invalidation. `os.environ` is filtered through `ExternalCommands.filter_env()` before `extra_environ` is applied, ensuring injected build variables are never stripped. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Shanmukh Pawan <smoparth@redhat.com>
📝 WalkthroughWalkthrough
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@smoparth Please mention |
Wiring decisionsWired (5 call sites) for untrusted third-party codeThese call sites execute PEP 517 build-backend hooks or other third-party scripts, so they receive
Not wired (8 call sites) — trusted tools onlyThese call sites invoke our own trusted tools (
To achieve full filteringIf all subprocesses should be filtered including
|
|
Overall direction of the PR looks good to me. |
|
This approach defaults to insecure behavior. In #1171 I proposed to deprecate and eventually remove |
Thanks for pointing to #1171, I missed that follow-up proposal. I've been going with the filter-env proposal#api-changes and actually even worked on the data model of it earlier, but had a few questions I wanted to clarify before pushing code. By the time I got back to it, I saw you'd already pushed that part and now again I missed this context about the follow-up proposal. Defaulting to secure behavior makes a lot of sense. I'm eager to work on Fromager, I think we should have an epic or an issue with linked sub-tasks to help with getting the correct context and picking up next steps. |
Add
env_filterparameter toexternal_commands.run()and thread it through all call sites that execute untrusted third-party code (PEP 517 build hooks, wheel metadata) and uv cache invalidation.os.environis filtered throughExternalCommands.filter_env()beforeextra_environis applied, ensuring injected build variables are never stripped.Closes: #1083
Pull Request Description
What
Why