jar

package
v1.4.4-alpha1202-diff-... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyzeJarSecurity

func AnalyzeJarSecurity(jarPath string) (map[string]interface{}, error)

AnalyzeJarSecurity performs a basic security analysis of a JAR file Looking for potential security issues or vulnerabilities

func DecompileAndFormat

func DecompileAndFormat(parser *JarParser, className string) (string, error)

DecompileAndFormat decompiles a class file and formats the source code

func GetJarDependencyTree

func GetJarDependencyTree(jarPath string) (map[string]interface{}, error)

GetJarDependencyTree analyzes dependencies between JAR files by examining MANIFEST.MF

func GetJavaVersion

func GetJavaVersion(parser *JarParser) (string, error)

GetJavaVersion attempts to determine the Java version used to compile the JAR

func ReadClassAsOriginalBytes

func ReadClassAsOriginalBytes(parser *JarParser, className string) ([]byte, error)

ReadClassAsOriginalBytes reads a class file from the JAR without decompiling it

Types

type JarParser

type JarParser struct {
	// contains filtered or unexported fields
}

JarParser is a utility for parsing and analyzing JAR files

func NewJarParser

func NewJarParser(jarPath string) (*JarParser, error)

NewJarParser creates a new JarParser for the specified JAR file path

func NewJarParserFromBytes

func NewJarParserFromBytes(jarContent []byte) (*JarParser, error)

NewJarParserFromBytes creates a new JarParser from JAR content in memory

func (*JarParser) DecompileClass

func (j *JarParser) DecompileClass(className string) ([]byte, error)

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

func (j *JarParser) ExportDecompiledJar() (*bytes.Buffer, error)

ExportDecompiledJar exports the JAR with all class files decompiled to .java files

func (*JarParser) FindClassByName

func (j *JarParser) FindClassByName(className string) (string, error)

FindClassByName searches for a class by its name (not path)

func (*JarParser) FindInnerClasses

func (j *JarParser) FindInnerClasses(outerClassPath string) ([]string, error)

FindInnerClasses finds all inner classes for a given outer class

func (*JarParser) FindJavaClasses

func (j *JarParser) FindJavaClasses(includeNestedJars ...bool) ([]string, error)

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

func (j *JarParser) GetDirectoryContents(dirPath string) ([]map[string]interface{}, error)

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

func (j *JarParser) GetJarManifest() (map[string]string, error)

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

func (j *JarParser) ListDirectory(dirPath string) ([]fs.DirEntry, error)

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

func (j *JarParser) ParseNestedJarPath(fullPath string) (string, string, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL