Skip to content

Add input validation for MariaDBAccount and MariaDBDatabase CR fields#483

Merged
openshift-merge-bot[bot] merged 1 commit into
openstack-k8s-operators:mainfrom
stuggi:fix_cr_field_validation
Jun 24, 2026
Merged

Add input validation for MariaDBAccount and MariaDBDatabase CR fields#483
openshift-merge-bot[bot] merged 1 commit into
openstack-k8s-operators:mainfrom
stuggi:fix_cr_field_validation

Conversation

@stuggi

@stuggi stuggi commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Add kubebuilder:validation:Pattern and MaxLength constraints to MariaDBAccount.spec.userName and MariaDBDatabase.spec.name, .defaultCharacterSet, .defaultCollation fields.

These fields are rendered into SQL statements and shell commands via Go text/template without escaping. While K8s metadata validation currently prevents most injection characters (the field values flow into Job names and labels), adding explicit CRD-level validation makes the protection intentional rather than accidental.

The pattern ^[a-zA-Z0-9_]+$ matches all valid MySQL identifiers and all values currently used by consuming operators (keystone, nova, glance, cinder, nova_cell0, etc.).

Jira: OSPRH-31719

Add kubebuilder:validation:Pattern and MaxLength constraints to
MariaDBAccount.spec.userName and MariaDBDatabase.spec.name,
.defaultCharacterSet, .defaultCollation fields.

These fields are rendered into SQL statements and shell commands via
Go text/template without escaping. While K8s metadata validation
currently prevents most injection characters (the field values flow
into Job names and labels), adding explicit CRD-level validation
makes the protection intentional rather than accidental.

The pattern ^[a-zA-Z0-9_]+$ matches all valid MySQL identifiers and
all values currently used by consuming operators (keystone, nova,
glance, cinder, nova_cell0, etc.).

Jira: OSPRH-31719

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
@openshift-ci openshift-ci Bot requested review from dprince and lmiccini June 23, 2026 07:23
@stuggi stuggi requested a review from dciabrin June 23, 2026 07:23
@openshift-ci

openshift-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dciabrin, stuggi

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 1bf8617 into openstack-k8s-operators:main Jun 24, 2026
6 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