Skip to content

Fix G602 analyzer panic that kills gosec process#1491

Merged
ccojocar merged 4 commits intosecurego:masterfrom
ravisastryk:fix-g602-crash-issue-1489
Feb 7, 2026
Merged

Fix G602 analyzer panic that kills gosec process#1491
ccojocar merged 4 commits intosecurego:masterfrom
ravisastryk:fix-g602-crash-issue-1489

Conversation

@ravisastryk
Copy link
Contributor

@ravisastryk ravisastryk commented Feb 6, 2026

Fixes #1489 - Running gosec with G602 enabled crashes on certain codebases.

The issue is that the G602 slice-bounds analyzer panics on certain SSA instruction patterns (nil const values, short type strings, nil blocks). Since there is no recover() in the analyzer's run path, the panic propagates and terminates the entire gosec process before any results are written.

Fix:

  • Add defer recover() to the analyzer run function - G602 panic degrades to a logged error instead of crashing the process
  • Nil-check handling with defensive programming strategy
  • Improve code coverage

@ravisastryk
Copy link
Contributor Author

This PR should follow after the merge of #1492

@ravisastryk ravisastryk force-pushed the fix-g602-crash-issue-1489 branch from d1d12f8 to 69cbfcc Compare February 6, 2026 02:09
@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 55.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.47%. Comparing base (1216c9b) to head (92b6cb9).
⚠️ Report is 178 commits behind head on master.

Files with missing lines Patch % Lines
analyzers/slice_bounds.go 55.00% 5 Missing and 4 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1491      +/-   ##
==========================================
+ Coverage   68.49%   69.47%   +0.97%     
==========================================
  Files          75       85      +10     
  Lines        4384     6748    +2364     
==========================================
+ Hits         3003     4688    +1685     
- Misses       1233     1828     +595     
- 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 eb252ba into securego:master Feb 7, 2026
6 checks passed
@ravisastryk ravisastryk deleted the fix-g602-crash-issue-1489 branch February 7, 2026 19:54
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.

An error occurred during the scanning process using G602, leading to the interruption of analysis and no output results

3 participants