Documentation
¶
Overview ¶
Package cocoapods is the format of CocoaPods repositories: the pod archive and its podspec, the names and paths of the CocoaPods CDN, and the package index. A hosted pod version is one archive at <name>/<version>/<name>-<version>.tar.gz whose one root podspec (JSON, or static Ruby read as data) names that pod and version; the CDN shards a pod's specs and version list by the MD5 of its name.
Role ¶
artifacts module, ecosystem layer: the format rules of the CocoaPods slice (package type cocoapods). Its Handler plugs into the item service through the format hooks (decision 0032), so every write and delete in a CocoaPods repository reaches it whichever API carried it. The slice's protocol package, cocoapods/http, serves the CDN with the names, paths and podspecs checked here. Its Git fetching builds a Git-sourced pod's archive for core remote's shared retrieval and cache policy, which this package imports and which reaches it only through the Policy.GitFetch hook (decision 0044).
Inputs ¶
- Driving: the format registry (artifacts/ecosystem), which hands the item service's hooks for CocoaPods repositories to Handler; the protocol package (cocoapods/http), which builds and parses CDN and archive paths and reads the podspec an archive was indexed with (Archive); and the remote policy (core remote), which checks an HTTP-sourced pod's archive before caching it (ValidateSourceArchive) and hands a Git-sourced pod's request, with its Git descriptor (source.CocoaPodsGitSource), to FetchCocoaPodsGit through Policy.GitFetch.
- Driven: the format hooks' environment (format.Env), through which Handler opens stored archives and keeps the package index; and the remote.Policy that FetchCocoaPodsGit is given: its pooled upstream client, its current-authority check (CheckCurrent) and the repository's allowed origins (externalDependenciesPatterns).
Outputs ¶
- Names and paths: ValidName, ValidVersion, Path, ParsePath, Shard, ShardFile and SpecPath.
- Archives: ReadArchive, which returns the Archive of a valid hosted pod archive, MaxArchiveBytes, and ValidateSourceArchive for a remote pod's source archive (zip or tar.gz).
- Handler: the hooks that inspect and admit a deployed archive, index its version with the Archive as metadata, and rebuild the index from the stored archives (Reindex).
- FetchCocoaPodsGit: the deterministic tar.gz of a Git-sourced pod's revision and its pinned submodules, answered as an upstream response.
Invariants ¶
- An archive is admitted only when every tar header and path, the gzip trailer and its one root podspec are valid and the podspec names the archive's pod and version, so a corrupt or path-escaping archive never becomes a resolvable version.
- A Ruby podspec is parsed as data and never executed; a statement outside the static grammar fails the upload.
- CDN metadata under .pod/cdn/ is generated, so a deploy there is refused with 409.
- FetchCocoaPodsGit never launches Git or writes a worktree: it reads objects in memory over smart HTTP(S), and validates object IDs, pack and delta expansion limits and archive members before the one archive it builds enters the cache. The repository's credentials are never sent to another Git origin, a submodule's included.
- Refusal texts are answered to clients in the response body, so they stay byte-identical.
References ¶
- Decision 0032: docs/research/decisions/0032-package-format-handlers.md (format hooks and optional interfaces; CocoaPods Git sources, #771).
- Decision 0044: docs/research/decisions/0044-modular-monolith-migration.md, "Artifacts and remote" (the GitFetch hook).
- docs/testing/cocoapods.md (the CDN client, Git sources and static Ruby podspecs).
- JFrog CocoaPods repositories and the repository class table, as that page cites them: https://docs.jfrog.com/artifactory/docs/cocoapods-repositories and https://docs.jfrog.com/artifactory/docs/repository-support-for-package-clients.
- Target layout: docs/research/architecture-options/5-modular-monolith.md, line 233 (ecosystem/cocoapods), line 379 (one slice per package type) and line 997 (the mapping row).
- Plan: docs/implementation/plan.md#p31-native-build-and-plugin-repositories and #p9d-modular-monolith-migration, epic ECO (https://github.com/weaveplatform/artifactweave/issues/943).
- https://github.com/weaveplatform/artifactweave/issues/771, https://github.com/weaveplatform/artifactweave/issues/1016 and https://github.com/weaveplatform/artifactweave/issues/1017
Status ¶
Implemented P9c, which delivered the plan's P31 group (issues #770 to #775). Moved here in P9d.
Testing ¶
- archive_test.go and archive_security_test.go: archive identity and integrity, hidden PAX expansion, truncated members and the source archive bounds, zip compression and cancellation.
- ruby_spec_test.go: the static Ruby podspec grammar and its refusals.
- handler_test.go and handler_lifecycle_test.go: admission against the stored archive, a cached HTTP source outside the hosted grammar, and reindexing.
- remote_git_test.go, remote_git_pack_test.go, remote_git_failure_test.go, remote_git_limits_test.go and remote_git_authority_test.go: revisions, tree and module safety, the pack reader, invalid object graphs, upstream failures, resource limits, credential isolation and revocation during a submodule fetch, against fake Git upstreams, some serving the packs in test/fixtures/cocoapods-git; remote_fixture_test.go holds the remote policy fixture they share with nothing else.
Index ¶
- Constants
- func FetchCocoaPodsGit(ctx context.Context, p *remote.Policy, q source.Request, permit source.Permit, ...) (*http.Response, error)
- func ParsePath(p string) (name, version string, ok bool)
- func Path(name, version string) string
- func Serves(t repo.PackageType) bool
- func Shard(name string) string
- func ShardFile(name string) string
- func SpecPath(name, version string) string
- func ValidName(v string) bool
- func ValidVersion(v string) bool
- func ValidateSourceArchive(ctx context.Context, body io.ReadSeeker, size int64, ext string) error
- type Archive
- type Handler
- func (Handler) Admit(ctx context.Context, env format.Env, c repo.Config, w format.Write) (format.Write, error)
- func (Handler) Deleted(context.Context, format.Env, repo.Config, []model.Item) error
- func (Handler) Deleting(context.Context, format.Env, repo.Config, model.Item) error
- func (Handler) Deployed(ctx context.Context, env format.Env, c repo.Config, it model.Item) error
- func (Handler) Inspect(ctx context.Context, env format.Env, _ repo.Config, w format.Write) (any, error)
- func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error
Constants ¶
const ( // MaxArchiveBytes bounds every pod archive at 64 MiB of compressed // bytes: a hosted archive, an HTTP source archive and the archive a Git // source is fetched into. A larger one is refused before it is read. MaxArchiveBytes = 64 << 20 )
Variables ¶
This section is empty.
Functions ¶
func FetchCocoaPodsGit ¶
func FetchCocoaPodsGit( ctx context.Context, p *remote.Policy, q source.Request, permit source.Permit, opts remote.Options, ) (*http.Response, error)
FetchCocoaPodsGit answers a remote CocoaPods read whose pod source is Git (q.Resource.CocoaPodsGit): it fetches the revision the descriptor names, and with Submodules each pinned submodule, over smart HTTP(S) through p's pooled client for q.Repo, and returns a 200 response whose body is the deterministic tar.gz of that tree, which the policy validates and caches as it does an HTTP source archive. The application installs it as remote.Policy.GitFetch.
It keeps Git transport behind the same source policy as HTTP archives: every exchange passes p.CheckCurrent and the repository's allowed origins first. Only the final validated tar is published; no Git checkout or attacker-controlled filesystem/configuration is ever executed. The fetch has a two-minute deadline and the pack, object, repository and archive limits of docs/testing/cocoapods.md.
It returns source.ErrUnsupported for a repository that is not a CocoaPods one, a request without a Git descriptor, a policy without a pool or a permit that allows no upstream network; source.ErrInvalidRequest for a descriptor that fails Validate; source.ErrInvalidResult for refs, packs, objects or trees outside those rules, and for a tree with no file; and the policy's and the client's errors unwrapped (source.ErrDenied, a *source.HTTPError), so the source service classifies them as it does for any upstream read.
func ParsePath ¶
ParsePath returns the pod name and version of a hosted archive path; ok is false unless p is exactly Path(name, version) for a valid name and version.
func Path ¶
Path is the repository path of a hosted pod archive, <name>/<version>/<name>-<version>.tar.gz: the only path a deployed archive may take, and the one ParsePath accepts.
func Serves ¶
func Serves(t repo.PackageType) bool
Serves reports whether t is the CocoaPods package type.
func Shard ¶
Shard is the CDN shard of a pod name, a/b/c for the first three hex digits of the MD5 of the name, which is how the CocoaPods CDN spreads specs and version lists (prefix lengths 1, 1 and 1 in CocoaPods-version.yml). MD5 only selects a path here; it proves nothing about content.
func ShardFile ¶
ShardFile is the name of the CDN version list that holds the pod name: all_pods_versions_a_b_c.txt for the shard a/b/c.
func SpecPath ¶
SpecPath is the CDN path of a pod version's podspec: Specs/<shard>/<name>/<version>/<name>.podspec.json.
func ValidName ¶
ValidName reports whether v can be a pod name: at most 128 bytes of valid UTF-8 with no leading or trailing space, neither . nor .., and no slash, backslash, ?, # or control character. CocoaPods' public CDN includes names with punctuation, spaces and Unicode, and the protocol treats a pod name as one path segment, so only what would break that segment is refused rather than a narrower invented grammar.
func ValidVersion ¶
ValidVersion reports whether v can be a pod version: at most 128 bytes that start with a digit and hold only letters, digits, '.', '+' and '-'.
func ValidateSourceArchive ¶
ValidateSourceArchive checks an HTTP-sourced pod's complete archive before remote cache publication. Its podspec comes from the CDN, not this archive.
Types ¶
type Archive ¶
type Archive struct {
Name string `json:"name"`
Version string `json:"version"`
Spec json.RawMessage `json:"spec"`
SHA256 string `json:"sha256"`
}
Archive is what ReadArchive learns from a valid hosted pod archive: the pod's name and version and its root podspec as JSON (a static Ruby podspec is converted). Handler adds the stored archive's SHA-256 and keeps it as the version's metadata in the package index, from which the protocol builds the CDN podspec, so its JSON field names are persisted.
func ReadArchive ¶
ReadArchive accepts an actual CocoaPods tar.gz and one JSON podspec at its root. It reads every header and compressed trailer before the version may be indexed. This prevents a corrupt or path-escaping archive from becoming a resolvable package through an otherwise valid podspec.
type Handler ¶
Handler is the format of CocoaPods repositories, which the item service calls on every write and delete in them, whichever API carried it. It admits a hosted pod archive only once it has read it whole, and keeps the package index: a pod is a package, and each archive's version is a version with the Archive as its metadata. The embedded generic format applies every package type's deploy policy.
func (Handler) Admit ¶
func (Handler) Admit( ctx context.Context, env format.Env, c repo.Config, w format.Write, ) (format.Write, error)
Admit applies the generic deploy policy, then refuses a write under the generated CDN metadata (.pod/cdn/, 409), a .tar.gz outside the hosted path grammar (400) and an archive that does not read as the pod and version of its path (400). Checksum uploads and remote cache writes pass after the generic checks: an HTTP source archive has its own validator and is not a hosted archive.
func (Handler) Deleted ¶
Deleted does nothing: a version is one archive, so the item service's pruning of versions left without files is all a delete needs.
func (Handler) Deleting ¶
Deleting does nothing: the item service drops a removed archive's version link with it.
func (Handler) Deployed ¶
Deployed indexes a stored hosted archive's version under its pod, with the Archive and the archive's SHA-256 as the version's metadata. Folders, cached items and other paths are not indexed.
func (Handler) Inspect ¶
func (Handler) Inspect( ctx context.Context, env format.Env, _ repo.Config, w format.Write, ) (any, error)
Inspect reads a deployed hosted archive before the write's transaction, so Admit decides without parsing under the write lock. It answers nil for a write that is not to a hosted archive path or has no SHA-256, and an error only when the stored content cannot be opened; an archive that fails ReadArchive is handed to Admit to refuse.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cocoapodshttp serves the current CocoaPods CDN protocol through /artifactory/api/pods/{repoKey}: the version document, the pod list, the sharded version lists and the podspecs that pod repo add-cdn and pod install read, and the archives those podspecs point at.
|
Package cocoapodshttp serves the current CocoaPods CDN protocol through /artifactory/api/pods/{repoKey}: the version document, the pod list, the sharded version lists and the podspecs that pod repo add-cdn and pod install read, and the archives those podspecs point at. |