feat: support rainbow v2025.3.3
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package com.novitechie.rules;
|
||||
|
||||
import com.janetfilter.core.commons.DebugInfo;
|
||||
import com.janetfilter.core.models.FilterRule;
|
||||
import com.novitechie.LogUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -11,56 +12,38 @@ import java.util.List;
|
||||
*/
|
||||
public class SystemRule {
|
||||
|
||||
private static final List<String> PREVENT_LOAD_ENV = new ArrayList<String>() {
|
||||
{
|
||||
add("IDEA_VM_OPTIONS");
|
||||
add("CLION_VM_OPTIONS");
|
||||
add("PHPSTORM_VM_OPTIONS");
|
||||
add("GOLAND_VM_OPTIONS");
|
||||
add("PYCHARM_VM_OPTIONS");
|
||||
add("WEBSTORM_VM_OPTIONS");
|
||||
add("WEBIDE_VM_OPTIONS");
|
||||
add("RIDER_VM_OPTIONS");
|
||||
add("DATAGRIP_VM_OPTIONS");
|
||||
add("RUBYMINE_VM_OPTIONS");
|
||||
add("APPCODE_VM_OPTIONS");
|
||||
add("DATASPELL_VM_OPTIONS");
|
||||
add("GATEWAY_VM_OPTIONS");
|
||||
add("JETBRAINS_CLIENT_VM_OPTIONS");
|
||||
add("JETBRAINSCLIENT_VM_OPTIONS");
|
||||
add("JANF_DEBUG");
|
||||
add("JANF_OUTPUT");
|
||||
}
|
||||
};
|
||||
private static List<FilterRule> hideEnvRules = Collections.emptyList();
|
||||
|
||||
private static final List<String> PREVENT_LOAD_PROPERTY = new ArrayList<String>() {
|
||||
{
|
||||
add("janf.debug");
|
||||
add("janf.output");
|
||||
}
|
||||
};
|
||||
private static List<FilterRule> hidePropertyRules = Collections.emptyList();
|
||||
|
||||
public static void initRules(List<FilterRule> hideEnvRules, List<FilterRule> hidePropertyRules) {
|
||||
SystemRule.hideEnvRules = hideEnvRules;
|
||||
SystemRule.hidePropertyRules = hidePropertyRules;
|
||||
}
|
||||
|
||||
public static boolean checkEnv(String name) {
|
||||
boolean f = PREVENT_LOAD_ENV.stream().anyMatch(name::equals);
|
||||
if (f) {
|
||||
if (StackTraceRule.check()) {
|
||||
DebugInfo.output("======================LoadEnv: " + name);
|
||||
LogUtil.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
if (checkHideEnv(name) && StackTraceRule.check()) {
|
||||
DebugInfo.output("======================LoadEnv: " + name);
|
||||
LogUtil.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean checkProperty(String name) {
|
||||
boolean f = PREVENT_LOAD_PROPERTY.stream().anyMatch(name::equals);
|
||||
if (f) {
|
||||
if (StackTraceRule.check()) {
|
||||
DebugInfo.output("======================LoadProperty: " + name);
|
||||
LogUtil.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
if (checkHideProperty(name) && StackTraceRule.check()) {
|
||||
DebugInfo.output("======================LoadProperty: " + name);
|
||||
LogUtil.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean checkHideEnv(String name) {
|
||||
return hideEnvRules.stream().anyMatch(rule -> rule.test(name));
|
||||
}
|
||||
|
||||
private static boolean checkHideProperty(String name) {
|
||||
return hidePropertyRules.stream().anyMatch(rule -> rule.test(name));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user