Skip to content

Commit

Permalink
SOLR-12429: Prevent symbolic links from being uploaded as part of a c…
Browse files Browse the repository at this point in the history
…onfigset (apache#2651)

* Add a check (and a test) of a symbolic link
  • Loading branch information
epugh authored Aug 27, 2024
1 parent 94146c1 commit a276a0f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Optimizations

Bug Fixes
---------------------
(No changes)
* SOLR-12429: Uploading a configset with a symbolic link produces a IOException. Now a error message to user generated instead. (Eric Pugh)

Dependency Upgrades
---------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ public static void assertConfigSetFolderLegal(Path confPath) throws IOException
new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
if (Files.isSymbolicLink(file)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
String.format(
Locale.ROOT,
"Not uploading symbolic link %s to configset, as symbolic links are not supported in ZooKeeper",
file));
}
if (FileTypeMagicUtil.isFileForbiddenInConfigset(file)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
Expand Down
22 changes: 21 additions & 1 deletion solr/packaging/test/test_zk.bats
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ teardown() {
sleep 1
run solr zk ls / -z localhost:${ZK_PORT}
assert_output --partial "myfile3.txt"

run solr zk cp zk:/ -r "${BATS_TEST_TMPDIR}/recursive_download/"
[ -e "${BATS_TEST_TMPDIR}/recursive_download/myfile.txt" ]
[ -e "${BATS_TEST_TMPDIR}/recursive_download/myfile2.txt" ]
Expand All @@ -139,6 +139,26 @@ teardown() {
assert_output --partial '"configSets":["_default","techproducts2"]'
}

@test "SOLR-12429 test upconfig fails with symlink" {
# should be unit test but had problems with Java SecurityManager and symbolic links
local source_configset_dir="${SOLR_TIP}/server/solr/configsets/sample_techproducts_configs"
test -d $source_configset_dir

ln -s ${source_configset_dir}/conf/stopwords.txt ${source_configset_dir}/conf/symlinked_stopwords.txt
ln -s ${source_configset_dir}/conf/lang ${source_configset_dir}/conf/language

# Use the -L option to confirm we have a symlink
[ -L ${source_configset_dir}/conf/symlinked_stopwords.txt ]
[ -L ${source_configset_dir}/conf/language ]

run solr zk upconfig -d ${source_configset_dir} -n techproducts_with_symlinks -z localhost:${ZK_PORT}
assert_output --partial "Uploading"
assert_output --partial "ERROR: Not uploading symbolic link"

rm ${source_configset_dir}/conf/symlinked_stopwords.txt
rm -d ${source_configset_dir}/conf/language
}

@test "downconfig" {
run solr zk downconfig -z localhost:${ZK_PORT} -n _default -d "${BATS_TEST_TMPDIR}/downconfig"
assert_output --partial "Downloading"
Expand Down

0 comments on commit a276a0f

Please sign in to comment.