Improve command whitelist checker.

This commit is contained in:
awesomemoder316 2021-08-17 21:01:07 -07:00
parent 0cb3156186
commit 05e2706fa9

View File

@ -37,14 +37,25 @@ public class ExecCommand implements WSCommand {
break;
}
String[] splitCommand = command.split(" ");
for (String whitelistedCommand : ud.getWhitelistedCommands()) {
if (command.toLowerCase().startsWith(whitelistedCommand)) {
String[] splitWhitelistedCommand = whitelistedCommand.split(" ");
if (!ud.isWhitelistActsAsBlacklist()) allowCommand = true; //cmd is whitelisted.
for (int x = 0; x < splitWhitelistedCommand.length; x ++) {
if (!ud.isWhitelistActsAsBlacklist()) {
if (splitCommand[x].equalsIgnoreCase(splitWhitelistedCommand[x])) { //cmd is whitelisted.
allowCommand = true;
continue;
}
allowCommand = false;
break;
}
}
}
if (!allowCommand //Check if was detected by whitelist
&& ud.isWhitelistActsAsBlacklist()) allowCommand = true; //cmd is not blacklisted.