Documentation
¶
Index ¶
- Constants
- func RepositoryToResponse(r *models.Repository) responses.RepositoryResponse
- func ValidateAIArtifactIdentity(format, name, version string) string
- type AIHandler
- type AdminAIHandler
- type AdminAuditHandler
- type AdminGPGHandler
- type AdminGroupsHandler
- type AdminPermissionsHandler
- type AdminSSOHandler
- type AdminStorageHandler
- type AdminTieringHandler
- type AdminTokensHandler
- type AdminUsersHandler
- type AttestationAttachHandler
- type AttestationAttacher
- func (a *AttestationAttacher) AttachSBOM(ctx context.Context, repo *models.Repository, report *models.SBOMReport, ...) (*responses.AttestationAttachResponse, error)
- func (a *AttestationAttacher) AttachVEX(ctx context.Context, repo *models.Repository, artifactID, format string) (*responses.AttestationAttachResponse, error)
- func (a *AttestationAttacher) Enabled(ctx context.Context, repo *models.Repository) bool
- func (a *AttestationAttacher) OnSBOMGenerated(ctx context.Context, repo *models.Repository, report *models.SBOMReport, ...)
- func (a *AttestationAttacher) OnScan(ctx context.Context, repoID, artifactID string)
- type AttestationHandler
- type AuthHandler
- type BackupHandler
- type BundleKeyResolver
- type BundlesHandler
- type CleanupHandler
- type CleanupRunner
- type CompletePresignedUploadResponse
- type CreatePresignedUploadRequest
- type CreatePresignedUploadResponse
- type DTrackPusher
- type DTrackSources
- type DebUploadHandler
- type DeltaHandler
- type DependencyTrackHandler
- type DockerGCHandler
- type DockerGCRunner
- type ErrorResponse
- type GroupMetadataNotifier
- type HTTPServer
- func (s *HTTPServer) AddMiddleware(middleware func(http.Handler) http.Handler)
- func (s *HTTPServer) EnableTLS(certFile, keyFile string)
- func (s *HTTPServer) GetRouter() chi.Router
- func (s *HTTPServer) ServeErrors() <-chan error
- func (s *HTTPServer) SetTimeouts(readTimeout, writeTimeout, readHeaderTimeout time.Duration)
- func (s *HTTPServer) Start(ctx context.Context) error
- func (s *HTTPServer) Stop(ctx context.Context) error
- type LicenseHandler
- type MavenUploadHandler
- type NPMUploadHandler
- func (h *NPMUploadHandler) HandlePublish(w http.ResponseWriter, r *http.Request)
- func (h *NPMUploadHandler) Register(router chi.Router)
- func (h *NPMUploadHandler) RegisterRepoRoutes(r chi.Router)
- func (h *NPMUploadHandler) SetNPMWorker(w *worker.NPMMetadataWorker)
- func (h *NPMUploadHandler) SetPublisher(p webhook.Publisher)
- type OIDCHandler
- type OpenAPIHandler
- type PackageDeleter
- type PresignedPart
- type PresignedPartsRequest
- type PresignedPartsResponse
- type PresignedUploadHandler
- type ProjectCleanupPreviewer
- type ProjectsHandler
- type PropertiesHandler
- type QuotasHandler
- type RPMUploadHandler
- func (h *RPMUploadHandler) Register(router chi.Router)
- func (h *RPMUploadHandler) SetDebWorker(w *worker.DebMetadataWorker)
- func (h *RPMUploadHandler) SetKeyResolver(r gpg.Resolver)
- func (h *RPMUploadHandler) SetPackageDeleter(d PackageDeleter)
- func (h *RPMUploadHandler) SetPublisher(p webhook.Publisher)
- func (h *RPMUploadHandler) SetRPMWorker(w *worker.RPMetadataWorker)
- type ReferrerRegistry
- type RepositoriesHandler
- func (h *RepositoriesHandler) RegisterAuthed(r chi.Router)
- func (h *RepositoriesHandler) WaitBackground()
- func (h *RepositoriesHandler) WithBlobStore(store storage.BlobStore) *RepositoriesHandler
- func (h *RepositoriesHandler) WithGroupMetadata(n GroupMetadataNotifier) *RepositoriesHandler
- func (h *RepositoriesHandler) WithPublisher(p webhook.Publisher) *RepositoriesHandler
- type Response
- type SAMLHandler
- type SBOMHandler
- type SecretsHandler
- type SelfTokensHandler
- type SystemInfoHandler
- type TierPlanner
- type TierRegistry
- type TierRunner
- type TieringAdminDB
- type TrashHandler
- func (h *TrashHandler) RegisterAuthed(r chi.Router)
- func (h *TrashHandler) WaitBackground()
- func (h *TrashHandler) WithBlobStore(store storage.BlobStore) *TrashHandler
- func (h *TrashHandler) WithGroupMetadata(n GroupMetadataNotifier) *TrashHandler
- func (h *TrashHandler) WithPublisher(p webhook.Publisher) *TrashHandler
- func (h *TrashHandler) WithRegenerator(r TrashRegenerator) *TrashHandler
- type TrashRegenerator
- type VEXHandler
- type VulnHandler
- type WebhooksHandler
Constants ¶
const AttestationKeyPath = "/.well-known/openartifact/attestation-key.pem"
AttestationKeyPath is where the public key verifying the attestations is served, unauthenticated.
const MaxMavenUploadBytes int64 = 1 << 30 // 1 GiB
const MaxNPMUploadBytes int64 = 200 << 20
Variables ¶
This section is empty.
Functions ¶
func RepositoryToResponse ¶ added in v0.3.0
func RepositoryToResponse(r *models.Repository) responses.RepositoryResponse
RepositoryToResponse converts a repository to its public API shape. It never includes upstream credentials; the MCP server reuses it.
func ValidateAIArtifactIdentity ¶ added in v0.6.0
ValidateAIArtifactIdentity checks the artifact_format, artifact_name and artifact_version a caller supplies when triggering an analysis (REST and MCP share it) and returns a message for the first problem, "" when acceptable. The format is one of the repository formats, which are also the ids package listings report.
Types ¶
type AIHandler ¶
type AIHandler struct {
// contains filtered or unexported fields
}
AIHandler handles AI analysis REST endpoints.
type AdminAIHandler ¶
type AdminAIHandler struct {
// contains filtered or unexported fields
}
func NewAdminAIHandler ¶
func (*AdminAIHandler) Register ¶
func (h *AdminAIHandler) Register(r chi.Router)
func (*AdminAIHandler) WithRuntime ¶ added in v0.6.0
func (h *AdminAIHandler) WithRuntime(w *worker.AIAnalysisWorker, env ai.Settings) *AdminAIHandler
WithRuntime makes configuration changes take effect immediately: after every saved change the worker's client and auto-analysis switch are rebuilt from the stored settings layered over env (the env/YAML defaults).
type AdminAuditHandler ¶
type AdminAuditHandler struct {
// contains filtered or unexported fields
}
func NewAdminAuditHandler ¶
func (*AdminAuditHandler) Register ¶
func (h *AdminAuditHandler) Register(r chi.Router)
type AdminGPGHandler ¶
type AdminGPGHandler struct {
// contains filtered or unexported fields
}
AdminGPGHandler manages the GPG keys that sign deb/rpm metadata and sealed release bundles (docs/security/signing.md). Every route needs an admin.
func NewAdminGPGHandler ¶
func (*AdminGPGHandler) Register ¶
func (h *AdminGPGHandler) Register(r chi.Router)
type AdminGroupsHandler ¶
type AdminGroupsHandler struct {
// contains filtered or unexported fields
}
func NewAdminGroupsHandler ¶
func (*AdminGroupsHandler) Register ¶
func (h *AdminGroupsHandler) Register(r chi.Router)
type AdminPermissionsHandler ¶
type AdminPermissionsHandler struct {
// contains filtered or unexported fields
}
func (*AdminPermissionsHandler) Register ¶
func (h *AdminPermissionsHandler) Register(r chi.Router)
type AdminSSOHandler ¶
type AdminSSOHandler struct {
// contains filtered or unexported fields
}
func NewAdminSSOHandler ¶
func (*AdminSSOHandler) RegisterAuthed ¶
func (h *AdminSSOHandler) RegisterAuthed(authed chi.Router)
func (*AdminSSOHandler) RegisterPublic ¶
func (h *AdminSSOHandler) RegisterPublic(r chi.Router)
type AdminStorageHandler ¶
type AdminStorageHandler struct {
// contains filtered or unexported fields
}
func NewAdminStorageHandler ¶
func (*AdminStorageHandler) Register ¶
func (h *AdminStorageHandler) Register(r chi.Router)
type AdminTieringHandler ¶ added in v0.7.0
type AdminTieringHandler struct {
// contains filtered or unexported fields
}
AdminTieringHandler serves /api/v1/admin/tiering: tiers, lifecycle policies, dry runs and the mover status.
func NewAdminTieringHandler ¶ added in v0.7.0
func NewAdminTieringHandler(db TieringAdminDB, reg TierRegistry, planner TierPlanner, runner TierRunner, log *logger.Logger, evaluator *auth.Evaluator) *AdminTieringHandler
NewAdminTieringHandler creates the handler.
func (*AdminTieringHandler) Register ¶ added in v0.7.0
func (h *AdminTieringHandler) Register(r chi.Router)
Register mounts the routes.
type AdminTokensHandler ¶
type AdminTokensHandler struct {
// contains filtered or unexported fields
}
func NewAdminTokensHandler ¶
func (*AdminTokensHandler) Register ¶
func (h *AdminTokensHandler) Register(r chi.Router)
type AdminUsersHandler ¶
type AdminUsersHandler struct {
// contains filtered or unexported fields
}
func NewAdminUsersHandler ¶
func (*AdminUsersHandler) Register ¶
func (h *AdminUsersHandler) Register(r chi.Router)
type AttestationAttachHandler ¶ added in v0.8.0
type AttestationAttachHandler struct {
// contains filtered or unexported fields
}
AttestationAttachHandler serves the attach endpoints and the per-repository switch.
func NewAttestationAttachHandler ¶ added in v0.8.0
func NewAttestationAttachHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, attacher *AttestationAttacher, blobs storage.BlobStore) *AttestationAttachHandler
NewAttestationAttachHandler builds the handler.
func (*AttestationAttachHandler) RegisterAuthed ¶ added in v0.8.0
func (h *AttestationAttachHandler) RegisterAuthed(r chi.Router)
RegisterAuthed registers the admin routes.
type AttestationAttacher ¶ added in v0.8.0
type AttestationAttacher struct {
// contains filtered or unexported fields
}
AttestationAttacher signs SBOMs and VEX documents and attaches them to the image they describe as OCI referrers, so `cosign verify-attestation`, `cosign tree` and `oras discover` find them next to the image.
func NewAttestationAttacher ¶ added in v0.8.0
func NewAttestationAttacher(db database.Database, log *logger.Logger, gen *sbom.Generator, svc *attest.Service, reg ReferrerRegistry) *AttestationAttacher
NewAttestationAttacher builds the attacher.
func (*AttestationAttacher) AttachSBOM ¶ added in v0.8.0
func (a *AttestationAttacher) AttachSBOM(ctx context.Context, repo *models.Repository, report *models.SBOMReport, doc []byte) (*responses.AttestationAttachResponse, error)
AttachSBOM attaches the stored SBOM report's document (JSON formats only).
func (*AttestationAttacher) AttachVEX ¶ added in v0.8.0
func (a *AttestationAttacher) AttachVEX(ctx context.Context, repo *models.Repository, artifactID, format string) (*responses.AttestationAttachResponse, error)
AttachVEX builds the VEX document of one artifact and attaches it.
func (*AttestationAttacher) Enabled ¶ added in v0.8.0
func (a *AttestationAttacher) Enabled(ctx context.Context, repo *models.Repository) bool
Enabled reports whether the repository attaches attestations automatically.
func (*AttestationAttacher) OnSBOMGenerated ¶ added in v0.8.0
func (a *AttestationAttacher) OnSBOMGenerated(ctx context.Context, repo *models.Repository, report *models.SBOMReport, doc []byte)
OnSBOMGenerated attaches a freshly generated SBOM when the repository opted in.
type AttestationHandler ¶ added in v0.8.0
type AttestationHandler struct {
// contains filtered or unexported fields
}
AttestationHandler exposes the public key that verifies SBOM and VEX attestations.
func NewAttestationHandler ¶ added in v0.8.0
func NewAttestationHandler(svc *attest.Service, log *logger.Logger, evaluator *auth.Evaluator) *AttestationHandler
NewAttestationHandler creates the handler; svc may be nil when attestations are unavailable.
func (*AttestationHandler) RegisterAuthed ¶ added in v0.8.0
func (h *AttestationHandler) RegisterAuthed(r chi.Router)
RegisterAuthed registers the admin description of the signing key.
func (*AttestationHandler) RegisterPublic ¶ added in v0.8.0
func (h *AttestationHandler) RegisterPublic(r chi.Router)
RegisterPublic serves the PEM public key without authentication: a verifier has to be able to fetch it before it trusts anything.
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, trustedProxies *middleware.TrustedProxies) *AuthHandler
func (*AuthHandler) RegisterAuthed ¶
func (h *AuthHandler) RegisterAuthed(r chi.Router)
func (*AuthHandler) RegisterPublic ¶
func (h *AuthHandler) RegisterPublic(r chi.Router)
func (*AuthHandler) WithBaseURL ¶ added in v0.6.0
func (h *AuthHandler) WithBaseURL(baseURL string) *AuthHandler
WithBaseURL sets the public base URL; an https value forces Secure cookies.
type BackupHandler ¶
type BackupHandler struct {
// contains filtered or unexported fields
}
func NewBackupHandler ¶
func (*BackupHandler) RegisterAuthed ¶
func (h *BackupHandler) RegisterAuthed(r chi.Router)
type BundleKeyResolver ¶ added in v0.8.0
type BundleKeyResolver interface {
SignerByRef(ctx context.Context, ref string) (gpg.Signer, *models.GPGKey, error)
}
BundleKeyResolver finds the signer for a seal request's gpg_key_id (a stored key id, a fingerprint, or "config").
type BundlesHandler ¶
type BundlesHandler struct {
// contains filtered or unexported fields
}
func NewBundlesHandler ¶
func (*BundlesHandler) RegisterAuthed ¶
func (h *BundlesHandler) RegisterAuthed(r chi.Router)
func (*BundlesHandler) WithGPGKeys ¶ added in v0.8.0
func (h *BundlesHandler) WithGPGKeys(keys BundleKeyResolver) *BundlesHandler
WithGPGKeys enables sealing with gpg_key_id: the sealed bundle's manifest is signed with the referenced key.
func (*BundlesHandler) WithPublisher ¶ added in v0.8.0
func (h *BundlesHandler) WithPublisher(p webhook.Publisher) *BundlesHandler
WithPublisher enables the bundle.promoted webhook event.
func (*BundlesHandler) WithRegenerator ¶ added in v0.8.0
func (h *BundlesHandler) WithRegenerator(r TrashRegenerator) *BundlesHandler
WithRegenerator enqueues the refresh of generated metadata (deb, rpm and npm indexes) in the target repository after a promotion.
type CleanupHandler ¶
type CleanupHandler struct {
// contains filtered or unexported fields
}
func NewCleanupHandler ¶
func NewCleanupHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, runner CleanupRunner) *CleanupHandler
func (*CleanupHandler) RegisterAuthed ¶
func (h *CleanupHandler) RegisterAuthed(r chi.Router)
type CleanupRunner ¶ added in v0.2.0
type CleanupRunner interface {
TriggerPolicy(ctx context.Context, policyID string) error
// PreviewPolicy reports what a run would remove, removing nothing.
PreviewPolicy(ctx context.Context, policyID string) (*worker.CleanupPreview, error)
}
CleanupRunner starts an immediate run of a cleanup policy. It is satisfied by *worker.CleanupWorker.
type CompletePresignedUploadResponse ¶ added in v0.5.0
type CompletePresignedUploadResponse struct {
ID string `json:"id"`
Path string `json:"path"`
SHA256 string `json:"sha256"`
Size int64 `json:"size"`
}
CompletePresignedUploadResponse mirrors the response of a raw PUT.
type CreatePresignedUploadRequest ¶ added in v0.5.0
type CreatePresignedUploadRequest struct {
Path string `json:"path"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
ContentType string `json:"content_type,omitempty"`
// Multipart asks for a multipart upload: the client PUTs the object in
// parts to URLs fetched from the parts endpoint. Required above the
// single-upload limit (5 GiB).
Multipart bool `json:"multipart,omitempty"`
// PartSize is the part size in bytes of a multipart upload (5 MiB to
// 4000 MiB); 0 lets the server choose.
PartSize int64 `json:"part_size,omitempty"`
}
CreatePresignedUploadRequest is the body of POST /repositories/{name}/uploads.
type CreatePresignedUploadResponse ¶ added in v0.5.0
type CreatePresignedUploadResponse struct {
ID string `json:"id"`
// UploadURL accepts one PUT of exactly Size bytes. Do not log it: the
// query string is the credential. Absent for a multipart upload.
UploadURL string `json:"upload_url,omitempty"`
Method string `json:"method,omitempty"`
// Headers must be sent with the PUT.
Headers map[string]string `json:"headers,omitempty"`
ExpiresAt time.Time `json:"expires_at"`
// Multipart, PartSize and PartCount describe a multipart upload: PUT each
// part (all PartSize bytes but the last) to a URL from the parts endpoint.
Multipart bool `json:"multipart,omitempty"`
PartSize int64 `json:"part_size,omitempty"`
PartCount int `json:"part_count,omitempty"`
}
CreatePresignedUploadResponse tells the client where and how to upload.
type DTrackPusher ¶ added in v0.8.0
DTrackPusher is what the handler needs from the background pusher.
type DTrackSources ¶ added in v0.8.0
type DTrackSources struct {
// contains filtered or unexported fields
}
DTrackSources builds the documents pushed to Dependency-Track from stored state.
func NewDTrackSources ¶ added in v0.8.0
func NewDTrackSources(db database.Database, gen *sbom.Generator) *DTrackSources
NewDTrackSources creates the sources over db and the SBOM generator.
func (*DTrackSources) BOM ¶ added in v0.8.0
func (s *DTrackSources) BOM(ctx context.Context, repo *models.Repository, artifactID string) ([]byte, int, error)
BOM implements dtrack.Sources: the CycloneDX SBOM without its vulnerabilities (Dependency-Track runs its own analysis and receives the decisions as VEX).
func (*DTrackSources) VEX ¶ added in v0.8.0
func (s *DTrackSources) VEX(ctx context.Context, repo *models.Repository, artifactID string, opts sbom.VEXOptions) ([]byte, int, error)
VEX implements dtrack.Sources.
type DebUploadHandler ¶
type DebUploadHandler struct {
// contains filtered or unexported fields
}
func NewDebUploadHandler ¶
func (*DebUploadHandler) Register ¶
func (h *DebUploadHandler) Register(router chi.Router)
func (*DebUploadHandler) SetDebWorker ¶
func (h *DebUploadHandler) SetDebWorker(w *worker.DebMetadataWorker)
func (*DebUploadHandler) SetPublisher ¶ added in v0.2.0
func (h *DebUploadHandler) SetPublisher(p webhook.Publisher)
SetPublisher wires the webhook publisher used for artifact events.
type DeltaHandler ¶
type DeltaHandler struct {
// contains filtered or unexported fields
}
DeltaHandler handles package delta requests.
func NewDeltaHandler ¶
func NewDeltaHandler(log *logger.Logger, db database.Database, blobStore storage.BlobStore) *DeltaHandler
NewDeltaHandler creates a new DeltaHandler.
func (*DeltaHandler) Register ¶
func (h *DeltaHandler) Register(router chi.Router)
Register registers the delta routes on the given router.
type DependencyTrackHandler ¶ added in v0.8.0
type DependencyTrackHandler struct {
// contains filtered or unexported fields
}
DependencyTrackHandler manages the Dependency-Track integration: the global settings, per-repository overrides, connection tests and manual pushes.
func NewDependencyTrackHandler ¶ added in v0.8.0
func NewDependencyTrackHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, pusher DTrackPusher) *DependencyTrackHandler
NewDependencyTrackHandler creates the handler; pusher may be nil (manual pushes then answer 501).
func (*DependencyTrackHandler) RegisterAuthed ¶ added in v0.8.0
func (h *DependencyTrackHandler) RegisterAuthed(r chi.Router)
RegisterAuthed registers the admin routes.
func (*DependencyTrackHandler) WithClientFactory ¶ added in v0.8.0
func (h *DependencyTrackHandler) WithClientFactory(f dtrack.ClientFactory) *DependencyTrackHandler
WithClientFactory replaces the Dependency-Track client constructor (tests).
type DockerGCHandler ¶ added in v0.4.0
type DockerGCHandler struct {
// contains filtered or unexported fields
}
DockerGCHandler serves the admin endpoint that runs Docker registry garbage collection (untagged manifests and the blobs only they referenced) on demand.
func NewDockerGCHandler ¶ added in v0.4.0
func NewDockerGCHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, runner DockerGCRunner) *DockerGCHandler
func (*DockerGCHandler) RegisterAuthed ¶ added in v0.4.0
func (h *DockerGCHandler) RegisterAuthed(r chi.Router)
type DockerGCRunner ¶ added in v0.4.0
type DockerGCRunner interface {
RunRepo(ctx context.Context, repo *models.Repository, opts worker.DockerGCOptions) (*worker.DockerGCReport, error)
DefaultGrace() time.Duration
}
DockerGCRunner runs Docker registry garbage collection. It is satisfied by *worker.DockerGCWorker.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
Code string `json:"code"`
Details string `json:"details,omitempty"`
}
ErrorResponse represents an error response.
type GroupMetadataNotifier ¶ added in v0.8.0
type GroupMetadataNotifier interface {
// NotifyStale marks a group's metadata stale and schedules its regeneration.
NotifyStale(groupID string)
// NotifyMemberChanged does so for every deb/rpm group listing the repository.
NotifyMemberChanged(repoID string)
}
GroupMetadataNotifier invalidates the generated metadata of deb and rpm group repositories (worker.GroupMetadataWorker).
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer implements the Server interface.
func NewHTTPServer ¶
func NewHTTPServer(addr string, log *logger.Logger) *HTTPServer
NewHTTPServer creates a new HTTP server. Defaults favor never truncating large artifact transfers: no read/write timeout, with only header reads bounded (slowloris mitigation) until SetTimeouts overrides them from config.
func (*HTTPServer) AddMiddleware ¶
func (s *HTTPServer) AddMiddleware(middleware func(http.Handler) http.Handler)
AddMiddleware adds a middleware to the server.
func (*HTTPServer) EnableTLS ¶ added in v0.2.0
func (s *HTTPServer) EnableTLS(certFile, keyFile string)
EnableTLS makes Start serve HTTPS using the given certificate and key files.
func (*HTTPServer) GetRouter ¶
func (s *HTTPServer) GetRouter() chi.Router
GetRouter returns the underlying chi router.
func (*HTTPServer) ServeErrors ¶ added in v0.4.0
func (s *HTTPServer) ServeErrors() <-chan error
ServeErrors delivers the error that ended the accept loop unexpectedly (anything but a graceful Stop). The caller must treat it as fatal.
func (*HTTPServer) SetTimeouts ¶
func (s *HTTPServer) SetTimeouts(readTimeout, writeTimeout, readHeaderTimeout time.Duration)
SetTimeouts configures read, write, and read-header timeouts on the HTTP server. readTimeout/writeTimeout of 0 mean "no limit" (relevant for large artifact transfers); readHeaderTimeout should stay non-zero regardless — it bounds only the header-read phase, so it never truncates a body.
func (*HTTPServer) Start ¶
func (s *HTTPServer) Start(ctx context.Context) error
Start binds the listen address and serves in the background. Everything that can be checked up front (the TLS key pair, the bind itself) fails here, so a misconfigured server never reports a successful start. A later failure of the accept loop is delivered on ServeErrors.
type LicenseHandler ¶
type LicenseHandler struct {
// contains filtered or unexported fields
}
func NewLicenseHandler ¶
func NewLicenseHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, detector *license.Detector, blobs storage.BlobStore) *LicenseHandler
NewLicenseHandler returns the license scan and policy handler. blobs is the store the scan reads artifact files from to find their declared licenses.
func (*LicenseHandler) RegisterRoutes ¶
func (h *LicenseHandler) RegisterRoutes(authedRouter chi.Router)
type MavenUploadHandler ¶
type MavenUploadHandler struct {
// contains filtered or unexported fields
}
func NewMavenUploadHandler ¶
func (*MavenUploadHandler) Register ¶
func (h *MavenUploadHandler) Register(router chi.Router)
Register mounts PUT/DELETE using a true chi wildcard ("/*"), not a regexp param: chi's {name:regexp} params never span "/" (the tail delimiter defaults to '/', so the regexp is only ever tested against a single path segment), so {path:.*} can never match a multi-segment GAV path and silently 404s every real upload/delete.
func (*MavenUploadHandler) SetMavenWorker ¶
func (h *MavenUploadHandler) SetMavenWorker(w *worker.MavenMetadataWorker)
SetMavenWorker wires the debounced maven-metadata.xml regeneration worker. Call NotifyStale(repoID, groupID, artifactID) after each successful upload.
func (*MavenUploadHandler) SetPublisher ¶ added in v0.2.0
func (h *MavenUploadHandler) SetPublisher(p webhook.Publisher)
SetPublisher wires the webhook publisher for artifact.* events.
type NPMUploadHandler ¶
type NPMUploadHandler struct {
// contains filtered or unexported fields
}
func NewNPMUploadHandler ¶
func (*NPMUploadHandler) HandlePublish ¶ added in v0.2.0
func (h *NPMUploadHandler) HandlePublish(w http.ResponseWriter, r *http.Request)
HandlePublish serves an npm publish (or `-rev` unpublish) PUT. It is exported for routers that share PUT "/*" with another format.
func (*NPMUploadHandler) Register ¶
func (h *NPMUploadHandler) Register(router chi.Router)
Register mounts the publish/unpublish routes under /repos/{name} on a router that has no other /repos/{name} subrouter (tests). Production code shares the /repos/{name} subrouter with the other formats and calls RegisterRepoRoutes.
func (*NPMUploadHandler) RegisterRepoRoutes ¶ added in v0.2.0
func (h *NPMUploadHandler) RegisterRepoRoutes(r chi.Router)
RegisterRepoRoutes registers the routes relative to a /repos/{name} subrouter. They must live inside that subrouter: a sibling /repos/{repo}/* route is shadowed by the mount and every PUT/DELETE 404s.
func (*NPMUploadHandler) SetNPMWorker ¶
func (h *NPMUploadHandler) SetNPMWorker(w *worker.NPMMetadataWorker)
SetNPMWorker wires the debounced npm packument regeneration worker. Call NotifyStale(packageID) after each successful publish.
func (*NPMUploadHandler) SetPublisher ¶ added in v0.2.0
func (h *NPMUploadHandler) SetPublisher(p webhook.Publisher)
SetPublisher wires the webhook publisher used for artifact.uploaded and artifact.deleted events. It must be called before the handler serves requests.
type OIDCHandler ¶
type OIDCHandler struct {
// contains filtered or unexported fields
}
func NewOIDCHandler ¶
func (*OIDCHandler) RegisterPublic ¶
func (h *OIDCHandler) RegisterPublic(public chi.Router)
func (*OIDCHandler) WithTrustedProxies ¶ added in v0.2.0
func (h *OIDCHandler) WithTrustedProxies(tp *middleware.TrustedProxies) *OIDCHandler
WithTrustedProxies sets the reverse-proxy allowlist used to resolve the client IP recorded on new sessions. Without it the TCP peer address is used.
type OpenAPIHandler ¶
type OpenAPIHandler struct{}
func NewOpenAPIHandler ¶
func NewOpenAPIHandler() *OpenAPIHandler
func (*OpenAPIHandler) RegisterRoutes ¶
func (h *OpenAPIHandler) RegisterRoutes(router chi.Router)
type PackageDeleter ¶ added in v0.8.0
type PackageDeleter interface {
DeletePackage(ctx context.Context, repo *models.Repository, id string, guard func(worker.DeletedPackage) error) (*worker.DeletedPackage, error)
}
PackageDeleter deletes a package row of any hosted format by its listing id. It is satisfied by *worker.CleanupWorker.
type PresignedPart ¶ added in v0.8.0
type PresignedPart struct {
PartNumber int `json:"part_number"`
// UploadURL accepts one PUT of exactly Size bytes. Do not log it: the
// query string is the credential.
UploadURL string `json:"upload_url"`
Method string `json:"method"`
// Headers must be sent with the PUT.
Headers map[string]string `json:"headers"`
// Size is the exact size of the part in bytes.
Size int64 `json:"size"`
}
PresignedPart is the upload target of one part.
type PresignedPartsRequest ¶ added in v0.8.0
type PresignedPartsRequest struct {
// PartNumbers are the 1-based parts to sign, at most 100 per call.
PartNumbers []int `json:"part_numbers"`
}
PresignedPartsRequest is the body of POST /repositories/{name}/uploads/{id}/parts.
type PresignedPartsResponse ¶ added in v0.8.0
type PresignedPartsResponse struct {
Parts []PresignedPart `json:"parts"`
ExpiresAt time.Time `json:"expires_at"`
}
PresignedPartsResponse carries the signed part URLs.
type PresignedUploadHandler ¶ added in v0.5.0
PresignedUploadHandler implements client-direct uploads: the client PUTs the bytes straight to the object store using a short-lived presigned URL, then calls complete so the server can verify size and sha256 and record the artifact. Only raw hosted repositories are supported.
func NewPresignedUploadHandler ¶ added in v0.5.0
func NewPresignedUploadHandler(log *logger.Logger, db database.Database, blobStore storage.BlobStore, evaluator *auth.Evaluator, urlTTL time.Duration, maxPending int, reg *metrics.Registry, ) *PresignedUploadHandler
NewPresignedUploadHandler builds the handler. blobStore may or may not support staging uploads; an unsupported backend answers 501 without recording anything. maxPending caps one user's outstanding uploads (0 = unlimited).
func (*PresignedUploadHandler) Register ¶ added in v0.5.0
func (h *PresignedUploadHandler) Register(router chi.Router)
Register mounts the routes.
type ProjectCleanupPreviewer ¶ added in v0.8.0
type ProjectCleanupPreviewer interface {
PreviewProjectPolicy(ctx context.Context, policyID string) ([]*worker.CleanupPreview, error)
}
ProjectCleanupPreviewer evaluates a project default cleanup policy without running it. It is satisfied by *worker.CleanupWorker.
type ProjectsHandler ¶ added in v0.6.0
type ProjectsHandler struct {
// contains filtered or unexported fields
}
ProjectsHandler serves /api/v1/projects: projects, their members and the groups attached to them. The RBAC middleware is the first gate (project scope, 404 for non-members, 403 below the required role); the handler re-checks the same decision from the evaluator, so a route reached any other way is still protected, and adds the escalation guards the middleware cannot know (which role is granted to whom).
func NewProjectsHandler ¶ added in v0.6.0
func NewProjectsHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, settings *auth.ProjectSettings) *ProjectsHandler
NewProjectsHandler returns the projects handler. evaluator decides roles and who is a global admin (implicit owner of every project); settings holds the projects.self_create switch.
func (*ProjectsHandler) RegisterRoutes ¶ added in v0.6.0
func (h *ProjectsHandler) RegisterRoutes(r chi.Router)
func (*ProjectsHandler) SetCleanupPreviewer ¶ added in v0.8.0
func (h *ProjectsHandler) SetCleanupPreviewer(p ProjectCleanupPreviewer)
SetCleanupPreviewer wires the dry run of project default cleanup policies.
type PropertiesHandler ¶
type PropertiesHandler struct {
// contains filtered or unexported fields
}
func NewPropertiesHandler ¶
func NewPropertiesHandler(log *logger.Logger, db database.Database, blobs storage.BlobStore) *PropertiesHandler
NewPropertiesHandler returns the artifact properties handler. blobs is the store read to re-evaluate license policies on the artifact's own declared licenses when a license property changes.
func (*PropertiesHandler) RegisterRoutes ¶
func (h *PropertiesHandler) RegisterRoutes(r chi.Router, pathPrefix string)
type QuotasHandler ¶
type QuotasHandler struct {
// contains filtered or unexported fields
}
func NewQuotasHandler ¶
func (*QuotasHandler) RegisterRoutes ¶
func (h *QuotasHandler) RegisterRoutes(r chi.Router, pathPrefix string)
type RPMUploadHandler ¶
type RPMUploadHandler struct {
// contains filtered or unexported fields
}
func NewRPMUploadHandler ¶
func (*RPMUploadHandler) Register ¶
func (h *RPMUploadHandler) Register(router chi.Router)
func (*RPMUploadHandler) SetDebWorker ¶
func (h *RPMUploadHandler) SetDebWorker(w *worker.DebMetadataWorker)
func (*RPMUploadHandler) SetKeyResolver ¶ added in v0.8.0
func (h *RPMUploadHandler) SetKeyResolver(r gpg.Resolver)
SetKeyResolver wires the signing keys used by repositories with sign_packages.
func (*RPMUploadHandler) SetPackageDeleter ¶ added in v0.8.0
func (h *RPMUploadHandler) SetPackageDeleter(d PackageDeleter)
SetPackageDeleter wires the deleter behind DELETE /repositories/{name}/packages/{id} for every format but deb and rpm, which have handlers of their own.
func (*RPMUploadHandler) SetPublisher ¶ added in v0.2.0
func (h *RPMUploadHandler) SetPublisher(p webhook.Publisher)
SetPublisher wires the webhook publisher used for artifact events. It also covers the embedded deb handler that serves deb repositories on the same routes.
func (*RPMUploadHandler) SetRPMWorker ¶
func (h *RPMUploadHandler) SetRPMWorker(w *worker.RPMetadataWorker)
type ReferrerRegistry ¶ added in v0.8.0
type ReferrerRegistry interface {
AttachReferrer(ctx context.Context, repo *models.Repository, req docker.ReferrerRequest) (*docker.ReferrerResult, error)
FindReferrer(ctx context.Context, repo *models.Repository, image, subjectDigest, artifactType string, annotations map[string]string) (string, error)
}
ReferrerRegistry is the docker registry's way of storing a referrer.
type RepositoriesHandler ¶
type RepositoriesHandler struct {
// contains filtered or unexported fields
}
func NewRepositoriesHandler ¶
func (*RepositoriesHandler) RegisterAuthed ¶
func (h *RepositoriesHandler) RegisterAuthed(r chi.Router)
func (*RepositoriesHandler) WaitBackground ¶ added in v0.2.0
func (h *RepositoriesHandler) WaitBackground()
WaitBackground blocks until background orphan-blob collections finish.
func (*RepositoriesHandler) WithBlobStore ¶ added in v0.2.0
func (h *RepositoriesHandler) WithBlobStore(store storage.BlobStore) *RepositoriesHandler
WithBlobStore enables the package download endpoint.
func (*RepositoriesHandler) WithGroupMetadata ¶ added in v0.8.0
func (h *RepositoriesHandler) WithGroupMetadata(n GroupMetadataNotifier) *RepositoriesHandler
WithGroupMetadata makes changes to deb and rpm repositories regenerate the metadata of the groups they belong to.
func (*RepositoriesHandler) WithPublisher ¶ added in v0.2.0
func (h *RepositoriesHandler) WithPublisher(p webhook.Publisher) *RepositoriesHandler
WithPublisher enables repository.created / repository.deleted webhook events.
type Response ¶
type Response struct {
Success bool `json:"success"`
Data any `json:"data,omitempty"`
Error string `json:"error,omitempty"`
Code string `json:"code,omitempty"`
}
Response represents a standard API response.
type SAMLHandler ¶
type SAMLHandler struct {
// contains filtered or unexported fields
}
func NewSAMLHandler ¶
func (*SAMLHandler) RegisterPublic ¶
func (h *SAMLHandler) RegisterPublic(public chi.Router)
func (*SAMLHandler) WithTrustedProxies ¶ added in v0.2.0
func (h *SAMLHandler) WithTrustedProxies(tp *middleware.TrustedProxies) *SAMLHandler
WithTrustedProxies overrides the reverse-proxy allowlist (default: the configured server.trustedProxies) used to resolve the client IP recorded on new sessions.
type SBOMHandler ¶
type SBOMHandler struct {
// contains filtered or unexported fields
}
func NewSBOMHandler ¶
func (*SBOMHandler) RegisterAuthed ¶
func (h *SBOMHandler) RegisterAuthed(r chi.Router)
func (*SBOMHandler) WithAttacher ¶ added in v0.8.0
func (h *SBOMHandler) WithAttacher(a *AttestationAttacher) *SBOMHandler
WithAttacher attaches each generated SBOM to its docker image as an OCI referrer in repositories that enabled it.
func (*SBOMHandler) WithAttestation ¶ added in v0.8.0
func (h *SBOMHandler) WithAttestation(svc *attest.Service) *SBOMHandler
WithAttestation enables signed downloads (`?attest=true`).
type SecretsHandler ¶
type SecretsHandler struct {
// contains filtered or unexported fields
}
func NewSecretsHandler ¶
func (*SecretsHandler) RegisterRoutes ¶
func (h *SecretsHandler) RegisterRoutes(authedRouter chi.Router, pathPrefix string)
type SelfTokensHandler ¶
type SelfTokensHandler struct {
// contains filtered or unexported fields
}
func NewSelfTokensHandler ¶
func (*SelfTokensHandler) Register ¶
func (h *SelfTokensHandler) Register(r chi.Router)
type SystemInfoHandler ¶
type SystemInfoHandler struct {
// contains filtered or unexported fields
}
func NewSystemInfoHandler ¶
func (*SystemInfoHandler) RegisterAuthed ¶ added in v0.2.0
func (h *SystemInfoHandler) RegisterAuthed(r chi.Router)
RegisterAuthed registers the detailed endpoint (behind the admin RBAC check).
func (*SystemInfoHandler) RegisterPublic ¶
func (h *SystemInfoHandler) RegisterPublic(r chi.Router)
RegisterPublic registers the unauthenticated, trimmed endpoint: version and an overall status only.
func (*SystemInfoHandler) ServeHTTP ¶
func (h *SystemInfoHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request)
type TierPlanner ¶ added in v0.7.0
type TierPlanner interface {
Plan(ctx context.Context, draft *tiering.Policy, sampleLimit int) (*tiering.Plan, error)
}
TierPlanner simulates policies (the tiering engine).
type TierRegistry ¶ added in v0.7.0
TierRegistry is the tier registry as the admin API sees it.
type TierRunner ¶ added in v0.7.0
type TierRunner interface {
// Trigger asks for an immediate pass; it reports false when one is already running.
Trigger() bool
Status() tiering.RunnerStatus
}
TierRunner is the background mover as the admin API sees it.
type TieringAdminDB ¶ added in v0.7.0
type TieringAdminDB interface {
ListStorageTiers(ctx context.Context) ([]*models.StorageTier, error)
GetStorageTierByName(ctx context.Context, name string) (*models.StorageTier, error)
CreateStorageTier(ctx context.Context, t *models.StorageTier) error
UpdateStorageTier(ctx context.Context, t *models.StorageTier) error
// DeleteStorageTierIfUnused checks and deletes atomically; it returns the
// reason the tier is still in use, or "" once it is deleted.
DeleteStorageTierIfUnused(ctx context.Context, id string) (string, error)
GetStorageBackend(ctx context.Context, name string) (*models.StorageBackend, error)
ListStoragePolicies(ctx context.Context) ([]*models.StoragePolicy, error)
GetStoragePolicy(ctx context.Context, id string) (*models.StoragePolicy, error)
CreateStoragePolicy(ctx context.Context, p *models.StoragePolicy) error
UpdateStoragePolicy(ctx context.Context, p *models.StoragePolicy) error
DeleteStoragePolicy(ctx context.Context, id string) (bool, error)
StorageTierUsage(ctx context.Context) ([]models.TierUsage, error)
ListStorageTierMoves(ctx context.Context, limit int) ([]*models.StorageTierMove, error)
CountStorageTierMoves(ctx context.Context) (int64, error)
}
TieringAdminDB is the persistence the tiering admin API needs.
type TrashHandler ¶ added in v0.5.0
type TrashHandler struct {
// contains filtered or unexported fields
}
TrashHandler serves the trash API: listing, restoring and purging soft-deleted packages and repositories.
The global routes (/api/v1/trash...) are admin only. The repository routes (/api/v1/repositories/{name}/trash...) need the repository-scoped `delete` permission and only ever touch items of that repository; emptying a repository's trash needs the repository-scoped `manage` permission.
func NewTrashHandler ¶ added in v0.5.0
func (*TrashHandler) RegisterAuthed ¶ added in v0.5.0
func (h *TrashHandler) RegisterAuthed(r chi.Router)
func (*TrashHandler) WaitBackground ¶ added in v0.5.0
func (h *TrashHandler) WaitBackground()
WaitBackground blocks until background orphan-blob collections finish.
func (*TrashHandler) WithBlobStore ¶ added in v0.5.0
func (h *TrashHandler) WithBlobStore(store storage.BlobStore) *TrashHandler
WithBlobStore enables freeing blobs when an item is purged.
func (*TrashHandler) WithGroupMetadata ¶ added in v0.8.0
func (h *TrashHandler) WithGroupMetadata(n GroupMetadataNotifier) *TrashHandler
WithGroupMetadata makes restoring a deb or rpm repository regenerate the merged metadata of the groups it belongs to (or its own, for a group).
func (*TrashHandler) WithPublisher ¶ added in v0.5.0
func (h *TrashHandler) WithPublisher(p webhook.Publisher) *TrashHandler
WithPublisher enables the artifact.restored/purged and repository.restored/purged events.
func (*TrashHandler) WithRegenerator ¶ added in v0.5.0
func (h *TrashHandler) WithRegenerator(r TrashRegenerator) *TrashHandler
WithRegenerator enables the metadata refresh after a restore.
type TrashRegenerator ¶ added in v0.5.0
type TrashRegenerator interface {
NotifyDebStale(repoID string)
NotifyRPMStale(repoID string)
NotifyMavenStale(repoID, groupID, artifactID string)
NotifyNPMStale(packageID string)
}
TrashRegenerator schedules the metadata refresh a restored item needs: a row that left the trash changes what the format's generated metadata lists, exactly like a fresh upload. Every method only enqueues work.
func NewWorkerRegenerator ¶ added in v0.5.0
func NewWorkerRegenerator(deb, rpm repoStaleNotifier, maven mavenStaleNotifier, npm npmStaleNotifier) TrashRegenerator
NewWorkerRegenerator builds the TrashRegenerator over the metadata workers constructed in main.go. Pass nil for a worker that is not running.
type VEXHandler ¶ added in v0.7.0
type VEXHandler struct {
// contains filtered or unexported fields
}
VEXHandler serves VEX documents built from the scan results and manages the admin VEX decisions.
func NewVEXHandler ¶ added in v0.7.0
func (*VEXHandler) RegisterAuthed ¶ added in v0.7.0
func (h *VEXHandler) RegisterAuthed(r chi.Router)
func (*VEXHandler) WithAttestation ¶ added in v0.8.0
func (h *VEXHandler) WithAttestation(svc *attest.Service) *VEXHandler
WithAttestation enables signed documents (`?attest=true`).
type VulnHandler ¶
type VulnHandler struct {
// contains filtered or unexported fields
}
VulnHandler handles vulnerability scanning endpoints.
func NewVulnHandler ¶
func NewVulnHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, scanners *vuln.Registry) *VulnHandler
NewVulnHandler creates a new vulnerability handler. scanners provides the scanner backends and their availability; nil means the defaults (trivy and grype from PATH, no database refresh).
func (*VulnHandler) RegisterOverviewRoutes ¶ added in v0.7.0
func (h *VulnHandler) RegisterOverviewRoutes(authedRouter chi.Router)
RegisterOverviewRoutes registers the cross-repository scan overview, which is not scoped to one repository. Administrative like every scan route: the RBAC middleware requires "manage" on /api/v1/ paths and the handlers check the admin flag again.
func (*VulnHandler) RegisterRoutes ¶
func (h *VulnHandler) RegisterRoutes(authedRouter chi.Router, pathPrefix string)
RegisterRoutes registers vulnerability scanning routes.
func (*VulnHandler) WithScanHook ¶ added in v0.8.0
func (h *VulnHandler) WithScanHook(f func(repoID, artifactID string)) *VulnHandler
WithScanHook sets a function called after each completed (or partial) scan was stored; the Dependency-Track integration uses it to push fresh results.
type WebhooksHandler ¶
type WebhooksHandler struct {
// contains filtered or unexported fields
}
func NewWebhooksHandler ¶
func NewWebhooksHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, dispatcher *webhook.Dispatcher) *WebhooksHandler
func (*WebhooksHandler) RegisterAuthed ¶
func (h *WebhooksHandler) RegisterAuthed(r chi.Router)
Source Files
¶
- admin_ai.go
- admin_audit.go
- admin_audit_cursor.go
- admin_gpg.go
- admin_groups.go
- admin_mutation_audit.go
- admin_permissions.go
- admin_sso.go
- admin_sso_oidc.go
- admin_storage.go
- admin_tiering.go
- admin_tokens.go
- admin_users.go
- ai.go
- attestation.go
- attestation_attach.go
- audit_export.go
- auth_handlers.go
- auth_helpers.go
- backup.go
- bundles.go
- bundles_promote.go
- bundles_signing.go
- cleanup.go
- cookie.go
- delta.go
- dependency_track.go
- docker_gc.go
- interfaces.go
- license.go
- license_artifact.go
- maven_parent_license.go
- openapi.go
- package_delete.go
- presigned_multipart.go
- presigned_uploads.go
- projects.go
- projects_activity.go
- projects_audit.go
- projects_cleanup.go
- projects_groups.go
- projects_members.go
- projects_quota.go
- projects_repos.go
- projects_tokens.go
- properties.go
- quotas.go
- repositories.go
- repositories_project.go
- sbom.go
- scan_export.go
- scan_helpers.go
- secrets.go
- self_tokens.go
- server.go
- sso_common.go
- sso_oidc_handlers.go
- sso_saml_handlers.go
- system_info.go
- trash.go
- trash_regen.go
- upload_deb.go
- upload_maven.go
- upload_npm.go
- upload_npm_body.go
- upload_npm_deprecate.go
- upload_rpm.go
- vex.go
- vuln.go
- vuln_distro.go
- vuln_overview.go
- vuln_overview_cursor.go
- webhooks.go