Merge pull request #994 from FunkinCrew/cyn0x8/fileutil-sandbox

[PUBLIC PR] Sandboxing for FileUtil (prevent deleting important game files etc)
This commit is contained in:
Kade
2025-04-22 19:00:24 -04:00
committed by Cameron Taylor
7 changed files with 909 additions and 125 deletions
+3
View File
@@ -251,6 +251,9 @@ class PolymodHandler
Polymod.addImportAlias('lime.utils.Assets', funkin.Assets);
Polymod.addImportAlias('openfl.utils.Assets', funkin.Assets);
// `funkin.util.FileUtil` has unrestricted access to the file system.
Polymod.addImportAlias('funkin.util.FileUtil', funkin.util.FileUtilSandboxed);
// Add blacklisting for prohibited classes and packages.
// `Sys`
@@ -2361,7 +2361,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
}
}
if (!FileUtil.doesFileExist(chartPath))
if (!FileUtil.fileExists(chartPath))
{
trace('Previously loaded chart file (${chartPath.toString()}) does not exist, disabling link...');
menuItemRecentChart.disabled = true;
@@ -106,7 +106,7 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
}
}
if (!FileUtil.doesFileExist(chartPath))
if (!FileUtil.fileExists(chartPath))
{
trace('Previously loaded chart file (${chartPath}) does not exist, disabling link...');
linkRecentChart.disabled = true;
@@ -1073,7 +1073,7 @@ class StageEditorState extends UIState
var filePath = new haxe.io.Path(file);
var item = new MenuItem();
item.text = filePath.file + "." + filePath.ext;
item.disabled = !FileUtil.doesFileExist(file);
item.disabled = !FileUtil.fileExists(file);
var load = function(file:String) {
currentFile = file;
@@ -32,7 +32,7 @@ class BackupAvailableDialog extends Dialog
{
super();
if (!FileUtil.doesFileExist(filePath)) return;
if (!FileUtil.fileExists(filePath)) return;
// time text
var fileDate = Path.withoutExtension(Path.withoutDirectory(filePath));
@@ -62,7 +62,7 @@ class BackupAvailableDialog extends Dialog
}
buttonOpenBackup.onClick = function(_) {
if (FileUtil.doesFileExist(filePath) && state.welcomeDialog != null) // doing a check in case a sleezy FUCK decides to delete the backup file AFTER dialog opens
if (FileUtil.fileExists(filePath) && state.welcomeDialog != null) // doing a check in case a sleezy FUCK decides to delete the backup file AFTER dialog opens
{
state.welcomeDialog.loadFromFilePath(filePath);
}
@@ -35,7 +35,7 @@ class WelcomeDialog extends Dialog
{
trace(file);
if (!FileUtil.doesFileExist(file)) continue; // whats the point of loading something that doesnt exist
if (!FileUtil.fileExists(file)) continue; // whats the point of loading something that doesnt exist
var patj = new haxe.io.Path(file);
File diff suppressed because it is too large Load Diff