diff --git a/cmd/rekor-cli/app/get.go b/cmd/rekor-cli/app/get.go index 6c85222198f39db0481a13c161239ce0b39562c7..fe66a27a21a27608068da495330d63f5581702bb 100644 --- a/cmd/rekor-cli/app/get.go +++ b/cmd/rekor-cli/app/get.go @@ -159,7 +159,6 @@ func parseEntry(uuid string, e models.LogEntryAnon) (interface{}, error) { if e.Attestation != nil { obj.Attestation = string(e.Attestation.Data) - obj.AttestationType = e.Attestation.MediaType } return &obj, nil diff --git a/openapi.yaml b/openapi.yaml index 63c64b20c0dd6975b65253953d50fab3cc57f6d6..2c0987ca09383a7312286e5befdcc122297a22e7 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -468,9 +468,7 @@ definitions: type: object properties: data: - format: byte - mediaType: - format: string + format: byte format: byte verification: diff --git a/pkg/api/entries.go b/pkg/api/entries.go index fd6d2bb74cdf673fe583fa89f2727ad1db160b45..58701e29f978553cc2f94b02863e339988a0df1c 100644 --- a/pkg/api/entries.go +++ b/pkg/api/entries.go @@ -94,13 +94,12 @@ func logEntryFromLeaf(ctx context.Context, signer signature.Signer, tc TrillianC uuid := hex.EncodeToString(leaf.MerkleLeafHash) if viper.GetBool("enable_attestation_storage") { - att, typ, err := storageClient.FetchAttestation(ctx, uuid) + att, err := storageClient.FetchAttestation(ctx, uuid) if err != nil { log.Logger.Errorf("error fetching attestation: %s %s", uuid, err) } else { logEntryAnon.Attestation = &models.LogEntryAnonAttestation{ - Data: att, - MediaType: typ, + Data: att, } } } @@ -210,12 +209,12 @@ func createLogEntry(params entries.CreateLogEntryParams) (models.LogEntry, middl if viper.GetBool("enable_attestation_storage") { go func() { - typ, attestation := entry.Attestation() - if typ == "" { + attestation := entry.Attestation() + if attestation == nil { log.RequestIDLogger(params.HTTPRequest).Infof("no attestation for %s", uuid) return } - if err := storeAttestation(context.Background(), uuid, typ, attestation); err != nil { + if err := storeAttestation(context.Background(), uuid, attestation); err != nil { log.RequestIDLogger(params.HTTPRequest).Errorf("error storing attestation: %s", err) } }() diff --git a/pkg/api/index.go b/pkg/api/index.go index 8aa088a70552222fde47c114d231a1a0d4704c7f..27a9f5c82954ca112c84d07adbe903b2e162f0b5 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -96,6 +96,6 @@ func addToIndex(ctx context.Context, key, value string) error { return redisClient.Do(ctx, radix.Cmd(nil, "LPUSH", key, value)) } -func storeAttestation(ctx context.Context, uuid, attestationType string, attestation []byte) error { - return storageClient.StoreAttestation(ctx, uuid, attestationType, attestation) +func storeAttestation(ctx context.Context, uuid string, attestation []byte) error { + return storageClient.StoreAttestation(ctx, uuid, attestation) } diff --git a/pkg/generated/models/log_entry.go b/pkg/generated/models/log_entry.go index c1ab0777c4861f0bad4c2e7ce8af2ed7e3e147a0..6aa7f4efa9b35e5ea7768b68aa2518ae0054dbc4 100644 --- a/pkg/generated/models/log_entry.go +++ b/pkg/generated/models/log_entry.go @@ -300,9 +300,6 @@ type LogEntryAnonAttestation struct { // data // Format: byte Data strfmt.Base64 `json:"data,omitempty"` - - // media type - MediaType string `json:"mediaType,omitempty"` } // Validate validates this log entry anon attestation diff --git a/pkg/generated/restapi/embedded_spec.go b/pkg/generated/restapi/embedded_spec.go index 7441c7920489a8575e060fdfdc9544705514288b..0dde72c6aba50e3411cac030e198f36783698f8d 100644 --- a/pkg/generated/restapi/embedded_spec.go +++ b/pkg/generated/restapi/embedded_spec.go @@ -498,9 +498,6 @@ func init() { "properties": { "data": { "format": "byte" - }, - "mediaType": { - "format": "string" } } }, @@ -1982,9 +1979,6 @@ func init() { "properties": { "data": { "format": "byte" - }, - "mediaType": { - "format": "string" } } }, @@ -2025,9 +2019,6 @@ func init() { "properties": { "data": { "format": "byte" - }, - "mediaType": { - "format": "string" } } }, diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index bf2c76d9b44bd222134b2495c61d976b38b306c3..2e182e495a7f1be1015d6148410a6b4a301161d7 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -31,8 +31,8 @@ import ( ) type AttestationStorage interface { - StoreAttestation(ctx context.Context, key string, attestationType string, attestation []byte) error - FetchAttestation(ctx context.Context, key string) ([]byte, string, error) + StoreAttestation(ctx context.Context, key string, attestation []byte) error + FetchAttestation(ctx context.Context, key string) ([]byte, error) } func NewAttestationStorage() (AttestationStorage, error) { @@ -53,11 +53,9 @@ type Blob struct { bucket *blob.Bucket } -func (b *Blob) StoreAttestation(ctx context.Context, key, attestationType string, attestation []byte) error { - log.Logger.Infof("storing attestation of type %s at %s", attestationType, key) - w, err := b.bucket.NewWriter(ctx, key, &blob.WriterOptions{ - ContentType: attestationType, - }) +func (b *Blob) StoreAttestation(ctx context.Context, key string, attestation []byte) error { + log.Logger.Infof("storing attestation at %s", key) + w, err := b.bucket.NewWriter(ctx, key, nil) if err != nil { return err } @@ -67,23 +65,19 @@ func (b *Blob) StoreAttestation(ctx context.Context, key, attestationType string return w.Close() } -func (b *Blob) FetchAttestation(ctx context.Context, key string) ([]byte, string, error) { +func (b *Blob) FetchAttestation(ctx context.Context, key string) ([]byte, error) { log.Logger.Infof("fetching attestation %s", key) exists, err := b.bucket.Exists(ctx, key) if err != nil { - return nil, "", err + return nil, err } if !exists { - return nil, "", nil - } - att, err := b.bucket.Attributes(ctx, key) - if err != nil { - return nil, "", err + return nil, nil } data, err := b.bucket.ReadAll(ctx, key) if err != nil { - return nil, "", err + return nil, err } - return data, att.ContentType, nil + return data, nil } diff --git a/pkg/types/alpine/v0.0.1/entry.go b/pkg/types/alpine/v0.0.1/entry.go index a148f63da40c7912e132fdae736cf249d569df24..311685273966b19349623cd2a854ea399fc8ecb9 100644 --- a/pkg/types/alpine/v0.0.1/entry.go +++ b/pkg/types/alpine/v0.0.1/entry.go @@ -300,8 +300,8 @@ func (v V001Entry) validate() error { return nil } -func (v V001Entry) Attestation() (string, []byte) { - return "", nil +func (v V001Entry) Attestation() []byte { + return nil } func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { diff --git a/pkg/types/entries.go b/pkg/types/entries.go index 0d5c3ebafd912cb6a72d6b9b9668e1137c1b687a..dda638ba401a4ac977d9d152afd6d081f98c0435 100644 --- a/pkg/types/entries.go +++ b/pkg/types/entries.go @@ -35,7 +35,7 @@ type EntryImpl interface { IndexKeys() ([]string, error) // the keys that should be added to the external index for this entry Canonicalize(ctx context.Context) ([]byte, error) // marshal the canonical entry to be put into the tlog Unmarshal(e models.ProposedEntry) error // unmarshal the abstract entry into the specific struct for this versioned type - Attestation() (string, []byte) + Attestation() []byte CreateFromArtifactProperties(context.Context, ArtifactProperties) (models.ProposedEntry, error) } diff --git a/pkg/types/hashedrekord/v0.0.1/entry.go b/pkg/types/hashedrekord/v0.0.1/entry.go index 9bb3702c1cb3094870c450d02df08cff057226b6..1cb646cc07e7847d241d81caa03c08c45312f9f6 100644 --- a/pkg/types/hashedrekord/v0.0.1/entry.go +++ b/pkg/types/hashedrekord/v0.0.1/entry.go @@ -182,8 +182,8 @@ func (v *V001Entry) validate() (pki.Signature, pki.PublicKey, error) { return sigObj, keyObj, nil } -func (v V001Entry) Attestation() (string, []byte) { - return "", nil +func (v V001Entry) Attestation() []byte { + return nil } func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { diff --git a/pkg/types/helm/v0.0.1/entry.go b/pkg/types/helm/v0.0.1/entry.go index 2665f81222028452ff44234a4d278f778351200a..545d3cc519077dddb18b4b0234da9054821bb49e 100644 --- a/pkg/types/helm/v0.0.1/entry.go +++ b/pkg/types/helm/v0.0.1/entry.go @@ -299,8 +299,8 @@ func (v V001Entry) validate() error { return nil } -func (v V001Entry) Attestation() (string, []byte) { - return "", nil +func (v V001Entry) Attestation() []byte { + return nil } func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { diff --git a/pkg/types/intoto/v0.0.1/entry.go b/pkg/types/intoto/v0.0.1/entry.go index 1c2fc280426beb81c71dd42160c57c81669fc097..66cc065f3bf5ce0d9f359f58fe8f076cc4c0131c 100644 --- a/pkg/types/intoto/v0.0.1/entry.go +++ b/pkg/types/intoto/v0.0.1/entry.go @@ -193,12 +193,12 @@ func (v *V001Entry) validate() error { return nil } -func (v *V001Entry) Attestation() (string, []byte) { +func (v *V001Entry) Attestation() []byte { if len(v.env.Payload) > viper.GetInt("max_attestation_size") { log.Logger.Infof("Skipping attestation storage, size %d is greater than max %d", len(v.env.Payload), viper.GetInt("max_attestation_size")) - return "", nil + return nil } - return v.env.PayloadType, []byte(v.env.Payload) + return []byte(v.env.Payload) } type verifier struct { diff --git a/pkg/types/jar/v0.0.1/entry.go b/pkg/types/jar/v0.0.1/entry.go index 8a7574948f9aff2fff3cf9df24c7edd4ade11b92..6bbbe00997060577b8d37992539c069443b47f18 100644 --- a/pkg/types/jar/v0.0.1/entry.go +++ b/pkg/types/jar/v0.0.1/entry.go @@ -290,8 +290,8 @@ func extractPKCS7SignatureFromJAR(inz *zip.Reader) ([]byte, error) { return nil, errors.New("unable to locate signature in JAR file") } -func (v V001Entry) Attestation() (string, []byte) { - return "", nil +func (v V001Entry) Attestation() []byte { + return nil } func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { diff --git a/pkg/types/rekord/v0.0.1/entry.go b/pkg/types/rekord/v0.0.1/entry.go index c7b4b8b86ce5836073a1662ef24c4c9d3b46ac32..d0f6d4c4a34c84be1fbf9350ef00c682c1615419 100644 --- a/pkg/types/rekord/v0.0.1/entry.go +++ b/pkg/types/rekord/v0.0.1/entry.go @@ -353,8 +353,8 @@ func (v V001Entry) validate() error { return nil } -func (v V001Entry) Attestation() (string, []byte) { - return "", nil +func (v V001Entry) Attestation() []byte { + return nil } func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { diff --git a/pkg/types/rfc3161/v0.0.1/entry.go b/pkg/types/rfc3161/v0.0.1/entry.go index f67e1e5f7225899f7c0d976e9a685d4eee20d69e..67450a3e8232b86baf27259e189456a78595ac01 100644 --- a/pkg/types/rfc3161/v0.0.1/entry.go +++ b/pkg/types/rfc3161/v0.0.1/entry.go @@ -173,8 +173,8 @@ func (v V001Entry) validate() error { return nil } -func (v V001Entry) Attestation() (string, []byte) { - return "", nil +func (v V001Entry) Attestation() []byte { + return nil } func (v V001Entry) CreateFromArtifactProperties(_ context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { diff --git a/pkg/types/rpm/v0.0.1/entry.go b/pkg/types/rpm/v0.0.1/entry.go index 219b4a338e5afeff2840169e12a0fd623a398e4d..72e66952b1c24a572524caccf38efec94342f57c 100644 --- a/pkg/types/rpm/v0.0.1/entry.go +++ b/pkg/types/rpm/v0.0.1/entry.go @@ -321,8 +321,8 @@ func (v V001Entry) validate() error { return nil } -func (v V001Entry) Attestation() (string, []byte) { - return "", nil +func (v V001Entry) Attestation() []byte { + return nil } func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { diff --git a/pkg/types/test_util.go b/pkg/types/test_util.go index bd663e0ee529300d6174f89c62bbb7140e7f97b4..5b91104f0a17a2510027bb883ed636566f88a785 100644 --- a/pkg/types/test_util.go +++ b/pkg/types/test_util.go @@ -48,8 +48,8 @@ func (u BaseUnmarshalTester) Validate() error { return nil } -func (u BaseUnmarshalTester) Attestation() (string, []byte) { - return "", nil +func (u BaseUnmarshalTester) Attestation() []byte { + return nil } func (u BaseUnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ ArtifactProperties) (models.ProposedEntry, error) { diff --git a/pkg/types/tuf/v0.0.1/entry.go b/pkg/types/tuf/v0.0.1/entry.go index 40204937559b6d112a8f066fddff2f69b93a390a..9820463893d53786e33bda734d1fcfd482e66862 100644 --- a/pkg/types/tuf/v0.0.1/entry.go +++ b/pkg/types/tuf/v0.0.1/entry.go @@ -313,8 +313,8 @@ func (v V001Entry) Validate() error { return nil } -func (v *V001Entry) Attestation() (string, []byte) { - return "", nil +func (v *V001Entry) Attestation() []byte { + return nil } func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) {