Documentation
¶
Index ¶
- func AnalyzeJarSecurity(jarPath string) (map[string]interface{}, error)
- func DecompileAndFormat(parser *JarParser, className string) (string, error)
- func GetJarDependencyTree(jarPath string) (map[string]interface{}, error)
- func GetJavaVersion(parser *JarParser) (string, error)
- func ReadClassAsOriginalBytes(parser *JarParser, className string) ([]byte, error)
- type JarParser
- func (j *JarParser) DecompileClass(className string) ([]byte, error)
- func (j *JarParser) ExportDecompiledJar() (*bytes.Buffer, error)
- func (j *JarParser) FindClassByName(className string) (string, error)
- func (j *JarParser) FindInnerClasses(outerClassPath string) ([]string, error)
- func (j *JarParser) FindJavaClasses(includeNestedJars ...bool) ([]string, error)
- func (j *JarParser) GetDirectoryContents(dirPath string) ([]map[string]interface{}, error)
- func (j *JarParser) GetJarFS() *javaclassparser.FS
- func (j *JarParser) GetJarManifest() (map[string]string, error)
- func (j *JarParser) GetNestedJarFS(nestedJarPath string) (*javaclassparser.FS, error)
- func (j *JarParser) ListDirectory(dirPath string) ([]fs.DirEntry, error)
- func (j *JarParser) ParseNestedJarPath(fullPath string) (string, string, error)deprecated
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnalyzeJarSecurity ¶
AnalyzeJarSecurity performs a basic security analysis of a JAR file Looking for potential security issues or vulnerabilities
func DecompileAndFormat ¶
DecompileAndFormat decompiles a class file and formats the source code
func GetJarDependencyTree ¶
GetJarDependencyTree analyzes dependencies between JAR files by examining MANIFEST.MF
func GetJavaVersion ¶
GetJavaVersion attempts to determine the Java version used to compile the JAR
Types ¶
type JarParser ¶
type JarParser struct {
// contains filtered or unexported fields
}
JarParser is a utility for parsing and analyzing JAR files
func NewJarParser ¶
NewJarParser creates a new JarParser for the specified JAR file path
func NewJarParserFromBytes ¶
NewJarParserFromBytes creates a new JarParser from JAR content in memory
func (*JarParser) DecompileClass ¶
DecompileClass reads and decompiles a Java class file from the JAR Handles nested JAR paths like "lib/fastjson.jar/com/example/Main.class" or "lib/outer.jar/libs/inner.jar/com/example/Main.class"
func (*JarParser) ExportDecompiledJar ¶
ExportDecompiledJar exports the JAR with all class files decompiled to .java files
func (*JarParser) FindClassByName ¶
FindClassByName searches for a class by its name (not path)
func (*JarParser) FindInnerClasses ¶
FindInnerClasses finds all inner classes for a given outer class
func (*JarParser) FindJavaClasses ¶
FindJavaClasses finds all Java class files in the JAR recursively If includeNestedJars is true, it will also look inside JARs within the JAR, including multiple levels of nesting (jar inside jar inside jar)
func (*JarParser) GetDirectoryContents ¶
GetDirectoryContents returns information about all entries in a directory Also supports nested JAR paths like "lib/fastjson.jar/com/example"
func (*JarParser) GetJarFS ¶
func (j *JarParser) GetJarFS() *javaclassparser.FS
GetJarFS returns the underlying filesystem for the JAR
func (*JarParser) GetJarManifest ¶
GetJarManifest retrieves the manifest information from the JAR
func (*JarParser) GetNestedJarFS ¶
func (j *JarParser) GetNestedJarFS(nestedJarPath string) (*javaclassparser.FS, error)
GetNestedJarFS handles the case of a JAR file within the JAR Deprecated: This is a simple version that only handles a single level of nesting. For multi-level nested JARs, the ListDirectory and DecompileClass methods now automatically handle multiple levels of nesting.
func (*JarParser) ListDirectory ¶
ListDirectory lists the contents of a directory within the JAR Handles nested JAR paths like "lib/fastjson.jar/com/example" or "lib/outer.jar/libs/inner.jar/com/example"
func (*JarParser) ParseNestedJarPath
deprecated
ParseNestedJarPath parses a path that may contain nested JAR files Returns the physical jar path, the internal path within the jar, and any error
Deprecated: For paths with multiple nested JARs, use parseMultiLevelJarPath instead. This method only handles a single level of nesting.
Example: "lib/sample.jar/com/example/Main.class" returns "lib/sample.jar", "com/example/Main.class", nil But "lib/outer.jar/libs/inner.jar/class.class" returns "lib/outer.jar", "libs/inner.jar/class.class", nil which treats everything after the first .jar/ as a single path