Skip to content

Harden qr init secret handling and config recovery#45

Closed
baanish wants to merge 2 commits into
masterfrom
cursor/init-secret-hardening-93e4
Closed

Harden qr init secret handling and config recovery#45
baanish wants to merge 2 commits into
masterfrom
cursor/init-secret-hardening-93e4

Conversation

@baanish

@baanish baanish commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

Makes qr init safe to rerun after corrupt/partial config and avoids writing API keys insecurely to config.toml.

  • Dispatches qr init before AppConfig::load() so a broken config cannot block recovery
  • Recreates config when missing or invalid
  • Adds atomic::write_private() for Unix 0600 config creation from the first byte
  • Applies keychain storage to fallback provider keys with explicit messaging when config storage is used
  • Adds CLI regression tests for corrupt-config recovery, permissions, and fallback keychain behavior

Test plan

  • cargo test
  • cargo fmt --all -- --check
  • cargo clippy --all-targets --locked -- -D warnings
Open in Web Open in Cursor 

Co-authored-by: Aanish Bhirud <baanish@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@cursor[bot], you've reached your PR review limit, so we couldn't start this review.

Next review available in: 3 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: b77089ea-a9ad-4cb4-b65d-cb02411b0a7a

📥 Commits

Reviewing files that changed from the base of the PR and between fcf57af and 3baf7d7.

📒 Files selected for processing (6)
  • src/ai/client.rs
  • src/atomic.rs
  • src/config.rs
  • src/main.rs
  • src/secret.rs
  • tests/cli.rs

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

@cursor cursor Bot marked this pull request as ready for review July 1, 2026 09:40
@kilo-code-bot

kilo-code-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • src/ai/client.rs
  • src/config.rs
  • src/main.rs
  • src/secret.rs
  • tests/cli.rs
Previous Review Summary (commit d27b0fd)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit d27b0fd)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • src/atomic.rs
  • src/config.rs
  • src/main.rs
  • src/secret.rs
  • tests/cli.rs

Reviewed by glm-5.2-short · Input: 18.5K · Output: 3.2K · Cached: 152.1K

- Parse config.toml without QR_* overrides when deciding if init should recreate
- Fail clearly on invalid env overrides instead of treating them as corrupt config
- Prefix keychain accounts with primary/fallback role; legacy lookup for primary
- Add tests for invalid-env init behavior and shared-default-env keychain storage

Co-authored-by: Aanish Bhirud <baanish@users.noreply.github.com>
@baanish baanish closed this Jul 1, 2026
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.

2 participants