archive

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package archive extracts Java archive files.

Index

Constants

View Source
const (
	// Name is the unique name of this extractor.
	Name = "java/archive"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// MaxZipDepth is the maximum number of inner zip files within an archive the extractor will unzip.
	// Once reached, no more inner zip files will be explored during extraction.
	MaxZipDepth int
	// MaxOpenedBytes is the maximum number of bytes recursively read from an archive file.
	// If this limit is reached, extraction is halted and results so far are returned.
	MaxOpenedBytes int64
	// MinZipBytes is use to ignore empty zip files during extraction.
	// Zip files smaller than minZipBytes are ignored.
	MinZipBytes int
	// ExtractFromFilename configures if JAR files should be extracted from filenames when no "pom.properties" is present.
	ExtractFromFilename bool
	// HashJars configures if JAR files should be hashed with base64(sha1()), which can be used in deps.dev.
	HashJars bool
}

Config is the configuration for the Extractor.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration for the Java archive extractor.

type Extractor

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

Extractor extracts Java packages from archive files.

func New

func New(cfg Config) *Extractor

New returns a Java archive extractor.

For most use cases, initialize with: ``` e := New(DefaultConfig()) ```

func (Extractor) Extract

func (e Extractor) Extract(ctx context.Context, input *extractor.ScanInput) ([]*extractor.Inventory, error)

Extract extracts java packages from archive files passed through input.

func (Extractor) FileRequired

func (e Extractor) FileRequired(path string, _ fs.FileMode) bool

FileRequired returns true if the specified file matches java archive file patterns.

func (Extractor) Name

func (e Extractor) Name() string

Name of the extractor.

func (Extractor) ToCPEs

func (e Extractor) ToCPEs(i *extractor.Inventory) ([]string, error)

ToCPEs is not applicable as this extractor does not infer CPEs from the Inventory.

func (Extractor) ToPURL

func (e Extractor) ToPURL(i *extractor.Inventory) (*purl.PackageURL, error)

ToPURL converts an inventory created by this extractor into a PURL.

func (Extractor) Version

func (e Extractor) Version() int

Version of the extractor.

type JarProps

type JarProps struct {
	ArtifactID string
	Version    string
	GroupID    string
}

JarProps stores the name, version, and group ID of a Java archive.

func ParseFilename

func ParseFilename(filePath string) *JarProps

ParseFilename attempts to figure out the package name, version, and group ID of a Java archive based on its filename. Returns nil if parsing was unsuccessful.

type Metadata

type Metadata struct {
	ArtifactID string
	GroupID    string
	SHA1       string
}

Metadata holds parsing information for a Java archive package.

type PomProps

type PomProps struct {
	GroupID    string
	ArtifactID string
	Version    string
}

PomProps for identifying Maven package.

Jump to

Keyboard shortcuts

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