Skip to content

CASSANDRA-21146 Guardrail for client driver versions#4699

Open
smiklosovic wants to merge 1 commit intoapache:trunkfrom
smiklosovic:CASSANDRA-21146
Open

CASSANDRA-21146 Guardrail for client driver versions#4699
smiklosovic wants to merge 1 commit intoapache:trunkfrom
smiklosovic:CASSANDRA-21146

Conversation

@smiklosovic
Copy link
Copy Markdown
Contributor

Thanks for sending a pull request! Here are some tips if you're new here:

  • Ensure you have added or run the appropriate tests for your PR.
  • Be sure to keep the PR description updated to reflect all changes.
  • Write your PR title to summarize what this PR proposes.
  • If possible, provide a concise example to reproduce the issue for a faster review.
  • Read our contributor guidelines
  • If you're making a documentation change, see our guide to documentation contribution

Commit messages should follow the following format:

<One sentence description, usually Jira title or CHANGES.txt summary>

<Optional lengthier description (context on patch)>

patch by <Authors>; reviewed by <Reviewers> for CASSANDRA-#####

Co-authored-by: Name1 <email1>
Co-authored-by: Name2 <email2>

The Cassandra Jira

@smiklosovic smiklosovic force-pushed the CASSANDRA-21146 branch 9 times, most recently from 717609b to 4e3a9d4 Compare March 31, 2026 12:20
@bschoening bschoening requested a review from Copilot April 1, 2026 20:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces a new guardrail to warn or reject native protocol connections based on configured minimum client driver versions.

Changes:

  • Adds ClientDriverVersionGuardrail and wires it into STARTUP processing to enforce driver version constraints.
  • Exposes warned/disallowed driver-version maps via Guardrails MBean + configuration plumbing.
  • Adds unit and integration tests for version parsing/comparison and guardrail behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/java/org/apache/cassandra/db/guardrails/ClientDriverVersionGuardrail.java Implements the guardrail logic for comparing driver versions against configured minimums.
src/java/org/apache/cassandra/db/guardrails/Guardrails.java Registers the new guardrail and adds MBean getter/setter JSON serialization for the new config.
src/java/org/apache/cassandra/transport/messages/StartupMessage.java Invokes the guardrail during client STARTUP when driver name/version are provided.
src/java/org/apache/cassandra/db/guardrails/GuardrailsMBean.java Adds MBean methods for getting/setting minimum client driver versions (warn/fail).
src/java/org/apache/cassandra/db/guardrails/GuardrailsConfig.java Extends guardrails config interface with minimum driver version maps.
src/java/org/apache/cassandra/config/GuardrailsOptions.java Implements the new config getters and adds setters with logging for runtime updates.
src/java/org/apache/cassandra/config/Config.java Adds YAML-backed config fields for warned/disallowed minimum driver versions.
src/java/org/apache/cassandra/tools/nodetool/GuardrailsConfigCommand.java Excludes the new map-based configs from nodetool guardrails config handling.
conf/cassandra.yaml Documents new YAML options for minimum client driver versions (warn/disallow).
conf/cassandra_latest.yaml Mirrors the new YAML documentation in the “latest” config template.
test/unit/org/apache/cassandra/db/guardrails/GuardrailClientDriverVersionTest.java Adds unit/integration tests for version comparisons and guardrail outcomes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +75 to +77
String minimumVersion = getMinimumVersion(driverId, disallowed);
fail(String.format("Client driver %s is below required minimum version %s, connection rejected",
driverId, minimumVersion), state);
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

driverId originates from client-supplied STARTUP options and is interpolated directly into warning/failure messages that may be logged and/or surfaced to clients. To reduce log-forging and nuisance risks, consider sanitizing the string (e.g., strip \r/\n, enforce a reasonable max length) before embedding it into messages.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is not really necessary. We have basically three drivers. It is not like it is possible to inject big driver name. That driver name is statically set in the driver itself.

Comment on lines +85 to +86
warn(String.format("Client driver %s is below recommended minimum version %s",
driverId, minimumVersion));
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

driverId originates from client-supplied STARTUP options and is interpolated directly into warning/failure messages that may be logged and/or surfaced to clients. To reduce log-forging and nuisance risks, consider sanitizing the string (e.g., strip \r/\n, enforce a reasonable max length) before embedding it into messages.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not applicable imho, overkill in our situation

@smiklosovic smiklosovic force-pushed the CASSANDRA-21146 branch 2 times, most recently from eb26940 to 59d739e Compare April 2, 2026 12:59
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.

2 participants