util

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: LGPL-2.1 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrArchiveEntryPathTooLong = errors.New("archive entry path exceeds maximum length")

ErrArchiveEntryPathTooLong distinguishes exceeding the path-length limit from other path errors.

Functions

func CanonicalPath

func CanonicalPath(pathToFile string) (string, error)

CanonicalPath converts a path to abs+clean and resolves symlinks when possible.

func CleanArchiveEntryPath

func CleanArchiveEntryPath(entryPath string) (string, error)

CleanArchiveEntryPath normalizes an archive entry path and rejects traversal/absolute variants.

func CompareSemver

func CompareSemver(leftVersion string, rightVersion string) (int, error)

CompareSemver compares semver versions after canonicalizing mixed bare and v-prefixed forms.

func HasWindowsReservedBase

func HasWindowsReservedBase(pathPart string) bool

HasWindowsReservedBase checks a segment for a Windows device name.

func IsCanonicalSemver

func IsCanonicalSemver(version string) bool

IsCanonicalSemver reports whether a version is already in canonical Go semver form with a leading 'v'. This gates Go serving because go-proxy accepts only canonical 'vX.Y.Z'.

func IsHistoricalVersion

func IsHistoricalVersion(version string, prefix string) bool

IsHistoricalVersion recognizes historical copies named v0.0.0-<prefix><N>, where N is a non-empty decimal suffix.

func IsInsideOrEqual

func IsInsideOrEqual(parentPath string, childPath string) (bool, error)

IsInsideOrEqual checks that childPath equals parentPath or lies inside it.

func IsRawVersionName

func IsRawVersionName(version string) bool

IsRawVersionName classifies already-stored names; after publication validation, non-semver means raw. Detection evidence is informational only, while the version name is authoritative.

func IsStorableRawVersion

func IsStorableRawVersion(name string) bool

IsStorableRawVersion reports whether a non-semver version name is safe to store and serve. Raw versions are universal-only: strict ASCII charset, bounded length, alnum edges, and no collision with route grammar (artifact suffixes, reserved segments, go major segments). Storable semver names are excluded on purpose: they follow the regular semver path.

func IsStorableSemver

func IsStorableSemver(version string) bool

IsStorableSemver reports whether a version is safe to store: strict semver with or without leading 'v', stored verbatim. Branch/dev forms, spaces/control chars, and build metadata are rejected to keep ordering unambiguous.

func IsStorableSemverPrerelease

func IsStorableSemverPrerelease(version string) bool

IsStorableSemverPrerelease reports whether a version is storable semver with a prerelease suffix. Tag listings have no prerelease flag, so tag mode drops such tags for parity with release mode.

func JoinInside

func JoinInside(basePath string, pathParts ...string) (string, error)

JoinInside builds a path inside basePath and rejects escapes after canonicalization.

func PathsOverlap

func PathsOverlap(leftPath string, rightPath string) (bool, error)

PathsOverlap checks for path nesting in either direction or equality.

func SymlinkTargetWithinRoot

func SymlinkTargetWithinRoot(symlinkPath string, target string) error

SymlinkTargetWithinRoot validates a symlink target interpreted relative to the symlink's own directory. Unlike an entry path, a target legitimately MAY contain ".." (e.g. "../LICENSE"); it is unsafe only when it is absolute or, once resolved against symlinkPath's parent, climbs above the archive root.

func ValidateArchiveEntryPath

func ValidateArchiveEntryPath(entryPath string, maxBytes uint) error

ValidateArchiveEntryPath checks the length and safety of an archive entry path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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