Package com.ultikits.ultitools.utils
Class SecurityPolicy
java.lang.Object
com.ultikits.ultitools.utils.SecurityPolicy
Provides NO runtime constraint on class loading or reflection (GEN-07, D-12, since 6.3.0).
isSafeClassName(String) and isSafeParameterType(Class) now unconditionally
return true; addTrustedPackage(String) and addDangerousClass(String)
are no-ops. The three name-based filter layers this class used to enforce never protected
anything: they evaluated already-trusted, already-loaded classes on the framework's own
classpath, not arbitrary untrusted input, and the trusted-package whitelist alone would have
refused nearly every third-party module class (TRUSTED_PACKAGE_PREFIXES held no
third-party package). See the package-private ClassloadFilterAudit (D-14) for what
these removed layers would have refused, recorded as telemetry rather than enforced.
This class still performs plugin-scan-time JAR STRUCTURE filtering only:
isSafeFileStructure(long, int) and isValidModuleJar(File) are unchanged and
remain the framework's one genuine defense against a zip-bomb or oversized module JAR
(ROADMAP criterion 4).
- Version:
- 1.0.0
- Author:
- UltiKits Security Team
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final AtomicBooleanFires the D-13 deprecation warning below at most once per JVM.private static final Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddDangerousClass(String className) Deprecated.static voidaddTrustedPackage(String packagePrefix) Deprecated.Since 6.3.0 (GEN-07): this method no longer mutatesClassloadFilterAudit.TRUSTED_PACKAGE_PREFIXESor anything else.static StringGet current security policy information.static booleanisSafeClassName(String className) Deprecated.Since 6.3.0 (GEN-07) this method is an unconditional no-op -- the three name-based classload filter layers it enforced never protected anything (they evaluated already-trusted, already-loaded classes, not arbitrary untrusted input), and the trusted-package whitelist alone would have refused nearly every third-party module class.static booleanisSafeFileStructure(long fileSize, int entryCount) Validate file size and structure for security.static booleanisSafeParameterType(Class<?> clazz) Deprecated.Since 6.3.0 (GEN-07), for the same reason asisSafeClassName(String)-- its only in-tree caller (the seven-argumentPluginManager.register/with-args reflective-construction path) was deleted by GEN-04, which is what dissolved this method's former "shared-field, can't safely delete the whitelist" objection.static booleanisValidModuleJar(File jarFile) Validate that a module JAR is safe to hand to a classloader: it must exist, be a regular file, have a.jarsuffix (case-insensitive), open as a readable archive, and pass the size/entry-count limits enforced byisSafeFileStructure(long, int).private static voidlogSecurityViolation(String reason, String details) Log security violation for monitoring and audit purposes.private static void
-
Field Details
-
LOGGER
-
DEPRECATION_WARNING_LOGGED
Fires the D-13 deprecation warning below at most once per JVM. Guards against the measured call volume: isSafeClassName was reached from two PluginManager scan loops, each capped at 1000 classes per JAR -- up to 2000 calls per module JAR, roughly 28,000 per startup with fourteen modules. A naive per-call warning would flood startup.
-
-
Constructor Details
-
SecurityPolicy
public SecurityPolicy()
-
-
Method Details
-
warnDeprecatedNoOp
private static void warnDeprecatedNoOp() -
isSafeClassName
Deprecated.Since 6.3.0 (GEN-07) this method is an unconditional no-op -- the three name-based classload filter layers it enforced never protected anything (they evaluated already-trusted, already-loaded classes, not arbitrary untrusted input), and the trusted-package whitelist alone would have refused nearly every third-party module class. The signature is retained because it ispublic staticon a published class and cannot be removed without breaking a downstream caller's compile. See the package-privateClassloadFilterAuditfor what these removed layers would have refused, now recorded as telemetry.Formerly validated whether a class name was safe to load; unconditionally returnstruenow, including for anullor blank input (GEN-07 empty-input edge -- this differs from the pre-6.3.0 behavior, which returnedfalsefor both).- Parameters:
className- class name to validate, ignored- Returns:
true, unconditionally
-
isSafeParameterType
Deprecated.Since 6.3.0 (GEN-07), for the same reason asisSafeClassName(String)-- its only in-tree caller (the seven-argumentPluginManager.register/with-args reflective-construction path) was deleted by GEN-04, which is what dissolved this method's former "shared-field, can't safely delete the whitelist" objection.Formerly validated whether a parameter type was safe for reflection operations; unconditionally returnstruenow, including for anullinput (GEN-07 empty-input edge -- this differs from the pre-6.3.0 behavior, which returnedfalse).- Parameters:
clazz- parameter class, ignored- Returns:
true, unconditionally
-
isSafeFileStructure
public static boolean isSafeFileStructure(long fileSize, int entryCount) Validate file size and structure for security.- Parameters:
fileSize- file size in bytesentryCount- number of entries in archive- Returns:
- true if safe, false otherwise
-
isValidModuleJar
Validate that a module JAR is safe to hand to a classloader: it must exist, be a regular file, have a.jarsuffix (case-insensitive), open as a readable archive, and pass the size/entry-count limits enforced byisSafeFileStructure(long, int).This is a static, instance-free rule with no dependency on Bukkit — it must be callable before the plugin's
onEnable()has built any manager, and from a plain JUnit test with no server running. Callers are responsible for skipping (not adding) a JAR this method rejects; this method never throws for a JAR it judges unsafe, it only returnsfalse.- Parameters:
jarFile- candidate module jar file- Returns:
- true if the jar may be handed to a classloader, false otherwise
- Since:
- 6.3.0
-
addTrustedPackage
Deprecated.Since 6.3.0 (GEN-07): this method no longer mutatesClassloadFilterAudit.TRUSTED_PACKAGE_PREFIXESor anything else. The signature is retained because it ispublic staticon a published class.Formerly added a trusted package prefix at runtime; now a no-op that does not mutate anything (GEN-07, D-12) --ClassloadFilterAudit.TRUSTED_PACKAGE_PREFIXESreflects exactly the shipped list, never a caller's runtime addition, so the audit measures the framework as released.- Parameters:
packagePrefix- package prefix, ignored
-
addDangerousClass
Deprecated.Since 6.3.0 (GEN-07): this method no longer mutatesClassloadFilterAudit.SYSTEM_DANGEROUS_CLASSESor anything else. The signature is retained because it ispublic staticon a published class.Formerly added a class to the dangerous-class blacklist at runtime; now a no-op that does not mutate anything (GEN-07, D-12) --ClassloadFilterAudit.SYSTEM_DANGEROUS_CLASSESreflects exactly the shipped list, never a caller's runtime addition.- Parameters:
className- class name, ignored
-
logSecurityViolation
Log security violation for monitoring and audit purposes.- Parameters:
reason- violation reasondetails- violation details
-
getSecurityPolicySummary
Get current security policy information.- Returns:
- security policy summary
-
ClassloadFilterAudit.SYSTEM_DANGEROUS_CLASSESor anything else.