Skip to content

SOLR-18170: add validation for configset names#4248

Merged
epugh merged 6 commits intoapache:mainfrom
epugh:copilot/add-validation-for-configset-names
Mar 31, 2026
Merged

SOLR-18170: add validation for configset names#4248
epugh merged 6 commits intoapache:mainfrom
epugh:copilot/add-validation-for-configset-names

Conversation

@epugh
Copy link
Copy Markdown
Contributor

@epugh epugh commented Mar 29, 2026

https://issues.apache.org/jira/browse/SOLR-18170

Description

The Configsets API (both v1 and v2) accepted arbitrary names including invalid characters (!, ", \) and hyphen-prefixed names, while the Admin UI already enforced collection-style naming rules. This inconsistency allowed creation of unusable configsets and potential path traversal via names like test/../other.

Solution

Changes

  • SolrIdentifierValidator — Added CONFIGSET to IdentifierType enum and validateConfigSetName() convenience method, applying the same pattern already used for collections/cores/shards (^(?!\-)[\\._A-Za-z0-9\\-]+$)

  • CloneConfigSet — Validate name before any other checks in cloneExistingConfigSet() (v2 CREATE)

  • UploadConfigSet — Validate name at entry of both uploadConfigSet() and uploadConfigSetFile() (v2 UPLOAD)

  • TestConfigSetsAPI — Added invalid-name assertions to testCreateErrors() and testUploadErrors() covering configset!, configset", -configset, and names with spaces

Invalid names now return HTTP 400:

Invalid configset: [configset!]. configset names must consist entirely of periods,
underscores, hyphens, and alphanumerics as well as not start with a hyphen.

I also discovered that I think some of the ignoreException() and unIgnoreException() pairing in our tests are not needed. At least in TestConfigSetsAPI copilot added one, and I removed it and the test worked just fine. Also finally learned a bit more about the use of LogListener, but going to save dealing with those legacy pairigns for another PR.

Tests

Added new tests.

Copilot AI and others added 4 commits March 29, 2026 14:13
- Add CONFIGSET to SolrIdentifierValidator.IdentifierType enum
- Add validateConfigSetName() method in SolrIdentifierValidator
- Validate configset name in CloneConfigSet.cloneExistingConfigSet()
- Validate configset name in UploadConfigSet.uploadConfigSet() and uploadConfigSetFile()
- Add tests for invalid configset names in TestConfigSetsAPI

Agent-Logs-Url: https://github.com/epugh/solr/sessions/0bc6a4dc-739c-4e58-b626-e30446c4864b

Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
// Checking error when configuration name contains invalid characters
for (String invalidName : new String[] {"configset!", "-configset"}) {
map =
postDataAndGetResponse(
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.

In another PR, this will move to strongly typed SolrJ object.

@epugh
Copy link
Copy Markdown
Contributor Author

epugh commented Mar 29, 2026

Test that failed is a known buggy test... Once I get a review, or no review and no "this isn't right" then I'll merge, mid week say?

Copy link
Copy Markdown
Contributor

@malliaridis malliaridis left a comment

Choose a reason for hiding this comment

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

This seems pretty much like just including configsets validation. I tested it manually by making direct API calls as well, and it works as expcted, nice.

I do not know all the options we have for creating configsets, so maybe another reviewer would be good?

@epugh epugh merged commit 24b5765 into apache:main Mar 31, 2026
5 of 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.

3 participants