Skip to content

Fix gosec slice bounds warnings#764

Merged
asayyah merged 1 commit intomasterfrom
fix-gosec-slice-bounds
Dec 20, 2025
Merged

Fix gosec slice bounds warnings#764
asayyah merged 1 commit intomasterfrom
fix-gosec-slice-bounds

Conversation

@asayyah
Copy link
Copy Markdown
Contributor

@asayyah asayyah commented Dec 20, 2025

Add nolint directives for safe slice accesses where bounds are guaranteed by fixed-size arrays or prior bounds checks.

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 20, 2025

Codecov Report

❌ Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.27%. Comparing base (7b9612e) to head (4ccbed6).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/protocol/extension/extension.go 80.00% 1 Missing and 2 partials ⚠️
pkg/crypto/ccm/ccm.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #764      +/-   ##
==========================================
+ Coverage   81.26%   81.27%   +0.01%     
==========================================
  Files         101      101              
  Lines        5603     5602       -1     
==========================================
  Hits         4553     4553              
+ Misses        676      675       -1     
  Partials      374      374              
Flag Coverage Δ
go 81.27% <76.47%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@asayyah asayyah force-pushed the fix-gosec-slice-bounds branch from 6db18e0 to d3387e3 Compare December 20, 2025 23:00
@asayyah asayyah requested a review from JoTurk December 20, 2025 23:05
out := make([]byte, handshakeMessageClientHelloVariableWidthStart)
out[0] = m.Version.Major
out[1] = m.Version.Minor
copy(out[0:2], []byte{m.Version.Major, m.Version.Minor})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: even if it will prob never matter performance wise, and will likely be optimized by the compiler, the temporary slice is unnecessary. even if we'll have to add nolint. would prefer something like out[0], out[1] = m.Version.Major, m.Version.Minor // nolint...

but that's up to you.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah that's a good point, fixed it! thank you!

Copy link
Copy Markdown
Member

@JoTurk JoTurk left a comment

Choose a reason for hiding this comment

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

cool.

Add nolint directives for safe slice accesses where bounds
are guaranteed by fixed-size arrays or prior bounds checks.
@asayyah asayyah force-pushed the fix-gosec-slice-bounds branch from d3387e3 to 4ccbed6 Compare December 20, 2025 23:32
@asayyah asayyah merged commit 08d8c3e into master Dec 20, 2025
28 of 29 checks passed
@asayyah asayyah deleted the fix-gosec-slice-bounds branch December 20, 2025 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants