Skip to content

Validate endpoint URLs and reject embedded credentials - #281

Merged
thushan merged 3 commits into
mainfrom
fix/endpoint-url-validation
Nov 22, 2026
Merged

thushan merged 3 commits into
mainfrom
fix/endpoint-url-validation

Conversation

@thushan

@thushan thushan commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Summary

An endpoint URL that has credentials written before the scheme, such as user:secret@http://host:11434, loaded without error, and the secret reached the logs, the startup table and /internal/status. Endpoint URLs are now checked in one place by three simple rules, and --validate-config runs the same check.

Type of change

  • Bug fix

What changed

  • internal/adapter/discovery/endpoint_url.go: ValidateEndpointURLs applies three rules:
    • url must be an absolute http/https URL with a host;
    • no @ or %40 may appear in url, health_check_url or model_url;
    • each override must be either a path starting with exactly one / or an absolute URL that meets the first rule.
  • Errors name the endpoint and the field, but never the configured value or what url.Parse returned.
  • repository.go: validateEndpointConfig calls the validator. The other setting checks move into validateEndpointSettings. Removed: redactURLUserinfo, malformedEndpointURLError, isURLScheme and the old userinfo check.
  • validate.go: --validate-config reports every invalid endpoint and exits 1. The duplicate-URL warning skips endpoints that fail validation.
  • Tests:
    • endpoint_url_test.go is a table of valid and invalid URLs, with a check that no error message contains a secret fragment;
    • TestRunValidateConfig_InvalidEndpointURLsFail covers the CLI path;
    • TestLoadFromConfig_RejectsCredentialBeforeScheme covers config loading.
  • Docs:
    • the v0.2.0 release notes gain a Breaking entry;
    • configuration/reference.md lists the rules per field;
    • configuration/endpoint-auth.md puts the credential warning on all three fields.

Decisions

  • Blunt rules, not URL interpretation: @ and %40 are rejected even in a path, because no realistic backend URL needs them and url.Parse puts credentials in different fields depending on where they are written.
  • Credentials belong in the endpoint's auth block, which the error message points to.

Compatibility

Breaking for configs that relied on loose parsing. Olla now refuses to start when an endpoint URL:

  • has no scheme;
  • uses a scheme other than http(s);
  • contains @ or %40;
  • has an override starting with //.

Run olla --validate-config before upgrading. Every shipped config passes.

How was this tested?

  • make ready passes at f76741b.
  • Fable and Codex cross-reviewed the branch. Two findings were left out of scope as follow-ups, and the rest are fixed.

Follow-ups

  • API keys in query strings still reach the logs (this predates the branch).

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a8fe186 and f76741b.

Files selected for processing: 12

  • docs/content/about/release-notes.md
  • docs/content/configuration/endpoint-auth.md
  • docs/content/configuration/reference.md
  • internal/adapter/discovery/duplicate_url_test.go
  • internal/adapter/discovery/endpoint_url.go
  • internal/adapter/discovery/endpoint_url_test.go
  • internal/adapter/discovery/repository.go
  • internal/adapter/discovery/repository_malformed_url_test.go
  • internal/adapter/discovery/repository_test.go
  • internal/adapter/discovery/repository_userinfo_test.go
  • validate.go
  • validate_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@thushan
thushan merged commit fc98f2f into main Nov 22, 2026
8 checks passed
@thushan
thushan deleted the fix/endpoint-url-validation branch November 22, 2026 21:59
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.

1 participant