2024-10-17 13:40:17 -05:00
|
|
|
/*
|
2024-10-18 09:25:31 -05:00
|
|
|
Copyright Docker attest authors
|
2024-10-17 13:40:17 -05:00
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
2024-10-18 09:25:31 -05:00
|
|
|
|
2024-04-15 15:20:56 -05:00
|
|
|
package mirror
|
|
|
|
|
|
|
|
|
|
import (
|
2024-09-02 16:17:50 +01:00
|
|
|
"github.com/docker/attest/oci"
|
|
|
|
|
"github.com/docker/attest/tuf"
|
2024-04-15 15:20:56 -05:00
|
|
|
v1 "github.com/google/go-containerregistry/pkg/v1"
|
|
|
|
|
"github.com/theupdateframework/go-tuf/v2/metadata"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
2024-07-11 09:41:04 -05:00
|
|
|
DefaultMetadataURL = "https://docker.github.io/tuf/metadata"
|
|
|
|
|
DefaultTargetsURL = "https://docker.github.io/tuf/targets"
|
2024-04-15 15:20:56 -05:00
|
|
|
tufMetadataMediaType = "application/vnd.tuf.metadata+json"
|
|
|
|
|
tufTargetMediaType = "application/vnd.tuf.target"
|
|
|
|
|
tufFileAnnotation = "tuf.io/filename"
|
|
|
|
|
)
|
|
|
|
|
|
2024-08-01 15:35:15 +01:00
|
|
|
type TUFRole string
|
2024-04-15 15:20:56 -05:00
|
|
|
|
2024-08-01 15:35:15 +01:00
|
|
|
var TUFRoles = []TUFRole{metadata.ROOT, metadata.SNAPSHOT, metadata.TARGETS, metadata.TIMESTAMP}
|
2024-04-15 15:20:56 -05:00
|
|
|
|
2024-08-01 15:35:15 +01:00
|
|
|
type TUFMetadata struct {
|
2024-04-15 15:20:56 -05:00
|
|
|
Root map[string][]byte
|
|
|
|
|
Snapshot map[string][]byte
|
|
|
|
|
Targets map[string][]byte
|
|
|
|
|
Timestamp []byte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type DelegatedTargetMetadata struct {
|
|
|
|
|
Name string
|
|
|
|
|
Version string
|
|
|
|
|
Data []byte
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 15:35:15 +01:00
|
|
|
type Image struct {
|
2024-08-12 16:43:42 -05:00
|
|
|
Image *oci.EmptyConfigImage
|
2024-04-15 15:20:56 -05:00
|
|
|
Tag string
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 15:35:15 +01:00
|
|
|
type Index struct {
|
2024-06-14 10:03:39 -05:00
|
|
|
Index v1.ImageIndex
|
2024-04-15 15:20:56 -05:00
|
|
|
Tag string
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 15:35:15 +01:00
|
|
|
type TUFMirror struct {
|
|
|
|
|
TUFClient *tuf.Client
|
2024-04-15 15:20:56 -05:00
|
|
|
tufPath string
|
|
|
|
|
metadataURL string
|
|
|
|
|
targetsURL string
|
|
|
|
|
}
|