Documentation
¶
Index ¶
- Variables
- func CanonicalPath(pathToFile string) (string, error)
- func CleanArchiveEntryPath(entryPath string) (string, error)
- func CompareSemver(leftVersion string, rightVersion string) (int, error)
- func FNV32a(s string) uint32
- func HasWindowsReservedBase(pathPart string) bool
- func IsCanonicalSemver(version string) bool
- func IsHistoricalVersion(version string, prefix string) bool
- func IsInsideOrEqual(parentPath string, childPath string) (bool, error)
- func IsRawVersionName(version string) bool
- func IsStorableRawVersion(name string) bool
- func IsStorableSemver(version string) bool
- func IsStorableSemverPrerelease(version string) bool
- func JoinInside(basePath string, pathParts ...string) (string, error)
- func PathsOverlap(leftPath string, rightPath string) (bool, error)
- func SymlinkTargetWithinRoot(symlinkPath string, target string) error
- func ValidateArchiveEntryPath(entryPath string, maxBytes uint) error
- type GenMapObj
Constants ¶
This section is empty.
Variables ¶
var ErrArchiveEntryPathTooLong = errors.New("archive entry path exceeds maximum length")
ErrArchiveEntryPathTooLong distinguishes exceeding the path-length limit from other path errors.
Functions ¶
func CanonicalPath ¶
CanonicalPath converts a path to abs+clean and resolves symlinks when possible.
func CleanArchiveEntryPath ¶
CleanArchiveEntryPath normalizes an archive entry path and rejects traversal/absolute variants.
func CompareSemver ¶
CompareSemver compares semver versions after canonicalizing mixed bare and v-prefixed forms.
func FNV32a ¶ added in v0.4.0
FNV32a returns the 32-bit FNV-1a hash of s, used for cheap map sharding.
func HasWindowsReservedBase ¶
HasWindowsReservedBase checks a segment for a Windows device name.
func IsCanonicalSemver ¶
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 ¶
IsHistoricalVersion recognizes historical copies named v0.0.0-<prefix><N>, where N is a non-empty decimal suffix.
func IsInsideOrEqual ¶
IsInsideOrEqual checks that childPath equals parentPath or lies inside it.
func IsRawVersionName ¶
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 ¶
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 ¶
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 ¶
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 ¶
JoinInside builds a path inside basePath and rejects escapes after canonicalization.
func PathsOverlap ¶
PathsOverlap checks for path nesting in either direction or equality.
func SymlinkTargetWithinRoot ¶
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 ¶
ValidateArchiveEntryPath checks the length and safety of an archive entry path.
Types ¶
type GenMapObj ¶ added in v0.4.0
type GenMapObj[V any] struct { // contains filtered or unexported fields }
GenMapObj is a two-generation string-keyed map: hits promote entries from the previous generation, and the whole current generation rotates out once it reaches cap. The effective ceiling is about 2*cap entries without per-entry eviction bookkeeping. It is not safe for concurrent use; callers hold their own locks.
func NewGenMap ¶ added in v0.4.0
NewGenMap builds a map with the given per-generation capacity (minimum 1).