Skip to content

Commit

Permalink
[BUILD] Restrict read permission to project.basedir/target if securit…
Browse files Browse the repository at this point in the history
…y manager is used
  • Loading branch information
s1monw committed Apr 14, 2015
1 parent 773d64c commit fe411a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dev-tools/tests.policy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ grant {

// contain read access to only what we need:
// project base directory
permission java.io.FilePermission "${project.basedir}${/}-", "read";
permission java.io.FilePermission "${project.basedir}${/}target${/}-", "read";
// mvn custom ./m2/repository for dependency jars
permission java.io.FilePermission "${m2.repository}{/}-", "read";
// maven default repo for settings.xml etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;

import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFileExists;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFileNotExists;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;

Expand All @@ -47,20 +45,16 @@ public class FileSystemUtilsTests extends ElasticsearchTestCase {
private Path dst;

@Before
public void copySourceFilesToTarget() throws IOException {
public void copySourceFilesToTarget() throws IOException, URISyntaxException {
src = newTempDirPath();
dst = newTempDirPath();
Files.createDirectories(src);
Files.createDirectories(dst);

// We first copy sources test files from src/test/resources
// Because after when the test runs, src files are moved to their destination
Properties props = new Properties();
try (InputStream is = FileSystemUtilsTests.class.getResource("rootdir.properties").openStream()) {
props.load(is);
}

FileSystemUtils.copyDirectoryRecursively(Paths.get(props.getProperty("copyappend.root.dir")), src);
final Path path = Paths.get(FileSystemUtilsTests.class.getResource("/org/elasticsearch/common/io/copyappend").toURI());
FileSystemUtils.copyDirectoryRecursively(path, src);
}

@Test
Expand Down

0 comments on commit fe411a9

Please sign in to comment.