Skip to content

Commit

Permalink
Update for new core SecretTag
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 30, 2022
1 parent 20636bd commit b0d7293
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Expand Up @@ -104,6 +104,20 @@ public static boolean canReadFile(File f) {
return true;
}
try {
String lown = CoreUtilities.toLowerCase(f.getCanonicalPath()).replace('\\', '/');
if (lown.endsWith("/")) {
lown = lown.substring(0, lown.length() - 1);
}
if (Debug.verbose) {
Debug.log("Checking file canRead: " + lown);
}
if (lown.contains("denizen/secrets.secret")) {
return false;
}
int dot = lown.lastIndexOf('.');
if (dot != -1 && lown.substring(dot + 1).equals("secret")) {
return false;
}
if (!Settings.allowStrangeYAMLSaves() &&
!f.getCanonicalPath().startsWith(new File(".").getCanonicalPath())) {
return false;
Expand All @@ -126,13 +140,17 @@ public static boolean canReadFile(File f) {
"sh", "bash", // Linux scripts
"bat", "ps1", "vb", "vbs", "vbscript", "batch", "cmd", "com", "msc", "sct", "ws", "wsf", // Windows scripts
"exe", "scr", "msi", "dll", "bin", // Windows executables
"lnk", "reg", "rgs" // other weird Windows files
"lnk", "reg", "rgs", // other weird Windows files
"secret" // Protected by Denizen
));

public static boolean isFileCanonicalStringSafeToWrite(String lown) {
if (lown.contains("denizen/config.yml")) {
return false;
}
if (lown.contains("denizen/secrets.secret")) {
return false;
}
if (lown.contains("denizen/scripts/")) {
return false;
}
Expand All @@ -156,7 +174,7 @@ public static boolean canWriteToFile(File f) {
lown = lown.substring(0, lown.length() - 1);
}
if (Debug.verbose) {
Debug.log("Checking file : " + lown);
Debug.log("Checking file canWrite: " + lown);
}
if (!Settings.allowStrangeYAMLSaves() &&
!f.getCanonicalPath().startsWith(new File(".").getCanonicalPath())) {
Expand Down
Expand Up @@ -326,8 +326,8 @@ else if (args.getString(1).equalsIgnoreCase("scripts")) {
}
Messaging.send(sender, "");
Messaging.send(sender, "<f>Specify which parts to reload. Valid options are: SAVES, NOTES, CONFIG, SCRIPTS");
Messaging.send(sender, "<b>Example: /denizen reload scripts");
Messaging.send(sender, "<f>Use '-a' to reload all parts.");
Messaging.send(sender, "<b>Example: /denizen reload saves");
Messaging.send(sender, "<f>Use '-a' to reload all parts at once.");
Messaging.send(sender, "<f>Note that you shouldn't use this command generally, instead use '/ex reload' - see also the Beginner's Guide @ https://guide.denizenscript.com/");
Messaging.send(sender, "");
}
Expand Down

0 comments on commit b0d7293

Please sign in to comment.