Skip to content

Commit 9b41304

Browse files
committed
Cage it
1 parent 5a12b4e commit 9b41304

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

shared/src/main/java/eu/maveniverse/maven/toolbox/shared/DirectorySink.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ private void accept(Artifact artifact) throws IOException {
101101
output.verbose(" matched");
102102
String name = artifactNameMapper.map(artifactMapper.map(artifact));
103103
output.verbose(" mapped to name {}", name);
104-
Path target = directory.resolve(name);
104+
Path target = directory.resolve(name).toAbsolutePath();
105+
if (!target.startsWith(directory)) {
106+
throw new IOException("Path escape prevented; check mappings");
107+
}
105108
if (!writtenPaths.add(target) && !allowOverwrite) {
106109
throw new IOException("Overwrite prevented; check mappings");
107110
}

0 commit comments

Comments
 (0)