Created
November 19, 2022 21:07
-
-
Save dllewellyn/e409f3a7b3b34cb7708b80b0e729e293 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun saveFile(fileName: String, content: String) { | |
val file = File("/data/is/safe/to/go/here", fileName) | |
val isSafe = file | |
.verifyFile(this) { | |
File("/data/is/safe/to/go/here").allowDirectory() | |
} | |
if (isSafe) { // Without this check - what would happen? Bad things.. | |
file.writeText(content) | |
} | |
} | |
saveFile("../../../not/safe/to/go/here", "contents-of-malware") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment