feat: support plugin update zip scan and .vmoptions read interception

This commit is contained in:
zpj80231
2026-06-08 16:54:22 +08:00
parent cae96dd654
commit 88cbdac735
13 changed files with 646 additions and 236 deletions

View File

@@ -4,6 +4,7 @@ import com.janetfilter.core.commons.DebugInfo;
import com.janetfilter.core.models.FilterRule;
import com.novitechie.LogUtil;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
@@ -12,6 +13,8 @@ import java.util.List;
*/
public class SystemRule {
private static final String JB_VM_OPTIONS_FILE = "jb.vmOptionsFile";
private static List<FilterRule> hideEnvRules = Collections.emptyList();
private static List<FilterRule> hidePropertyRules = Collections.emptyList();
@@ -31,7 +34,7 @@ public class SystemRule {
}
public static boolean checkProperty(String name) {
if (checkHideProperty(name) && StackTraceRule.check()) {
if ((checkVMOptionsProperty(name) || checkHideProperty(name)) && StackTraceRule.check()) {
DebugInfo.output("======================Hide Property: " + name);
LogUtil.printStackTrace();
return true;
@@ -39,6 +42,14 @@ public class SystemRule {
return false;
}
public static String hookProperty(String name) {
if (checkVMOptionsProperty(name)) {
Path path = VMOptionsRule.hook();
return path == null ? null : path.toString();
}
return null;
}
private static boolean checkHideEnv(String name) {
return hideEnvRules.stream().anyMatch(rule -> rule.test(name));
}
@@ -46,4 +57,8 @@ public class SystemRule {
private static boolean checkHideProperty(String name) {
return hidePropertyRules.stream().anyMatch(rule -> rule.test(name));
}
private static boolean checkVMOptionsProperty(String name) {
return JB_VM_OPTIONS_FILE.equals(name);
}
}