[
https://issues.apache.org/jira/browse/SOLR-15169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17289829#comment-17289829
]
Andras Salamon commented on SOLR-15169:
---------------------------------------
Thanks for the comments.
I was not trying to add a new feature, I backported SOLR-14561 to our Solr
8.4.1 (+lots of patches) and got several similar unit test failures:
{noformat}
SolrCloudExampleTest
ShardRoutingCustomTest
TestRandomRequestDistribution
TestCloudManagedSchema
CheckHdfsIndexTest{noformat}
with errors like:
{noformat}
[junit4] 2> 7410 ERROR (qtp1427077336-53) [n:127.0.0.1:60158_sr_%2Fm
x:control_collection_shard1_replica_n1 ] o.a.s.h.RequestHandlerBase
org.apache.solr.common.SolrException: Path
/Users/andrassalamon/src/lucene-solr/solr/build/solr-core/test/J0/temp/solr.cloud.SolrCloudExampleTest_C8068C6606AB5C90-001/control-001/cores/control_collection_shard1_replica_n1
must be relative to SOLR_HOME, SOLR_DATA_HOME coreRootDirectory. Set system
property 'solr.allowPaths' to add
other allowed paths. {noformat}
Checking the logs showed that the normalize method will converter
{noformat}
/Users/andrassalamon/src/lucene-solr/solr/build/solr-core/test/J0/../../../../../../../../../Users/andrassalamon/src/lucene-solr/solr/build/solr-core/test/J0/temp/solr.cloud.ShardRoutingCustomTest_7699317C45F3CE23-001/control-001/cores/control_collection_shard1_replica_n1
{noformat}
to
{noformat}
./Users/andrassalamon/src/lucene-solr/solr/build/solr-core/test/J0/temp/solr.cloud.ShardRoutingCustomTest_7699317C45F3CE23-001/control-001/cores/control_collection_shard1_replica_n1
{noformat}
and after that even if allowedPath contains the following two paths:
{noformat}
/Users/andrassalamon/src/lucene-solr/solr/build/solr-core/test/J0/../../../../../../../../../Users/andrassalamon/src/lucene-solr/solr/build/solr-core/test/J0/temp/solr.cloud.ShardRoutingCustomTest_7699317C45F3CE23-001/control-001,
/Users/andrassalamon/src/lucene-solr/solr/build/solr-core/test/J0/../../../../../../../../../Users/andrassalamon/src/lucene-solr/solr/build/solr-core/test/J0/temp/solr.cloud.ShardRoutingCustomTest_7699317C45F3CE23-001/control-001/cores
{noformat}
startsWith will return false.
I checked the code and found the problem in the SolrPaths.assertPathAllowed
method.
I do think it's not a good idea to call normalize for pathToAssert and not call
it for allowPaths. To be honest I wouldn't call it at all, but the comment
before the call implies that it's important.
{noformat}
// Conversion Path -> String -> Path is to be able to compare against
org.apache.lucene.mockfile.FilterPath instances{noformat}
so that's why I added the normalize.
> SolrPaths.assertPathAllowed normalization problem
> -------------------------------------------------
>
> Key: SOLR-15169
> URL: https://issues.apache.org/jira/browse/SOLR-15169
> Project: Solr
> Issue Type: Bug
> Reporter: Andras Salamon
> Priority: Minor
> Time Spent: 10m
> Remaining Estimate: 0h
>
> In the {{SolrPaths.assertPathAllowed}} the {{normalize()}} method is only
> called for {{pathToAssert}} and not for the {{allowPaths}} elements, which
> means that the following call gives SolrException:
> {noformat}
> SolrPaths.assertPathAllowed(Path.of("/a/b/../b/d"),
> Set.of(Path.of("/a/b/../b"), Path.of("/c"))); {noformat}
> even if "a/b/..b/" is a prefix of "/a/b/../b/d".
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]