Skip to content

Enable gosec linter in golangci-lint#103

Merged
openshift-merge-bot[bot] merged 2 commits into
openstack-lightspeed:mainfrom
lpiwowar:lpiwowar/gosec
May 13, 2026
Merged

Enable gosec linter in golangci-lint#103
openshift-merge-bot[bot] merged 2 commits into
openstack-lightspeed:mainfrom
lpiwowar:lpiwowar/gosec

Conversation

@lpiwowar

@lpiwowar lpiwowar commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Chores
    • Enabled enhanced security linting checks with exclusions for test files and directories.
    • Updated random number generation to use cryptographically secure methods.

Review Change Stack

Add gosec to the list of enabled linters to catch security
issues. Exclude test files from gosec checks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented May 12, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ff122658-7faf-440a-a47c-3c099705b7b1

📥 Commits

Reviewing files that changed from the base of the PR and between 4dc1606 and c6f9735.

📒 Files selected for processing (2)
  • .golangci.yml
  • internal/controller/funcs.go

📝 Walkthrough

Walkthrough

This PR enables the gosec security linter in golangci.yml with test-file exclusions, and updates OLSConfigPing in the controller to use cryptographically secure randomness instead of the weak math/rand package when generating ping labels.

Changes

Security Enhancements

Layer / File(s) Summary
Enable gosec security linter
.golangci.yml
The gosec linter is added to the enabled linters list with exclusion rules for test files matching _test\.go and the test/ directory.
Cryptographic randomness in OLSConfigPing
internal/controller/funcs.go
Imports switch from math/rand to crypto/rand, and the OLSConfigPing function now generates random labels using cryptographically secure randomness bounded to math.MaxInt64 with error handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops through security's door,
Where gosec now catches what slipped before!
From weak random seeds to crypto so strong,
The ping label dances where it belongs. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: enabling the gosec linter in golangci-lint configuration, which is reflected in the .golangci.yml file modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lpiwowar

Copy link
Copy Markdown
Contributor Author

/test all

Replace weak random number generator (math/rand) with
cryptographically secure random number generator (crypto/rand)
to resolve gosec G404 finding.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lpiwowar

Copy link
Copy Markdown
Contributor Author

/test all

@lpiwowar lpiwowar marked this pull request as ready for review May 13, 2026 09:16
@openshift-ci openshift-ci Bot requested review from Akrog and umago May 13, 2026 09:16
@umago

umago commented May 13, 2026

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci

openshift-ci Bot commented May 13, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lpiwowar, umago

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot Bot merged commit d598c3f into openstack-lightspeed:main May 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants