Skip to content

Commit

Permalink
refactor(meta): rename
Browse files Browse the repository at this point in the history
Signed-off-by: Laurentiu Niculae <[email protected]>
  • Loading branch information
laurentiuNiculae committed Oct 24, 2023
1 parent 12ec805 commit 50dccdf
Show file tree
Hide file tree
Showing 53 changed files with 1,014 additions and 1,012 deletions.
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ TESTDATA := $(TOP_LEVEL)/test/data
OS ?= $(shell go env GOOS)
ARCH ?= $(shell go env GOARCH)

PROTOC := $(TOOLSDIR)/bin/protoc
PROTOC_VERSION := 24.4
GO_PROTOC_VERSION := 1.31.0
PROTOC_VERSION := 3.15.8
HOST_OS := $(shell go env GOOS)
HOST_ARCH := $(shell go env GOARCH)
ifeq ($(HOST_OS),linux)
PROTOC_OS = linux
PROTOC_ARCH = x86_64
ifeq ($(HOST_ARCH),arm64)
PROTOC_ARCH = aarch_64
endif
else ifeq ($(HOST_OS),darwin)
PROTOC_OS = osx
PROTOC_ARCH = universal_binary
endif
PROTOC := $(TOOLSDIR)/bin/protoc
ifeq ($(HOST_ARCH),amd64)
PROTOC_ARCH = x86_64
else ifeq ($(HOST_ARCH),arm64)
PROTOC_ARCH = aarch_64
endif

BENCH_OUTPUT ?= stdout
ALL_EXTENSIONS = debug,imagetrust,lint,metrics,mgmt,profile,scrub,search,sync,ui,userprefs
Expand Down Expand Up @@ -283,6 +283,7 @@ $(PROTOC):
mkdir -p $(TOOLSDIR)/bin
curl -Lo protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-$(PROTOC_OS)-$(PROTOC_ARCH).zip
unzip -o -d $(TOOLSDIR) protoc.zip bin/protoc
rm protoc.zip
chmod +x $(PROTOC)
go install google.golang.org/protobuf/cmd/protoc-gen-go@v$(GO_PROTOC_VERSION)

