Skip to content

Strengthen generateRandomString - #25

Merged
openshift-merge-bot[bot] merged 2 commits into
openstack-k8s-operators:mainfrom
lpiwowar:lpiwowar/postgresql-compliance
Jul 21, 2026
Merged

Strengthen generateRandomString#25
openshift-merge-bot[bot] merged 2 commits into
openstack-k8s-operators:mainfrom
lpiwowar:lpiwowar/postgresql-compliance

Conversation

@lpiwowar

@lpiwowar lpiwowar commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Previously, generateRandomString() used crypto/rand bytes encoded with hex.EncodeToString(), so every character in the output was limited to the 16 hex digits. This gave only 4 bits of entropy per character, making the generated passwords significantly weaker than their length would suggest.

Replace hex encoding with an alphanumeric charset (a-z, A-Z, 0-9), which provides 62 possible values per character, enforce a minimum length of 16 characters, and guarantee that every generated password contains at least one lowercase letter, one uppercase letter, and one digit. This makes the password more secure against brute-force attacks.

Update tests to cover the minimum-length error path and the new character-class requirements.

Additionally, enable logging of successful and unsuccessful connections / disconnections to the PostgreSQL database to enable detection of malicious activity against the database.

@openshift-ci

openshift-ci Bot commented Jul 20, 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

@lpiwowar

Copy link
Copy Markdown
Collaborator Author

/test all

@openshift-ci

openshift-ci Bot commented Jul 20, 2026

Copy link
Copy Markdown

@lpiwowar: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/openstack-lightspeed-kuttl-4-18 04e0fa1 link true /test openstack-lightspeed-kuttl-4-18

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

lpiwowar added 2 commits July 21, 2026 04:54
Configure PostgreSQL to log all successful client connections
(log_connectsions = on) and all events related to disconnections of the
client (log_disconnections = on).
Previously, generateRandomString used crypto/rand bytes encoded with
hex.EncodeToString, so every character in the output was limited to the
16 hex digits. This gave only 4 bits of entropy per character, making
the generated passwords significantly weaker than their length would
suggest.

Replace hex encoding with an alphanumeric charset (a-z, A-Z, 0-9),
which provides 62 possible values per character, enforce a minimum length
of 16 characters, and guarantee that every generated password contains
at least one lowercase letter, one uppercase letter, and one digit.
This makes the password more secure against brute-force attacks.

Update tests to cover the minimum-length error path and the new
character-class requirements.
@lpiwowar
lpiwowar force-pushed the lpiwowar/postgresql-compliance branch from 04e0fa1 to 891a67d Compare July 21, 2026 09:04
@lpiwowar
lpiwowar marked this pull request as ready for review July 21, 2026 09:07
@openshift-ci
openshift-ci Bot requested review from Akrog and umago July 21, 2026 09:07

@umago umago left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci

openshift-ci Bot commented Jul 21, 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 e770335 into openstack-k8s-operators:main Jul 21, 2026
8 checks passed
@lpiwowar
lpiwowar deleted the lpiwowar/postgresql-compliance branch July 21, 2026 11:34
@lpiwowar
lpiwowar restored the lpiwowar/postgresql-compliance branch July 21, 2026 15:24
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