1818 */
1919package org .kie .maven .plugin ;
2020
21+ import org .drools .util .PathUtils ;
2122import org .drools .util .PortablePath ;
2223import org .kie .memorycompiler .resources .ResourceStore ;
2324
2425import java .io .File ;
2526import java .io .IOException ;
2627import java .nio .file .Files ;
2728import java .nio .file .Path ;
28- import java .nio .file .Paths ;
2929
3030public class DiskResourceStore implements ResourceStore {
3131
@@ -77,7 +77,7 @@ public void remove(String pResourceName) {
7777
7878 private void commonWrite (String fullPath , byte [] pResourceData , boolean createFolder ) {
7979 try {
80- final Path path = Paths . get ( fullPath ). normalize ( );
80+ final Path path = PathUtils . getSecuredPath ( root . toPath (), fullPath );
8181 if (createFolder ) {
8282 final Path parentPath = path .getParent ();
8383 if (parentPath != null ) {
@@ -92,15 +92,17 @@ private void commonWrite(String fullPath, byte[] pResourceData, boolean createFo
9292
9393 private byte [] commonRead (String fullPath ) {
9494 try {
95- return Files .readAllBytes (Paths .get (fullPath ).normalize ());
95+ final Path path = PathUtils .getSecuredPath (root .toPath (), fullPath );
96+ return Files .readAllBytes (path );
9697 } catch (IOException e ) {
9798 throw new RuntimeException (e );
9899 }
99100 }
100101
101102 private void commonRemove (String fullPath ) {
102103 try {
103- Files .deleteIfExists (Paths .get (fullPath ).normalize ());
104+ final Path path = PathUtils .getSecuredPath (root .toPath (), fullPath );
105+ Files .deleteIfExists (path );
104106 } catch (IOException e ) {
105107 throw new RuntimeException (e );
106108 }
0 commit comments