Skip to content

Commit 7c58f29

Browse files
authored
Fix check for relative mag paths in datasource validation (#8720)
Relative paths in datasource-properties.json are supposed to be interpreted as relative to the dataset directory. This particular codepath resolved them in the current working directory, which yields wrong results. Note that this code will probably be changed soon again, when we make those paths (mostly) immutable. ### Steps to test: (I already tested locally) - Change datasource with explicit mag paths in allowed way, should work - Change a relative mag path to point outside of the organization directory (using `..`), should still be rejected ### Issues: - fixes https://scm.slack.com/archives/C5AKLAV0B/p1750859466889959 ------ - [x] Added changelog entry (create a `$PR_NUMBER.md` file in `unreleased_changes` or use `./tools/create-changelog-entry.py`) - [x] Needs datastore update after deployment
1 parent 9395ef6 commit 7c58f29

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

unreleased_changes/8720.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Fixed
2+
- Fixed a bug where the checks on relative paths were too strict when editing dataset settings.

webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/DataSourceService.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ class DataSourceService @Inject()(
226226
val uri = new URI(pathStr)
227227
if (DataVaultService.isRemoteScheme(uri.getScheme)) true
228228
else {
229-
val path = Path.of(new URI(pathStr).getPath).normalize().toAbsolutePath
229+
val path = organizationDir
230+
.resolve(dataSource.id.directoryName)
231+
.resolve(Path.of(new URI(pathStr).getPath).normalize())
232+
.toAbsolutePath
230233
val allowedParent = organizationDir.toAbsolutePath
231234
if (path.startsWith(allowedParent)) true else false
232235
}

0 commit comments

Comments
 (0)