Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOID] Fixes directory that should be non existing #574

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions core/src/test/java/apoc/export/ExportCoreSecurityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,18 @@ public TestIllegalExternalFSAccess(
not found. They all attempt to exit the import folder back to the apoc folder:
Directory Layout: .../apoc/core/target/import
*/
private static final String case10 = "file://%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f/apoc/" + FILENAME;
private static final String case11 = "file://../../../../apoc/" + FILENAME;
private static final String case12 = "file:///..//..//..//..//apoc//core//..//" + FILENAME;
private static final String case13 = "file:///..//..//..//..//apoc/" + FILENAME;
private static final String case14 =
"file://" + directory.getAbsolutePath() + "//..//..//..//..//apoc/" + FILENAME;
private static final String case15 =
"file:///%252e%252e%252f%252e%252e%252f%252e%252e%252f%252e%252e%252f/apoc/" + FILENAME;
private static final String nonExistingDirectory = "__non-existing-dir__";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use Files.createTempDirectory and then we don't have to worry about leaving stuff around on the host running the build.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's not going to create the file. If we do create the directory (even if it's temporary) then the tests would fail. I could make the name random if you prefer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, ok! I thought it would create some files there at some point. Because if it does we could do Files.createTempDirectory().resolve("non-existing") and have a non existing directory and be sure that those files will not remain on the host. But if we don't it doesn't matter. Feel free to merge!

private static final String case10 =
"file://%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f/" + nonExistingDirectory + "/" + FILENAME;
private static final String case11 = String.format("file://../../../../%s/%s", nonExistingDirectory, FILENAME);
private static final String case12 =
String.format("file:///..//..//..//..//%s//core//..//%s", nonExistingDirectory, FILENAME);
private static final String case13 =
String.format("file:///..//..//..//..//%s/%s", nonExistingDirectory, FILENAME);
private static final String case14 = String.format(
"file://" + directory.getAbsolutePath() + "//..//..//..//..//%s/%s", nonExistingDirectory, FILENAME);
private static final String case15 = "file:///%252e%252e%252f%252e%252e%252f%252e%252e%252f%252e%252e%252f/"
+ nonExistingDirectory + "/" + FILENAME;

public static final List<String> casesNotExistingDir =
Arrays.asList(case10, case11, case12, case13, case14, case15);
Expand Down
Loading