open-telemetry / opentelemetry-go-contrib

Collection of extensions for OpenTelemetry-Go.
https://opentelemetry.io/
Apache License 2.0
1.08k stars 505 forks source link

Fix panic caused by invalid spanId with b3 propagator #5754

Closed Cirilla-zmh closed 4 days ago

Cirilla-zmh commented 2 weeks ago

Background

When using the b3 single propagator, the presence of an invalid spanId in the request can trigger a panic.

Cause

The panic occurs due to an array index out-of-bounds error when parsing the SpanID without proper length checks for invalid spanIds.

Fix

Added a length check for SpanID to prevent this panic by ensuring spanIds are of valid length before processing.

linux-foundation-easycla[bot] commented 2 weeks ago

CLA Signed

The committers listed above are authorized under a signed CLA.

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 64.5%. Comparing base (d9e0bf2) to head (56cfb6d).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5754/graphs/tree.svg?width=650&height=150&src=pr&token=P6F3W9WA7Q&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry)](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5754?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) ```diff @@ Coverage Diff @@ ## main #5754 +/- ## ===================================== Coverage 64.5% 64.5% ===================================== Files 200 200 Lines 12558 12560 +2 ===================================== + Hits 8101 8105 +4 + Misses 4220 4218 -2 Partials 237 237 ``` | [Files](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5754?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) | Coverage Δ | | |---|---|---| | [propagators/b3/b3\_propagator.go](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5754?src=pr&el=tree&filepath=propagators%2Fb3%2Fb3_propagator.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-cHJvcGFnYXRvcnMvYjMvYjNfcHJvcGFnYXRvci5nbw==) | `100.0% <100.0%> (+1.2%)` | :arrow_up: |
dmathieu commented 2 weeks ago

The changelog entry needs to be fixed.

Cirilla-zmh commented 2 weeks ago

The changelog entry needs to be fixed.

@dmathieu Thank you for your hint. I just resolved the conflict and need your approval to run the workflow.

Cirilla-zmh commented 2 weeks ago

@dmathieu @MadVikingGod I've just rebased the main branch. If it's convenient for you, could you please run the workflow again? Thank you!

Cirilla-zmh commented 2 weeks ago

@dmathieu @MadVikingGod It seems that this PR already has the conditions for merge. If convenient, please merge it. Thanks a lot for you!