Skip to content

Refactor runtime option resolution into focused modules#245

Merged
EffortlessSteven merged 2 commits into
mainfrom
codex/break-complex-function-into-srp-submodules
May 14, 2026
Merged

Refactor runtime option resolution into focused modules#245
EffortlessSteven merged 2 commits into
mainfrom
codex/break-complex-function-into-srp-submodules

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Motivation

  • The ShipperConfig::build_runtime_options implementation had grown into a large, complex function that mixed many responsibilities and made reasoning and testing harder.
  • Extracting small, single-responsibility resolvers improves readability, reduces borrow/move pitfalls, and prepares the code for future changes in how options are assembled.

Description

  • Replaced the large inline implementation of ShipperConfig::build_runtime_options with a small delegation point that calls runtime_options::build and preserved the public API and precedence semantics.
  • Added crates/shipper-config/src/runtime_options/mod.rs which assembles top-level RuntimeOptions and factors out helpers for readiness, parallel, state-dir, and rehearsal resolution.
  • Implemented focused submodules retry.rs, registry.rs, and secrets.rs under crates/shipper-config/src/runtime_options/ to encapsulate retry-policy resolution, multi-registry selection/fallback, and webhook/encryption override logic respectively.
  • Kept existing behavior intact: CLI overrides still take precedence over config file values and RetryPolicy::Custom retains its semantics when resolving retry fields.

Testing

  • Ran cargo fmt --all -- --check which succeeded.
  • Ran the crate test suite with cargo test -p shipper-config and all tests passed (crate unit and integration tests completed successfully).
  • Ran linting with cargo clippy -p shipper-config --all-targets --all-features -- -D warnings which completed without warnings.

Codex Task

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@EffortlessSteven has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 58 minutes and 24 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d10a701f-2287-4a35-af31-e3bfb1fac1d1

📥 Commits

Reviewing files that changed from the base of the PR and between 38d23d5 and e61f99c.

📒 Files selected for processing (6)
  • crates/shipper-config/src/lib.rs
  • crates/shipper-config/src/runtime_options/mod.rs
  • crates/shipper-config/src/runtime_options/registry.rs
  • crates/shipper-config/src/runtime_options/retry.rs
  • crates/shipper-config/src/runtime_options/secrets.rs
  • crates/shipper-config/tests/config_runtime_contract.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/break-complex-function-into-srp-submodules

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.

❤️ Share

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

@factory-droid

factory-droid Bot commented May 13, 2026

Copy link
Copy Markdown

Droid finished @EffortlessSteven's task —— View job


Review complete for PR #245 (c2917c6)

The refactoring correctly preserves runtime-option resolution semantics while improving code organization. One pre-existing SSRF risk was identified in registry fallback URL construction that should be addressed before merging.

Validation: 1 comment posted (approved). 0 comments rejected.


fn default_registry_for_name(name: &str) -> Registry {
if name == "crates-io" {
Registry::crates_io()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] SSRF risk in default_registry_for_name from unvalidated CLI input

When --registries is passed with a registry name not found in config, default_registry_for_name constructs format!("https://{name}.crates.io") by directly interpolating the user-supplied name argument. An attacker controlling the CLI --registries flag could probe internal infrastructure by specifying names like 169-254-169-254.crates.io or other internal hostname patterns as a crates.io subdomain. This is a pre-existing risk inherited from the original inline code, but the extraction into a dedicated function makes the attack surface more visible.

fn default_registry_for_name(name: &str) -> Registry {
    if name == "crates-io" {
        Registry::crates_io()
    } else {
        Registry {
            name: name.to_string(),
            api_base: format!("https://{name}.crates.io"),
            index_base: None,
        }
    }
}

Consider validating that name contains only permitted characters (e.g., alphanumeric, dash) before URL construction, or restrict to an allowlist of known registry identifiers.

@factory-droid

factory-droid Bot commented May 14, 2026

Copy link
Copy Markdown

Droid finished @EffortlessSteven's task —— View job



Validation result: approved

No candidate comments to validate — review_candidates.json contains an empty comments array. The prior SSRF finding posted as PR comment 3233464394 has already been addressed by this PR via the new is_safe_synthetic_registry_name allowlist validation.

Validation: 0 comments posted (approved). 0 comments rejected.

@EffortlessSteven EffortlessSteven merged commit df24db9 into main May 14, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant