Class SecurityPolicy
java.lang.Object
com.ultikits.ultitools.utils.SecurityPolicy
Validates module JAR structure before a classloader consumes it.
The archive must be a readable regular JAR file within the 100 MB and 10,000-entry limits.
This is not a sandbox and does not constrain what loaded module code can do.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisSafeFileStructure(long fileSize, int entryCount) Validate file size and structure for security.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.
-
Field Details
-
LOGGER
-
-
Constructor Details
-
SecurityPolicy
public SecurityPolicy()
-
-
Method Details
-
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
-
logSecurityViolation
-