feat(lease): add --all flag, default to creating all leases#337
Conversation
- `fnox lease create --all` creates leases for all configured backends - `fnox lease create` (no backend name) defaults to --all behavior - `fnox lease` (no subcommand) defaults to `lease create --all` - Secrets are resolved once upfront and shared across all backends - Partial failures are reported but don't stop other backends Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello, 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
Changelog
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
|
Greptile SummaryThis PR adds Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["fnox lease [create]"] --> B{subcommand?}
B -- "None (fnox lease)" --> C["Construct LeaseCreateCommand\nbackend_name=None, all=true"]
B -- "Create(cmd)" --> D["cmd.run()"]
C --> D
D --> E["Resolve secrets once\n(shared across all backends)"]
E --> F{create_all?}
F -- "all=true OR\nbackend_name=None" --> G{leases empty?}
G -- "yes" --> H["Err: no backends configured"]
G -- "no" --> I["run_all()"]
F -- "backend_name=Some(n)" --> J["look up backend_name in config"]
J -- "not found" --> K["Err: backend not found"]
J -- "found" --> L["create_single()"]
I --> M["loop over all backends"]
M --> L
L --> N{success?}
N -- "Ok" --> O["output result\n(shell / json / env)"]
N -- "Err" --> P["eprintln error\npush to errors vec"]
O --> Q{more backends?}
P --> Q
Q -- "yes" --> M
Q -- "no" --> R{errors empty?}
R -- "yes" --> S["Ok(())"]
R -- "no" --> T["Err: aggregated failures"]
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new feature allowing the creation of leases for all configured backends with --all, and sets this as the default behavior for fnox lease. The code is well-refactored to support this, with logic split into run_all and create_single functions, and user experience is improved with better output formatting. However, it introduces a potential command injection vulnerability in the Env output format. Furthermore, a regression exists where interactively provided environment variables are not cleaned up, potentially leading to credential leaks. To address these, it is recommended to quote credential keys in the shell output and ensure all temporary environment variables are properly cleared using the TempEnvGuard.
| @@ -125,7 +210,6 @@ impl LeaseCreateCommand { | |||
| // TODO: unsafe set_var on a multi-threaded Tokio runtime is | |||
| // technically UB. Refactor to pass credentials explicitly. | |||
| unsafe { std::env::set_var(var, &value) }; | |||
There was a problem hiding this comment.
The PR removed the code that adds interactive credentials to the TempEnvGuard. As a result, credentials entered interactively are no longer cleared from the process environment after the command finishes, which can lead to sensitive information remaining in the environment of a long-running process (like the fnox TUI if it uses this command). Interactively set environment variables are not being cleaned up because the _temp_env_guard from run() is not being used here. To fix this, you should pass the _temp_env_guard from run() down to this function (and run_all()) and register the variable with it, for example, by adding unsafe { std::env::set_var(var, &value) }; temp_env_guard.keys.push(var.to_string()); after updating the function signature to accept temp_env_guard: &mut TempEnvGuard.
- Error when both backend_name and --all are specified (conflicts_with) - Thread TempEnvGuard into create_single so interactive env vars are cleaned up on exit - Return non-zero exit on partial failure so CI/scripts can detect it Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| leases.len(), | ||
| errors.join("\n") | ||
| ))); | ||
| } |
There was a problem hiding this comment.
Fails on any backend error, not only all
Medium Severity
The run_all method returns an error whenever !errors.is_empty(), meaning it fails if any backend fails. The PR description states it "fails only if all backends fail," so the condition needs to check errors.len() == leases.len() instead. As written, a single backend failure causes the entire command to report failure even when other backends succeeded.
The output changed from "Lease created" to "✓ Lease 'name' created (expires in Xm)", so match on "created" instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
### 🚀 Features - **(cloudflare)** add Cloudflare API token lease backend by [@jdx](https://github.com/jdx) in [#335](#335) - **(fido2)** bump demand to v2, mask PIN during typing by [@jdx](https://github.com/jdx) in [#334](#334) - **(init)** add -f as short alias for --force by [@jdx](https://github.com/jdx) in [#329](#329) - **(lease)** add --all flag, default to creating all leases by [@jdx](https://github.com/jdx) in [#337](#337) - **(lease)** add GitHub App installation token lease backend by [@jdx](https://github.com/jdx) in [#342](#342) ### 🐛 Bug Fixes - **(config)** fix directory locations to follow XDG spec by [@jdx](https://github.com/jdx) in [#336](#336) - **(exec)** use unix exec and exit silently on subprocess failure by [@jdx](https://github.com/jdx) in [#339](#339) - **(fido2)** remove duplicate touch prompt by [@jdx](https://github.com/jdx) in [#332](#332) - **(set)** write to lowest-priority existing config file by [@jdx](https://github.com/jdx) in [#331](#331) - **(tui)** skip providers requiring interactive auth by [@jdx](https://github.com/jdx) in [#333](#333) ### 🛡️ Security - **(ci)** retry lint step to handle transient pkl fetch failures by [@jdx](https://github.com/jdx) in [#341](#341) - **(mcp)** add MCP server for secret-gated AI agent access by [@jdx](https://github.com/jdx) in [#343](#343) - add guide for fnox sync by [@jdx](https://github.com/jdx) in [#328](#328) ### 🔍 Other Changes - share Rust cache across CI jobs by [@jdx](https://github.com/jdx) in [#340](#340)


Summary
fnox lease create --allcreates leases for all configured backends sequentiallyfnox lease create(no backend name) defaults to--allbehaviorfnox lease(no subcommand) defaults tolease create --allTest plan
fnox leaseto verify all are created🤖 Generated with Claude Code
Note
Medium Risk
Changes core lease-creation CLI semantics and introduces multi-backend execution/error aggregation, which could affect scripts and failure handling across backends.
Overview
Updates the
leaseCLI sofnox leasewith no subcommand now defaults to creating leases for all configured backends, andfnox lease createaccepts an optional[BACKEND_NAME]plus a new-a/--allflag (mutually exclusive with a backend name).Refactors lease creation to resolve secrets once up-front and then create leases sequentially across backends, collecting and reporting per-backend failures before returning a combined error; output formatting is tweaked (success prefix, indented/masked creds, JSON now includes
backend). Docs/usage specs and bats tests are updated to match the new CLI behavior/output.Written by Cursor Bugbot for commit a8fd891. This will update automatically on new commits. Configure here.