Expand Down
2 changes: 1 addition & 1 deletion errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ var (
ErrManifestConflict = errors.New("manifest: multiple manifests found")
ErrManifestMetaNotFound = errors.New("metadb: image metadata not found for given manifest reference")
ErrManifestDataNotFound = errors.New("metadb: image data not found for given manifest digest")
ErrImageDataNotFound = errors.New("metadb: image data not found")
ErrImageMetaNotFound = errors.New("metadb: image data not found")
ErrUnexpectedMediaType = errors.New("metadb: got unexpected media type")
ErrIndexDataNotFount = errors.New("metadb: index data not found for given digest")
ErrRepoMetaNotFound = errors.New("metadb: repo metadata not found for given repo name")
Expand Down
2 changes: 1 addition & 1 deletion examples/config-all-remote.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"region": "us-east-2",
"cacheTablename": "ZotBlobTable",
"repoMetaTablename": "ZotRepoMetadataTable",
"imageDataTablename": "ZotImageDataTable",
"imageMetaTablename": "ZotImageMetaTable",
"repoBlobsInfoTablename": "ZotRepoBlobsInfoTable",
"versionTablename": "ZotVersion"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/config-dynamodb.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"region": "us-east-2",
"cacheTablename": "ZotBlobTable",
"repoMetaTablename": "ZotRepoMetadataTable",
"imageDataTablename": "ZotImageDataTable",
"imageMetaTablename": "ZotImageMetaTable",
"repoBlobsInfoTablename": "ZotRepoBlobsInfoTable",
"userDataTablename": "ZotUserDataTable",
"versionTablename": "ZotVersion"
Expand Down
16 changes: 8 additions & 8 deletions pkg/api/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestCreateCacheDatabaseDriver(t *testing.T) {
"region": "us-east-2",
"cacheTablename": "BlobTable",
"repoMetaTablename": "RepoMetadataTable",
"imageDataTablename": "ZotImageDataTable",
"imageMetaTablename": "ZotImageMetaTable",
"repoBlobsInfoTablename": "ZotRepoBlobsInfoTable",
"userDataTablename": "ZotUserDataTable",
"versionTablename": "Version",
Expand All @@ -174,7 +174,7 @@ func TestCreateCacheDatabaseDriver(t *testing.T) {
"region": "us-east-2",
"cacheTablename": "BlobTable",
"repoMetaTablename": "RepoMetadataTable",
"imageDataTablename": "ZotImageDataTable",
"imageMetaTablename": "ZotImageMetaTable",
"repoBlobsInfoTablename": "ZotRepoBlobsInfoTable",
"userDataTablename": "ZotUserDataTable",
"versionTablename": "Version",
Expand All @@ -189,7 +189,7 @@ func TestCreateCacheDatabaseDriver(t *testing.T) {
"region": "us-east-2",
"cacheTablename": "BlobTable",
"repoMetaTablename": "RepoMetadataTable",
"imageDataTablename": "ZotImageDataTable",
"imageMetaTablename": "ZotImageMetaTable",
"repoBlobsInfoTablename": "ZotRepoBlobsInfoTable",
"userDataTablename": "ZotUserDataTable",
"versionTablename": "Version",
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestCreateMetaDBDriver(t *testing.T) {
"region": "us-east-2",
"cachetablename": "BlobTable",
"repometatablename": "RepoMetadataTable",
"imageDataTablename": "ZotImageDataTable",
"imageMetaTablename": "ZotImageMetaTable",
"repoBlobsInfoTablename": "ZotRepoBlobsInfoTable",
"userdatatablename": "UserDatatable",
}
Expand All @@ -237,7 +237,7 @@ func TestCreateMetaDBDriver(t *testing.T) {
"region": "us-east-2",
"cachetablename": "",
"repometatablename": "RepoMetadataTable",
"imageDataTablename": "ZotImageDataTable",
"imageMetaTablename": "ZotImageMetaTable",
"repoBlobsInfoTablename": "ZotRepoBlobsInfoTable",
"userDataTablename": "ZotUserDataTable",
"versiontablename": 1,
Expand All @@ -252,7 +252,7 @@ func TestCreateMetaDBDriver(t *testing.T) {
"region": "us-east-2",
"cachetablename": "test",
"repometatablename": "RepoMetadataTable",
"imagedatatablename": "ZotImageDataTable",
"imagemetatablename": "ZotImageMetaTable",
"repoblobsinfotablename": "ZotRepoBlobsInfoTable",
"userdatatablename": "ZotUserDataTable",
"apikeytablename": "APIKeyTable",
Expand Down Expand Up @@ -434,7 +434,7 @@ func TestObjectStorageController(t *testing.T) {
"region": "us-east-2",
"cachetablename": "test",
"repometatablename": "RepoMetadataTable",
"imagedatatablename": "ZotImageDataTable",
"imagemetatablename": "ZotImageMetaTable",
"repoblobsinfotablename": "ZotRepoBlobsInfoTable",
"userdatatablename": "ZotUserDataTable",
"apikeytablename": "APIKeyTable1",
Expand Down Expand Up @@ -7933,7 +7933,7 @@ func TestGCSignaturesAndUntaggedManifestsWithMetaDB(t *testing.T) {
err = gc.CleanRepo(repoName)
So(err, ShouldBeNil)

// make sure both signatures are removed from repodb and repo reference for untagged is removed
// make sure both signatures are removed from metaDB and repo reference for untagged is removed
repoMeta, err = ctlr.MetaDB.GetRepoMeta(ctx, repoName)
So(err, ShouldBeNil)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/client/cve_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ func getMockCveScanner(metaDB mTypes.MetaDB) cveinfo.Scanner {
return false, err
}

manifestData, err := metaDB.GetImageData(manifestDigest)
manifestData, err := metaDB.GetImageMeta(manifestDigest)
if err != nil {
return false, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/extensions/extension_image_trust_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func TestSignatureUploadAndVerificationAWS(t *testing.T) {
versionTablename := "Version" + uuid.String()
userDataTablename := "UserDataTable" + uuid.String()
apiKeyTablename := "ApiKeyTable" + uuid.String()
imageDataTablename := "imageDataTable" + uuid.String()
imageMetaTablename := "imageMetaTable" + uuid.String()
repoBlobsInfoTablename := "repoBlobsInfoTable" + uuid.String()

cacheDriverParams := map[string]interface{}{
Expand All @@ -143,7 +143,7 @@ func TestSignatureUploadAndVerificationAWS(t *testing.T) {
"region": "us-east-2",
"cacheTablename": cacheTablename,
"repoMetaTablename": repoMetaTablename,
"imageDataTablename": imageDataTablename,
"imageMetaTablename": imageMetaTablename,
"repoBlobsInfoTablename": repoBlobsInfoTablename,
"userDataTablename": userDataTablename,
"apiKeyTablename": apiKeyTablename,
Expand Down
8 changes: 4 additions & 4 deletions pkg/extensions/imagetrust/image_trust.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ func IsResourceExistsException(err error) bool {
}

func (imgTrustStore *ImageTrustStore) VerifySignature(
signatureType string, rawSignature []byte, sigKey string, manifestDigest godigest.Digest, imageData mTypes.ImageData,
signatureType string, rawSignature []byte, sigKey string, manifestDigest godigest.Digest, imageMeta mTypes.ImageMeta,
repo string,
) (string, time.Time, bool, error) {
desc := ispec.Descriptor{
MediaType: imageData.MediaType,
Digest: imageData.Digest,
Size: imageData.Size,
MediaType: imageMeta.MediaType,
Digest: imageMeta.Digest,
Size: imageMeta.Size,
}

if manifestDigest.String() == "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/extensions/imagetrust/image_trust_disabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewAWSImageTrustStore(region, endpoint string) (*imageTrustDisabled, error)
type imageTrustDisabled struct{}

func (imgTrustStore *imageTrustDisabled) VerifySignature(
signatureType string, rawSignature []byte, sigKey string, manifestDigest godigest.Digest, imageData mTypes.ImageData,
signatureType string, rawSignature []byte, sigKey string, manifestDigest godigest.Digest, imageMeta mTypes.ImageMeta,
repo string,
) (string, time.Time, bool, error) {
return "", time.Time{}, false, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/extensions/imagetrust/image_trust_disabled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestImageTrust(t *testing.T) {
So(err, ShouldBeNil)

author, expTime, ok, err := localImgTrustStore.VerifySignature("cosign",
[]byte(""), "", image.Digest(), image.AsImageData(), repo,
[]byte(""), "", image.Digest(), image.AsImageMeta(), repo,
)
So(author, ShouldBeEmpty)
So(expTime, ShouldBeZeroValue)
Expand All @@ -52,7 +52,7 @@ func TestImageTrust(t *testing.T) {
So(err, ShouldBeNil)

author, expTime, ok, err = cloudImgTrustStore.VerifySignature("cosign",
[]byte(""), "", image.Digest(), image.AsImageData(), repo,
[]byte(""), "", image.Digest(), image.AsImageMeta(), repo,
)
So(author, ShouldBeEmpty)
So(expTime, ShouldBeZeroValue)
Expand Down
40 changes: 20 additions & 20 deletions pkg/extensions/imagetrust/image_trust_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestVerifySignatures(t *testing.T) {
image := CreateRandomImage()

imgTrustStore := &imagetrust.ImageTrustStore{}
_, _, _, err := imgTrustStore.VerifySignature("", []byte(""), "", "", image.AsImageData(), "repo")
_, _, _, err := imgTrustStore.VerifySignature("", []byte(""), "", "", image.AsImageMeta(), "repo")
So(err, ShouldNotBeNil)
So(err, ShouldEqual, zerr.ErrBadManifestDigest)
})
Expand All @@ -163,7 +163,7 @@ func TestVerifySignatures(t *testing.T) {
image := CreateRandomImage()

imgTrustStore := &imagetrust.ImageTrustStore{}
_, _, _, err := imgTrustStore.VerifySignature("wrongType", []byte(""), "", image.Digest(), image.AsImageData(),
_, _, _, err := imgTrustStore.VerifySignature("wrongType", []byte(""), "", image.Digest(), image.AsImageMeta(),
"repo")
So(err, ShouldNotBeNil)
So(err, ShouldEqual, zerr.ErrInvalidSignatureType)
Expand All @@ -180,7 +180,7 @@ func TestVerifySignatures(t *testing.T) {
CosignStorage: &imagetrust.PublicKeyLocalStorage{},
}

_, _, _, err := imgTrustStore.VerifySignature("cosign", []byte(""), "", image.Digest(), image.AsImageData(), repo)
_, _, _, err := imgTrustStore.VerifySignature("cosign", []byte(""), "", image.Digest(), image.AsImageMeta(), repo)
So(err, ShouldNotBeNil)
So(err, ShouldEqual, zerr.ErrSignConfigDirNotSet)
})
Expand All @@ -200,7 +200,7 @@ func TestVerifySignatures(t *testing.T) {
CosignStorage: pubKeyStorage,
}

_, _, _, err = imgTrustStore.VerifySignature("cosign", []byte(""), "", image.Digest(), image.AsImageData(), repo)
_, _, _, err = imgTrustStore.VerifySignature("cosign", []byte(""), "", image.Digest(), image.AsImageMeta(), repo)
So(err, ShouldNotBeNil)
})

Expand All @@ -220,7 +220,7 @@ func TestVerifySignatures(t *testing.T) {
CosignStorage: pubKeyStorage,
}

_, _, isTrusted, err := imgTrustStore.VerifySignature("cosign", []byte(""), "", image.Digest(), image.AsImageData(),
_, _, isTrusted, err := imgTrustStore.VerifySignature("cosign", []byte(""), "", image.Digest(), image.AsImageMeta(),
repo)
So(err, ShouldBeNil)
So(isTrusted, ShouldBeFalse)
Expand Down Expand Up @@ -309,7 +309,7 @@ func TestVerifySignatures(t *testing.T) {

// signature is trusted
author, _, isTrusted, err := imgTrustStore.VerifySignature("cosign", rawSignature, sigKey, image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldBeNil)
So(isTrusted, ShouldBeTrue)
So(author, ShouldNotBeEmpty)
Expand All @@ -327,7 +327,7 @@ func TestVerifySignatures(t *testing.T) {
}

_, _, _, err := imgTrustStore.VerifySignature("notation", []byte("signature"), "", image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldNotBeNil)
So(err, ShouldEqual, zerr.ErrSignConfigDirNotSet)
})
Expand All @@ -343,7 +343,7 @@ func TestVerifySignatures(t *testing.T) {
}

_, _, isTrusted, err := imgTrustStore.VerifySignature("notation", []byte(""), "", image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldNotBeNil)
So(isTrusted, ShouldBeFalse)
})
Expand All @@ -364,7 +364,7 @@ func TestVerifySignatures(t *testing.T) {
}

_, _, _, err = imgTrustStore.VerifySignature("notation", []byte("signature"), "", image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldNotBeNil)
})

Expand All @@ -386,7 +386,7 @@ func TestVerifySignatures(t *testing.T) {
}

_, _, _, err = imgTrustStore.VerifySignature("notation", []byte("signature"), "", image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldNotBeNil)
})

Expand Down Expand Up @@ -489,7 +489,7 @@ func TestVerifySignatures(t *testing.T) {

// signature is trusted
author, _, isTrusted, err := imgTrustStore.VerifySignature("notation", rawSignature, sigKey, image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldBeNil)
So(isTrusted, ShouldBeTrue)
So(author, ShouldNotBeEmpty)
Expand All @@ -499,7 +499,7 @@ func TestVerifySignatures(t *testing.T) {

// signature is not trusted
author, _, isTrusted, err = imgTrustStore.VerifySignature("notation", rawSignature, sigKey, image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldNotBeNil)
So(isTrusted, ShouldBeFalse)
So(author, ShouldNotBeEmpty)
Expand Down Expand Up @@ -985,7 +985,7 @@ func TestAWSTrustStore(t *testing.T) {
}

_, _, _, err = imgTrustStore.VerifySignature("notation", []byte("signature"), "", image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldNotBeNil)
})

Expand Down Expand Up @@ -1015,7 +1015,7 @@ func TestAWSTrustStore(t *testing.T) {
}

_, _, _, err = imgTrustStore.VerifySignature("notation", []byte("signature"), "", image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldNotBeNil)

secretsManagerCacheMock = mocks.SecretsManagerCacheMock{
Expand All @@ -1032,7 +1032,7 @@ func TestAWSTrustStore(t *testing.T) {
}

_, _, _, err = imgTrustStore.VerifySignature("notation", []byte("signature"), "", image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldNotBeNil)

secretsManagerCacheMock = mocks.SecretsManagerCacheMock{
Expand All @@ -1049,7 +1049,7 @@ func TestAWSTrustStore(t *testing.T) {
}

_, _, _, err = imgTrustStore.VerifySignature("notation", []byte("signature"), "", image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldNotBeNil)
})

Expand All @@ -1063,15 +1063,15 @@ func TestAWSTrustStore(t *testing.T) {
versionTablename := "Version" + uuid.String()
userDataTablename := "UserDataTable" + uuid.String()
apiKeyTablename := "ApiKeyTable" + uuid.String()
imageDataTablename := "imageDataTable" + uuid.String()
imageMetaTablename := "imageMetaTable" + uuid.String()
repoBlobsInfoTablename := "repoBlobsInfoTable" + uuid.String()

dynamoDBDriverParams := map[string]interface{}{
"name": "dynamoDB",
"endpoint": os.Getenv("DYNAMODBMOCK_ENDPOINT"),
"region": "us-east-2",
"repometatablename": repoMetaTablename,
"imagedatatablename": imageDataTablename,
"imagemetatablename": imageMetaTablename,
"repoblobsinfotablename": repoBlobsInfoTablename,
"userdatatablename": userDataTablename,
"apikeytablename": apiKeyTablename,
Expand Down Expand Up @@ -1287,7 +1287,7 @@ func RunVerificationTests(t *testing.T, dbDriverParams map[string]interface{}) {

// signature is trusted
author, _, isTrusted, err := imageTrustStore.VerifySignature("cosign", rawSignature, sigKey, image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldBeNil)
So(isTrusted, ShouldBeTrue)
So(author, ShouldNotBeEmpty)
Expand Down Expand Up @@ -1377,7 +1377,7 @@ func RunVerificationTests(t *testing.T, dbDriverParams map[string]interface{}) {

// signature is trusted
author, _, isTrusted, err := imageTrustStore.VerifySignature("notation", rawSignature, sigKey, image.Digest(),
image.AsImageData(), repo)
image.AsImageMeta(), repo)
So(err, ShouldBeNil)
So(isTrusted, ShouldBeTrue)
So(author, ShouldEqual, "CN=cert,O=Notary,L=Seattle,ST=WA,C=US")
Expand Down
Loading

0 comments on commit 50dccdf

Please sign in to comment.