[OneCollector] Validate full event names - #4857
Conversation
Validate `{EventFullName}` before serializing to avoid payload corruption.
Add PR number.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4857 +/- ##
=======================================
Coverage 77.37% 77.37%
=======================================
Files 468 468
Lines 19812 19831 +19
=======================================
+ Hits 15329 15345 +16
- Misses 4483 4486 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Pull request dashboard statusWaiting on reviewers · refreshed 2026-08-14 16:20 UTC Review the latest changes. Status above doesn't look right?
|
There was a problem hiding this comment.
Pull request overview
Adds validation for {EventFullName} values supplied via log attributes in the OneCollector exporter to prevent unsafe/invalid raw JSON from being emitted (which could corrupt payloads). This fits into the exporter’s existing event name management and common-schema JSON serialization pipeline.
Changes:
- Add
IsEventFullNameValidand enforce character + length validation inEventNameManager.ResolveEventFullName(string), falling back to the default event full name when invalid. - Add tests to ensure JSON injection is not possible via
{EventFullName}and to validate allowed/rejected full-name inputs. - Update OneCollector exporter changelog to document the behavior change.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/OpenTelemetry.Exporter.OneCollector/Internal/EventNameManager.cs |
Validates {EventFullName} inputs (chars/length) before producing raw JSON bytes; logs and falls back to default on invalid input. |
test/OpenTelemetry.Exporter.OneCollector.Tests/LogRecordCommonSchemaJsonSerializerTests.cs |
Adds regression test asserting {EventFullName} cannot inject extra JSON properties into the serialized payload. |
test/OpenTelemetry.Exporter.OneCollector.Tests/EventNameManagerTests.cs |
Adds tests for single-argument {EventFullName} resolution, including unsafe character rejection and length handling. |
src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md |
Documents the new validation/fallback behavior in ## Unreleased. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Do not cache names that are too long. - Extend test coverage.
|
How much performance impact does adding the IsEventFullNameValid check introduce? |
I haven't measured it, but I would have thought it minimal as it's just scanning the chars in the name.
No, I was doing a code audit with Copilot/Claude (I forget which specifically), and it flagged that the validation didn't run in all cases. |
It was Copilot, and it addresses a path where JSON injection can occur (see the tests). |
- Bound the cache of event names. - Ensure event names and namespaces are valid JSON.
|
Added some additional hardening based on a scan of the code by Copilot and Claude. |
Escape non-ASCII characters.
Changes
Validate
{EventFullName}before serializing to avoid payload corruption.Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)