Skip to content

Commit

Permalink
fix gosec overflow alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Sep 10, 2024
1 parent e9ac0d2 commit 9d84ad7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions exporters/zipkin/internal/internaltest/text_map_propagator.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func (p *TextMapPropagator) Inject(ctx context.Context, carrier propagation.Text
}

// InjectedN tests if p has made n injections to carrier.
func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n int) bool {
if actual := p.stateFromCarrier(carrier).Injections; actual != uint64(n) {
func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n uint64) bool {
if actual := p.stateFromCarrier(carrier).Injections; actual != n {
t.Errorf("TextMapPropagator{%q} injected %d times, not %d", p.name, actual, n)
return false
}
Expand Down
4 changes: 2 additions & 2 deletions internal/internaltest/text_map_propagator.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func (p *TextMapPropagator) Inject(ctx context.Context, carrier propagation.Text
}

// InjectedN tests if p has made n injections to carrier.
func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n int) bool {
if actual := p.stateFromCarrier(carrier).Injections; actual != uint64(n) {
func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n uint64) bool {
if actual := p.stateFromCarrier(carrier).Injections; actual != n {
t.Errorf("TextMapPropagator{%q} injected %d times, not %d", p.name, actual, n)
return false
}
Expand Down
3 changes: 2 additions & 1 deletion internal/rawhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ func RawToBool(r uint64) bool {
}

func Int64ToRaw(i int64) uint64 {
return uint64(i)
// Assumes original was a valid uint64 (overflow not checked).
return uint64(i) // nolint: gosec
}

func RawToInt64(r uint64) int64 {
Expand Down
4 changes: 2 additions & 2 deletions internal/shared/internaltest/text_map_propagator.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func (p *TextMapPropagator) Inject(ctx context.Context, carrier propagation.Text
}

// InjectedN tests if p has made n injections to carrier.
func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n int) bool {
if actual := p.stateFromCarrier(carrier).Injections; actual != uint64(n) {
func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n uint64) bool {
if actual := p.stateFromCarrier(carrier).Injections; actual != n {
t.Errorf("TextMapPropagator{%q} injected %d times, not %d", p.name, actual, n)
return false
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/internal/internaltest/text_map_propagator.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func (p *TextMapPropagator) Inject(ctx context.Context, carrier propagation.Text
}

// InjectedN tests if p has made n injections to carrier.
func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n int) bool {
if actual := p.stateFromCarrier(carrier).Injections; actual != uint64(n) {
func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n uint64) bool {
if actual := p.stateFromCarrier(carrier).Injections; actual != n {
t.Errorf("TextMapPropagator{%q} injected %d times, not %d", p.name, actual, n)
return false
}
Expand Down

0 comments on commit 9d84ad7

Please sign in to comment.