Skip to main content

Module validation

Module validation 

Source
Expand description

Shape guards for untrusted strings that ride in URL path segments against the pakx-registry backend.

The registry’s RFC 3986 minimal percent-encoder (urlencoding_minimal in the registry client + commands/info.rs) leaves . in the unreserved set per the spec — which means a string of literally .. produces a URL with a literal .. segment that a normalizing reverse proxy (CDN, ALB, nginx with merge_slashes off) collapses upward, silently re-routing the call to the wrong endpoint. The encoder is doing the right thing; we need a separate shape guard on every input that lands inside a URL path segment before encoding.

Two guards live here:

  • validate_package_name — for <name> segments (and reused via the registry client’s own copy of the same logic).
  • validate_version — for <version> segments. Stricter than the name guard because semver versions have a well-defined character set ([a-zA-Z0-9._+-]{1,64} covers exact pins, build metadata, and pre-release tags).

Both share the same error type so callers can route either through a single match arm in the CLI’s error rendering.

Structs§

ValidationError
Shape-guard failure for a string destined for a URL path segment.

Constants§

MAX_VERSION_LEN
Maximum number of characters in a validated version segment.

Functions§

validate_package_name
Reject hostile package names before they reach the URL builder.
validate_version
Reject hostile version pins before they reach the URL builder.