File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
dspace-api/src/main/java/org/dspace/storage/bitstore Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 1919import java .util .List ;
2020import java .util .Map ;
2121
22+ import org .apache .commons .lang3 .StringUtils ;
2223import org .apache .logging .log4j .Logger ;
2324import org .dspace .content .Bitstream ;
2425import org .dspace .core .Utils ;
26+ import org .dspace .services .factory .DSpaceServicesFactory ;
2527
2628/**
2729 * Native DSpace (or "Directory Scatter" if you prefer) asset store.
@@ -252,7 +254,10 @@ protected File getFile(Bitstream bitstream) throws IOException {
252254 }
253255 File bitstreamFile = new File (bufFilename .toString ());
254256 Path normalizedPath = bitstreamFile .toPath ().normalize ();
255- if (!normalizedPath .startsWith (baseDir .getAbsolutePath ())) {
257+ String [] allowedAssetstoreRoots = DSpaceServicesFactory .getInstance ().getConfigurationService ()
258+ .getArrayProperty ("assetstore.allowed.roots" , new String []{});
259+ if (!normalizedPath .startsWith (baseDir .getAbsolutePath ())
260+ && !StringUtils .startsWithAny (normalizedPath .toString (), allowedAssetstoreRoots )) {
256261 log .error ("Bitstream path outside of assetstore root requested:" +
257262 "bitstream={}, path={}, assetstore={}" ,
258263 bitstream .getID (), normalizedPath , baseDir .getAbsolutePath ());
Original file line number Diff line number Diff line change @@ -12,12 +12,15 @@ assetstore.dir = ${dspace.dir}/assetstore
1212# This value will be used as `incoming` default store inside the `bitstore.xml`
1313# Possible values are:
1414# - 0: to use the `localStore`;
15- # - 1: to use the `s3Store`.
15+ # - 1: to use the `s3Store`.
1616# If you want to add additional assetstores, they must be added to that bitstore.xml
1717# and new values should be provided as key-value pairs in the `stores` map of the
18- # `bitstore.xml` configuration.
18+ # `bitstore.xml` configuration.
1919assetstore.index.primary = 0
2020
21+ # if the assetstore path is symbolic link, use this configuration to allow that path.
22+ # assetstore.allowed.roots = /data/assetstore
23+
2124# ---------------------------------------------------------------#
2225# -------------- Amazon S3 Specific Configurations --------------#
2326# ---------------------------------------------------------------#
@@ -54,4 +57,4 @@ assetstore.s3.awsSecretKey =
5457
5558# If the credentials are left empty,
5659# then this setting is ignored and the default AWS region will be used.
57- assetstore.s3.awsRegionName =
60+ assetstore.s3.awsRegionName =
You can’t perform that action at this time.
0 commit comments