Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gosec overflow alerts #5799

Merged
merged 17 commits into from
Sep 13, 2024
Merged

Conversation

dmathieu
Copy link
Member

To allow the golangci-lint upgrade in #5796.

@dmathieu dmathieu added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Sep 10, 2024
Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.5%. Comparing base (5e3434c) to head (dbb596f).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #5799   +/-   ##
=====================================
  Coverage   84.5%   84.5%           
=====================================
  Files        272     272           
  Lines      22771   22776    +5     
=====================================
+ Hits       19251   19256    +5     
  Misses      3177    3177           
  Partials     343     343           

see 10 files with indirect coverage changes

@dmathieu dmathieu force-pushed the fix-uint-gosec branch 3 times, most recently from 9d84ad7 to b21f2f9 Compare September 10, 2024 08:10
@dmathieu dmathieu marked this pull request as ready for review September 10, 2024 08:13
@pellared pellared dismissed their stale review September 10, 2024 09:03

Bug is fixed

@MrAlias
Copy link
Contributor

MrAlias commented Sep 10, 2024

This is missing fixes for all the other lint errors:

golangci-lint --fix ./bridge/opencensus
internal/span.go:64:33: G115: integer overflow conversion int32 -> uint32 (gosec)
	s.otelSpan.SetStatus(codes.Code(status.Code), status.Message)
	                               ^
internal/ocmetric/metric.go:147:25: G115: integer overflow conversion int64 -> uint64 (gosec)
				Count:        uint64(dist.Count),
				                    ^
internal/ocmetric/metric.go:169:27: G115: integer overflow conversion int64 -> uint64 (gosec)
		bucketCounts[i] = uint64(bucket.Count)
		                        ^
internal/ocmetric/metric.go:360:27: G115: integer overflow conversion int64 -> uint64 (gosec)
				Count:          uint64(summary.Count),
				                      ^
golangci-lint --fix ./exporters/otlp/otlplog/otlploggrpc
internal/transform/log.go:145:15: G115: integer overflow conversion int64 -> uint64 (gosec)
	return uint64(t.UnixNano())
	             ^
golangci-lint --fix ./exporters/otlp/otlplog/otlploghttp
internal/transform/log.go:145:15: G115: integer overflow conversion int64 -> uint64 (gosec)
	return uint64(t.UnixNano())
	             ^
golangci-lint --fix ./exporters/otlp/otlpmetric/otlpmetricgrpc
internal/transform/metricdata.go:285:15: G115: integer overflow conversion int64 -> uint64 (gosec)
	return uint64(t.UnixNano())
	             ^
golangci-lint --fix ./exporters/otlp/otlpmetric/otlpmetrichttp
internal/transform/metricdata.go:285:15: G115: integer overflow conversion int64 -> uint64 (gosec)
	return uint64(t.UnixNano())
	             ^
golangci-lint --fix ./exporters/otlp/otlptrace
internal/tracetransform/span.go:100:33: G115: integer overflow conversion int64 -> uint64 (gosec)
		StartTimeUnixNano:      uint64(sd.StartTime().UnixNano()),
		                              ^
internal/tracetransform/span.go:101:33: G115: integer overflow conversion int64 -> uint64 (gosec)
		EndTimeUnixNano:        uint64(sd.EndTime().UnixNano()),
		                              ^
internal/tracetransform/span.go:181:15: G115: integer overflow conversion int32 -> uint32 (gosec)
	return uint32(flags)
	             ^
internal/tracetransform/span.go:195:34: G115: integer overflow conversion int64 -> uint64 (gosec)
			TimeUnixNano:           uint64(es[i].Time.UnixNano()),
			                              ^
golangci-lint --fix ./log
keyvalue.go:79:26: G115: integer overflow conversion int64 -> uint64 (gosec)
	return Value{num: uint64(v), any: KindInt64}
	                        ^
golangci-lint --fix ./schema
internal/parser_checks.go:29:39: G115: integer overflow conversion int -> uint64 (gosec)
	if fileFormatParsed.Major() != uint64(supportedFormatMajor) {
	                                     ^
internal/parser_checks.go:38:38: G115: integer overflow conversion int -> uint64 (gosec)
	if fileFormatParsed.Minor() > uint64(supportedFormatMinor) {
	                                    ^
golangci-lint --fix ./sdk/metric
internal/exemplar/value.go:31:46: G115: integer overflow conversion int64 -> uint64 (gosec)
		return Value{t: Int64ValueType, val: uint64(v)}

@dmathieu
Copy link
Member Author

Duh you're right, my bad. I forgot that the linter stops after the first package with failures. I have fixed everything else.

dmathieu and others added 2 commits September 12, 2024 19:52
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@dmathieu dmathieu merged commit a3c512a into open-telemetry:main Sep 13, 2024
31 checks passed
@dmathieu dmathieu deleted the fix-uint-gosec branch September 13, 2024 07:11
@MrAlias MrAlias added this to the v1.31.0 milestone Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants