Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,8 @@ A CRAN version is mirrored as its source package from `upstream.cran`, for examp

An Alpine package is mirrored from the repository in `upstream.apk` named as the namespace, `alpine` by default, as syft writes it in image SBOMs: `pkg:apk/alpine/busybox@1.36.1-r29?arch=x86_64&distro=alpine-3.20.3`. The `distro` qualifier gives the release (`v3.20`) and `arch` the architecture; packages without either are refused. Edge isn't mirrored: a `distro` with a pre-release suffix, such as `alpine-3.21.0_alpha20240807`, is refused, but an edge system that reports a plain release number can't be told apart and is mirrored from that release. The package is looked up in the `main` and then the `community` `APKINDEX.tar.gz` of that release and cached under the path `/apk/{repository}/{release}/{repo}/{arch}/{file}` serves it from. The file isn't checked by the proxy, as when serving, since the index checksum covers only the package's control section; apk checks it on install. The indexes aren't mirrored, so `apk add` needs the upstream or an index the proxy already cached. Give a version: Alpine repositories keep only the current one.

A Debian package is mirrored from the archive the namespace names: the one in `upstream.debian_repositories` by that name, or else `upstream.debian` for `debian` or no namespace, as syft and trivy write it in image SBOMs: `pkg:deb/debian/curl@7.88.1-10+deb12u8?arch=amd64&distro=debian-12`. The `distro` qualifier gives the release, as `debian-12`, a point release such as `debian-12.4`, `ubuntu-22.04` or a codename such as `bookworm`, and `arch` the architecture; packages without either are refused. The package is looked up in the release's suites the archive serves, of `{codename}`, `{codename}-updates` and `{codename}-security`, through the `Packages` indexes of the components their `Release` lists, such as `stable` in Docker's apt repository, which are checked against the `Release`. A suite whose `Release` lists none is read for `main`, `contrib`, `non-free`, `non-free-firmware`, `restricted`, `universe` and `multiverse`. Debian keeps `{codename}-security` in an archive of its own, `deb.debian.org/debian-security`, which can be added to `upstream.debian_repositories` and named in the namespace. An epoch is matched from the version (`1:9.2p1-2+deb12u3`) or the `epoch` qualifier; without one, a version listed with two epochs is refused. The file is checked against the index's SHA256 and cached under the path `/debian/` serves it from, so apt gets it with the upstream down. The indexes aren't mirrored. Give a version: an archive keeps only the current one of each suite.

| Flag | Default | Description |
|------|---------|-------------|
| `--sbom` | | Path to CycloneDX or SPDX SBOM file |
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/git-pkgs/integrity v0.2.0
github.com/git-pkgs/magic v0.6.0
github.com/git-pkgs/purl v0.2.1
github.com/git-pkgs/registries v0.13.2
github.com/git-pkgs/registries v0.14.0
github.com/git-pkgs/sbom v0.1.9
github.com/git-pkgs/spdx v0.3.6
github.com/git-pkgs/vers v0.7.2
Expand Down Expand Up @@ -75,7 +75,7 @@ require (
github.com/dustin/go-humanize v1.1.0 // indirect
github.com/ecosyste-ms/ecosystems-go v0.5.0 // indirect
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
github.com/git-pkgs/pom v0.1.8 // indirect
github.com/git-pkgs/pom v0.1.9 // indirect
github.com/git-pkgs/vulns v0.2.4 // indirect
github.com/github/go-spdx/v2 v2.8.0 // indirect
github.com/go-logr/logr v1.4.4 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ github.com/git-pkgs/integrity v0.2.0 h1:sxpAk7EUllZnTYttOoPTW/Yfe5J2imglpuJiuBUZ
github.com/git-pkgs/integrity v0.2.0/go.mod h1:vPLb2RB+hR/iCMIgqph0PZbQ7iktXDTK+uupoHQikKk=
github.com/git-pkgs/magic v0.6.0 h1:fINPe67FEIaFRVlZzhOIDClMkm+gftBroBENa8bHSxQ=
github.com/git-pkgs/magic v0.6.0/go.mod h1:SXOqcsNmbmpZjJZHEEWnwxprbsFvpwWgTAZrgXp4Jm4=
github.com/git-pkgs/pom v0.1.8 h1:mXCuWw6XkrKKZb6IurRZyIznYLPhV5AYg5ZO38Uj/l8=
github.com/git-pkgs/pom v0.1.8/go.mod h1:sQBeYRzjCUn77fcABPn6I/a1aBHFxm55jTmkNxYtGtw=
github.com/git-pkgs/pom v0.1.9 h1:gP7nqAS+UXITeRXjHhpyrMHRl9K3sRRBzRLV3+TeqHU=
github.com/git-pkgs/pom v0.1.9/go.mod h1:sQBeYRzjCUn77fcABPn6I/a1aBHFxm55jTmkNxYtGtw=
github.com/git-pkgs/purl v0.2.1 h1:b46hRlOMbrG6aXjjFJdYixGi5WTh0TLlAnH9iNeuOS0=
github.com/git-pkgs/purl v0.2.1/go.mod h1:l8rCfvt5iXVrFIcoQ8+vCLOaHhrtEW2id0LENP+IzMw=
github.com/git-pkgs/registries v0.13.2 h1:3fWinubUZbBEJ+kDii3O5kzqHJMJBmJK1X9FefAow+I=
github.com/git-pkgs/registries v0.13.2/go.mod h1:UlX6jcAd4ftRBVVNzB4mQg32tfSNCk/L2pO4Wtplnho=
github.com/git-pkgs/registries v0.14.0 h1:PQbfRFghM6cN2xu1FcDHS2F73yOMATVIBaq+zY/6uSI=
github.com/git-pkgs/registries v0.14.0/go.mod h1:zgtz1lneDi8olIzAJxnSvSMT7PzChp9dsbFxJVbfyfQ=
github.com/git-pkgs/sbom v0.1.9 h1:sfF5cJAwmgrm2N4HTXQWjiBe8tdu8xwhjwfAOyDNMfc=
github.com/git-pkgs/sbom v0.1.9/go.mod h1:KIkZX0v31l62SeFsi2qsQXcZRVrAXvIdPQ4x4en+G2M=
github.com/git-pkgs/spdx v0.3.6 h1:tbkqeYLKgAcDV1qPZNAkNxpNMTx9EfoNQQhcVEHApzs=
Expand Down
21 changes: 17 additions & 4 deletions internal/handler/debian.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ func NewDebianHandler(
upstreamURL string,
repositories map[string]string,
) *DebianHandler {
if upstreamURL == "" {
upstreamURL = debianUpstream
}
h := &DebianHandler{
proxy: proxy,
upstreamURL: strings.TrimSuffix(upstreamURL, "/"),
upstreamURL: DebianUpstreamURL(upstreamURL),
proxyURL: strings.TrimSuffix(proxyURL, "/"),
repositories: make(map[string]string, len(repositories)),
}
Expand Down Expand Up @@ -238,11 +235,27 @@ func (h *DebianHandler) releaseListing(r *http.Request, repository, upstreamURL,
return nil, ""
}

// DebianUpstreamURL returns the upstream.debian archive, the default one when
// none is configured.
func DebianUpstreamURL(configured string) string {
if configured == "" {
configured = debianUpstream
}
return strings.TrimSuffix(configured, "/")
}

// artifactCacheFilename names a package in the cache by its repository and
// its path in it, since the same file name can hold different bytes in
// different archives, and in different directories of one archive: Docker's
// repository has a pool under each suite.
func (h *DebianHandler) artifactCacheFilename(repository, path string) string {
return DebianCacheFilename(repository, path)
}

// DebianCacheFilename is the name the Debian handler caches the package at
// path in the upstream.debian_repositories archive repository under, or in
// the upstream.debian archive when repository is empty.
func DebianCacheFilename(repository, path string) string {
if repository == "" {
return path
}
Expand Down
Loading
Loading