fix(templating): reject URI templates with a field reference inside the authority#25886
fix(templating): reject URI templates with a field reference inside the authority#25886thomasqueirozb wants to merge 3 commits into
Conversation
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
| prefix: String, | ||
| }, | ||
|
|
||
| /// The literal prefix ends before the authority (host + optional port) is |
There was a problem hiding this comment.
Nit: There are a lot of verbose comments. We should delete those. The snafu(display text is sufficient. And the partial_uri_authority_rejected test covers this.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fec8bcd5d0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ```yaml | ||
| sinks: | ||
| my_sink: | ||
| uri: "https://tenant-{{ env }}.example.com/" |
There was a problem hiding this comment.
Fix the invalid remediation example
For users following this changelog, this replacement is still rejected by the new PartialUriAuthority check: its literal prefix is https://tenant-, which has no / after ://, so the field remains inside the hostname. The text says to keep the hostname static, but the example still puts {{ env }} in the host; use a static host with the dynamic value after a / instead.
Useful? React with 👍 / 👎.
| ```yaml | ||
| sinks: | ||
| my_sink: | ||
| uri: "https://api.internal{{ path }}" |
There was a problem hiding this comment.
Mark no-separator path templates as breaking
For this example, existing configs can be functional today when path renders with a leading /: the old checker used base https://api.internal with path / and accepted rendered URLs like https://api.internal/v1. This change now fails those configs at build time, so describing them as only having “dropped every event” hides a real breaking upgrade case that should be marked or explained in the changelog.
Useful? React with 👍 / 👎.
Summary
Template::literal_prefix()truncates purely on the byte offset of the first{{, with no URI-grammar awareness. For a template likehttps://tenant.{{ env }}.example.com/, this yields a literal prefix ofhttps://tenant., whichUriChecker::from_prefixhappily parses as authoritytenant.— a baseline no real render can ever match, so every rendered event was silently dropped by the confinement check. This also affected templates with no separator at all before the field, e.g.https://api.internal{{ path }}.This PR adds a build-time check: if there's no
/after://in the literal prefix, the field reference sits inside (or directly extends) the authority, and the template is now rejected at build time with a newBuildError::PartialUriAuthorityinstead of silently dropping every event at render time.Vector configuration
How did you test this PR?
partial_uri_authority_rejectedcovering both the mid-authority case and the no-separator case.uri_authority_mismatch_rejectedandno_static_uri_authority_rejectedto use a template with a static host closed off by/, since the previous no-separator template is now rejected at build time.cargo nextest run --no-default-features --lib template::— all pass.cargo clippy --no-default-features --lib— clean.Change Type
Is this a breaking change?
Does this PR include user facing changes?
no-changeloglabel to this PR.References
NA