Skip to content

fix: panic on float constants in overflow analyzer#1505

Merged
ccojocar merged 1 commit intosecurego:masterfrom
ravisastryk:fix/panic-constant-int64val
Feb 14, 2026
Merged

fix: panic on float constants in overflow analyzer#1505
ccojocar merged 1 commit intosecurego:masterfrom
ravisastryk:fix/panic-constant-int64val

Conversation

@ravisastryk
Copy link
Copy Markdown
Contributor

fix: prevent panic on float constants in conversion overflow analyzer

The issue is that gosec v2.23.0 panics with "-1 not an Int" when analyzing code with float-to-int conversions because constant.Int64Val() panics when called on non-Int constants.

Fixes #1502

Note: As part of this, we can also improve code coverage for utility, beyond the scope of this PR but we can detect upfront when any future panics happen.

@ravisastryk ravisastryk marked this pull request as ready for review February 13, 2026 17:15
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 13, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.73%. Comparing base (1216c9b) to head (0945aa4).
⚠️ Report is 283 commits behind head on master.

Files with missing lines Patch % Lines
analyzers/util.go 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1505      +/-   ##
==========================================
- Coverage   68.49%   66.73%   -1.77%     
==========================================
  Files          75       94      +19     
  Lines        4384     7301    +2917     
==========================================
+ Hits         3003     4872    +1869     
- Misses       1233     2197     +964     
- Partials      148      232      +84     

☔ 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.

@ccojocar ccojocar merged commit 616192c into securego:master Feb 14, 2026
6 checks passed
@ravisastryk ravisastryk deleted the fix/panic-constant-int64val branch February 14, 2026 19:12
flimzy pushed a commit to flimzy/gosec that referenced this pull request Mar 12, 2026
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.

panic: -1 not an Int

3 participants