Skip to content

Security scan fixes - gosec#1846

Merged
limak9182 merged 1 commit intofeature/database-controllersfrom
fix/go-sec-scans-fix
Apr 15, 2026
Merged

Security scan fixes - gosec#1846
limak9182 merged 1 commit intofeature/database-controllersfrom
fix/go-sec-scans-fix

Conversation

@limak9182
Copy link
Copy Markdown

@limak9182 limak9182 commented Apr 15, 2026

Description

Handle previously ignored error return values from ctrl.SetControllerReference in the PostgreSQL cluster builder functions, flagged by gosec (G104 / CWE-703).

Key Changes

  • pkg/postgresql/cluster/core/cluster.go: buildCNPGCluster and buildCNPGPooler now return error, propagating SetControllerReference failures to callers. Updated call sites at the reconciler level (Reconcile) and createConnectionPooler to handle the new error.
  • pkg/postgresql/cluster/core/cluster_unit_test.go: Updated tests for TestBuildCNPGCluster, TestBuildCNPGPooler/rw_pooler, and TestBuildCNPGPooler/ro_pooler to assert no error on the new return signature.

Testing and Verification

  • All existing unit tests pass (go test ./pkg/postgresql/cluster/core/ -v)
  • gosec no longer reports G104 on cluster.go:567 and cluster.go:726

Related Issues

CPI-1859

PR Checklist

  • Code changes adhere to the project's coding standards.
  • Relevant unit and integration tests are included.
  • Documentation has been updated accordingly.
  • All tests pass locally.
  • The PR description follows the project's guidelines.

@github-actions
Copy link
Copy Markdown
Contributor

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contribution License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment with the exact sentence copied from below.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

Copy link
Copy Markdown

@M4KIF M4KIF left a comment

Choose a reason for hiding this comment

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

Important, nice to see static analysis related fixes.

@limak9182 limak9182 marked this pull request as ready for review April 15, 2026 08:40
@limak9182 limak9182 merged commit 6f83dfb into feature/database-controllers Apr 15, 2026
11 of 15 checks passed
@limak9182 limak9182 deleted the fix/go-sec-scans-fix branch April 15, 2026 08:40
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants