feat: support rainbow v2025.3.3

This commit is contained in:
yelochick 2025-08-19 16:46:32 +08:00
parent 7a9f82629c
commit b316de054e
6 changed files with 140 additions and 97 deletions

44
privacy.conf.example Normal file
View File

@ -0,0 +1,44 @@
[Hide_Plugin]
EQUAL,io.zhile.research.ide-eval-resetter
EQUAL,Nasller.License
EQUAL,nasller
EQUAL,manifold.ij
[Hide_Package]
PREFIX,com.janetfilter
PREFIX,jdk.internal.org.objectweb.asm
[Hide_Resource]
EQUAL,/6c81ec87e55d331c267262e892427a3d93d76683.txt
PREFIX,/com/janetfilter
[Hide_Env]
EQUAL,IDEA_VM_OPTIONS
EQUAL,CLION_VM_OPTIONS
EQUAL,PHPSTORM_VM_OPTIONS
EQUAL,GOLAND_VM_OPTIONS
EQUAL,PYCHARM_VM_OPTIONS
EQUAL,WEBSTORM_VM_OPTIONS
EQUAL,WEBIDE_VM_OPTIONS
EQUAL,RIDER_VM_OPTIONS
EQUAL,DATAGRIP_VM_OPTIONS
EQUAL,RUBYMINE_VM_OPTIONS
EQUAL,APPCODE_VM_OPTIONS
EQUAL,DATASPELL_VM_OPTIONS
EQUAL,GATEWAY_VM_OPTIONS
EQUAL,JETBRAINS_CLIENT_VM_OPTIONS
EQUAL,JETBRAINSCLIENT_VM_OPTIONS
EQUAL,JANF_DEBUG
EQUAL,JANF_OUTPUT
[Hide_Property]
EQUAL,janf.debug
EQUAL,janf.output
[Ignore_Class]
EQUAL,com.janetfilter.core.utils.StringUtils
EQUAL,com.janetfilter.core.utils.DateUtils
[Ignore_Resource]
EQUAL,/com/janetfilter/core/utils/StringUtils.class
EQUAL,/com/janetfilter/core/utils/DateUtils.class

View File

@ -1,12 +1,27 @@
package com.novitechie;
import com.janetfilter.core.Environment;
import com.janetfilter.core.plugin.MyTransformer;
import com.janetfilter.core.plugin.PluginConfig;
import com.janetfilter.core.plugin.PluginEntry;
import com.novitechie.rules.IdeaPluginRule;
import com.novitechie.rules.LoadClassRule;
import com.novitechie.rules.ResourceRule;
import com.novitechie.rules.SystemRule;
import java.util.Arrays;
import java.util.List;
public class PrivacyPlugin implements PluginEntry {
@Override
public void init(Environment environment, PluginConfig config) {
IdeaPluginRule.initRules(config.getBySection("Hide_Plugin"));
LoadClassRule.initRules(config.getBySection("Hide_Package"), config.getBySection("Ignore_Class"));
ResourceRule.initRules(config.getBySection("Hide_Resource"), config.getBySection("Ignore_Resource"));
SystemRule.initRules(config.getBySection("Hide_Env"), config.getBySection("Hide_Property"));
}
@Override
public String getName() {
return "PRIVACY";

View File

@ -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,21 +12,22 @@ import java.util.List;
*/
public class IdeaPluginRule {
private static final List<String> PREVENT_LOAD_PLUGINS = new ArrayList<String>() {
{
add("io.zhile.research.ide-eval-resetter");
add("Nasller.License");
add("nasller");
add("manifold.ij");
}
};
private static List<FilterRule> hidePluginRules = Collections.emptyList();
public static void initRules(List<FilterRule> hidePluginRules) {
IdeaPluginRule.hidePluginRules = hidePluginRules;
}
public static boolean check(String name) {
boolean f = PREVENT_LOAD_PLUGINS.stream().anyMatch(name::equals);
if (f) {
if (checkHidePlugin(name)) {
DebugInfo.output("======================LoadPlugin: " + name);
LogUtil.printStackTrace();
return true;
}
return f;
return false;
}
private static boolean checkHidePlugin(String name) {
return hidePluginRules.stream().anyMatch(rule -> rule.test(name));
}
}

View File

@ -1,37 +1,37 @@
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;
public class LoadClassRule {
private static final List<String> PREVENT_LOAD_PACKAGES = new ArrayList<String>() {
{
// add("com.novitechie");
add("com.janetfilter");
add("jdk.internal.org.objectweb.asm");
}
};
private static List<FilterRule> hidePackageRules = Collections.emptyList();
private static final List<String> IGNORE_CLASS = new ArrayList<String>() {
{
add("com.janetfilter.core.utils.StringUtils");
}
};
private static List<FilterRule> ignoreClassRules = Collections.emptyList();
public static void initRules(List<FilterRule> hidePackageRules, List<FilterRule> ignoreClassRules) {
LoadClassRule.hidePackageRules = hidePackageRules;
LoadClassRule.ignoreClassRules = ignoreClassRules;
}
public static void check(String name) throws Exception {
boolean f = PREVENT_LOAD_PACKAGES.stream().anyMatch(name::startsWith);
if (f) {
boolean f2 = IGNORE_CLASS.stream().anyMatch(name::equals);
if (!f2) {
DebugInfo.output("======================LoadClass: " + name);
LogUtil.printStackTrace();
throw new ClassNotFoundException(name);
}
if (!checkIgnoreClass(name) && checkHidePackage(name)) {
DebugInfo.output("======================LoadClass: " + name);
LogUtil.printStackTrace();
throw new ClassNotFoundException(name);
}
}
private static boolean checkHidePackage(String name) {
return hidePackageRules.stream().anyMatch(rule -> rule.test(name));
}
private static boolean checkIgnoreClass(String name) {
return ignoreClassRules.stream().anyMatch(rule -> rule.test(name));
}
}

View File

@ -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,31 +12,29 @@ import java.util.List;
*/
public class ResourceRule {
private static final List<String> PREVENT_LOAD_RESOURCE = new ArrayList<String>() {
{
add("/6c81ec87e55d331c267262e892427a3d93d76683.txt");
add("/com/janetfilter");
}
};
private static List<FilterRule> hideResourceRules = Collections.emptyList();
private static final List<String> IGNORE_RESOURCE = new ArrayList<String>() {
{
add("/com/janetfilter/core/utils/StringUtils.class");
}
};
private static List<FilterRule> ignoreResourceRules = Collections.emptyList();
public static void initRules(List<FilterRule> hideResourceRules, List<FilterRule> ignoreResourceRules) {
ResourceRule.hideResourceRules = hideResourceRules;
ResourceRule.ignoreResourceRules = ignoreResourceRules;
}
public static boolean check(String name) {
boolean f = PREVENT_LOAD_RESOURCE.stream().anyMatch(name::startsWith);
if (f) {
boolean f1 = IGNORE_RESOURCE.stream().anyMatch(name::equals);
if (!f1) {
if (StackTraceRule.check()) {
DebugInfo.output("======================LoadResource: " + name);
LogUtil.printStackTrace();
return true;
}
}
if (!checkIgnoreResource(name) && checkHideResource(name) && StackTraceRule.check()) {
DebugInfo.output("======================LoadResource: " + name);
LogUtil.printStackTrace();
return true;
}
return false;
}
private static boolean checkHideResource(String name) {
return hideResourceRules.stream().anyMatch(rule -> rule.test(name));
}
private static boolean checkIgnoreResource(String name) {
return ignoreResourceRules.stream().anyMatch(rule -> rule.test(name));
}
}

View File

@ -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));
}
}