p2

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package p2 validates Eclipse p2 update-site paths and bounded metadata.

Index

Constants

View Source
const (
	MaxMetadata = 36 << 20
	MaxArtifact = 512 << 20
	MaxChildren = 64
	MaxDepth    = 5
	MaxChildURL = 2048
)

Variables

View Source
var ErrInvalid = errors.New("p2: invalid p2 repository content")

Functions

func ArtifactChecksums

func ArtifactChecksums(
	metadataName string,
	body []byte,
	artifactPath string,
) (types.Checksums, error)

ArtifactChecksums reads the checksums declared for a standard P2 artifact path. An absent declaration leaves the structural JAR validation in force. Invalid declarations fail closed instead of silently disabling pinning.

func EditComposite

func EditComposite(name string, body []byte, replace func(string) (string, error)) ([]byte, error)

EditComposite reads any supported composite metadata representation, calls replace for each child location, and returns its complete rewritten bytes. No original location reaches a client if one replacement fails.

func ExtractArchive

func ExtractArchive(site []byte, entry string) ([]byte, error)

ExtractArchive serves Artifactory's `site.zip!/` P2 URL form. The complete source archive is checked before its named update-site file is delivered.

func ValidChildLocation

func ValidChildLocation(raw string) bool

ValidChildLocation accepts repository-relative locations and absolute HTTP(S) locations. The server separately checks configured origin policy before any child is exposed. This syntax check also rejects encoded traversal.

func Validate

func Validate(name string, src io.ReadSeeker, size int64) error

Validate reads the complete representation before the source cache may publish it. zip readers check both directory structure and entry CRCs.

Types

type Kind

type Kind uint8

Kind classifies the small set of native p2 files. An update site may place these under an archive suffix (site.zip!/content.jar) or a site directory.

const (
	KindInvalid Kind = iota
	KindIndex
	KindMetadata
	KindArtifact
)

func Classify

func Classify(name string) Kind

Jump to

Keyboard shortcuts

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