Skip to content
Snippets Groups Projects
Unverified Commit 12d1a47c authored by dlorenc's avatar dlorenc Committed by GitHub
Browse files

Remove the attestation media type field. (#565)


This was never actually correct - these are technically "payloadTypes", which are
not actually mediaTypes. Some implementations mistakenly sent incorrect media types, so
it appeared to work. The GCS storage layer rejected correct implementations that sent the
payloadType, because these are not valid mediaTypes.

We never used this field anyway, so let's drop it. I verified that the API correctly ignores
unknown fields, so removing this will not break clients that send it.

Signed-off-by: default avatarDan Lorenc <lorenc.d@gmail.com>
parent 47486c21
No related branches found
No related tags found
No related merge requests found
Showing
with 40 additions and 62 deletions
...@@ -159,7 +159,6 @@ func parseEntry(uuid string, e models.LogEntryAnon) (interface{}, error) { ...@@ -159,7 +159,6 @@ func parseEntry(uuid string, e models.LogEntryAnon) (interface{}, error) {
if e.Attestation != nil { if e.Attestation != nil {
obj.Attestation = string(e.Attestation.Data) obj.Attestation = string(e.Attestation.Data)
obj.AttestationType = e.Attestation.MediaType
} }
return &obj, nil return &obj, nil
......
...@@ -468,9 +468,7 @@ definitions: ...@@ -468,9 +468,7 @@ definitions:
type: object type: object
properties: properties:
data: data:
format: byte format: byte
mediaType:
format: string
format: byte format: byte
verification: verification:
......
...@@ -94,13 +94,12 @@ func logEntryFromLeaf(ctx context.Context, signer signature.Signer, tc TrillianC ...@@ -94,13 +94,12 @@ func logEntryFromLeaf(ctx context.Context, signer signature.Signer, tc TrillianC
uuid := hex.EncodeToString(leaf.MerkleLeafHash) uuid := hex.EncodeToString(leaf.MerkleLeafHash)
if viper.GetBool("enable_attestation_storage") { if viper.GetBool("enable_attestation_storage") {
att, typ, err := storageClient.FetchAttestation(ctx, uuid) att, err := storageClient.FetchAttestation(ctx, uuid)
if err != nil { if err != nil {
log.Logger.Errorf("error fetching attestation: %s %s", uuid, err) log.Logger.Errorf("error fetching attestation: %s %s", uuid, err)
} else { } else {
logEntryAnon.Attestation = &models.LogEntryAnonAttestation{ logEntryAnon.Attestation = &models.LogEntryAnonAttestation{
Data: att, Data: att,
MediaType: typ,
} }
} }
} }
...@@ -210,12 +209,12 @@ func createLogEntry(params entries.CreateLogEntryParams) (models.LogEntry, middl ...@@ -210,12 +209,12 @@ func createLogEntry(params entries.CreateLogEntryParams) (models.LogEntry, middl
if viper.GetBool("enable_attestation_storage") { if viper.GetBool("enable_attestation_storage") {
go func() { go func() {
typ, attestation := entry.Attestation() attestation := entry.Attestation()
if typ == "" { if attestation == nil {
log.RequestIDLogger(params.HTTPRequest).Infof("no attestation for %s", uuid) log.RequestIDLogger(params.HTTPRequest).Infof("no attestation for %s", uuid)
return 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) log.RequestIDLogger(params.HTTPRequest).Errorf("error storing attestation: %s", err)
} }
}() }()
......
...@@ -96,6 +96,6 @@ func addToIndex(ctx context.Context, key, value string) error { ...@@ -96,6 +96,6 @@ func addToIndex(ctx context.Context, key, value string) error {
return redisClient.Do(ctx, radix.Cmd(nil, "LPUSH", key, value)) return redisClient.Do(ctx, radix.Cmd(nil, "LPUSH", key, value))
} }
func storeAttestation(ctx context.Context, uuid, attestationType string, attestation []byte) error { func storeAttestation(ctx context.Context, uuid string, attestation []byte) error {
return storageClient.StoreAttestation(ctx, uuid, attestationType, attestation) return storageClient.StoreAttestation(ctx, uuid, attestation)
} }
...@@ -300,9 +300,6 @@ type LogEntryAnonAttestation struct { ...@@ -300,9 +300,6 @@ type LogEntryAnonAttestation struct {
// data // data
// Format: byte // Format: byte
Data strfmt.Base64 `json:"data,omitempty"` Data strfmt.Base64 `json:"data,omitempty"`
// media type
MediaType string `json:"mediaType,omitempty"`
} }
// Validate validates this log entry anon attestation // Validate validates this log entry anon attestation
......
...@@ -498,9 +498,6 @@ func init() { ...@@ -498,9 +498,6 @@ func init() {
"properties": { "properties": {
"data": { "data": {
"format": "byte" "format": "byte"
},
"mediaType": {
"format": "string"
} }
} }
}, },
...@@ -1982,9 +1979,6 @@ func init() { ...@@ -1982,9 +1979,6 @@ func init() {
"properties": { "properties": {
"data": { "data": {
"format": "byte" "format": "byte"
},
"mediaType": {
"format": "string"
} }
} }
}, },
...@@ -2025,9 +2019,6 @@ func init() { ...@@ -2025,9 +2019,6 @@ func init() {
"properties": { "properties": {
"data": { "data": {
"format": "byte" "format": "byte"
},
"mediaType": {
"format": "string"
} }
} }
}, },
......
...@@ -31,8 +31,8 @@ import ( ...@@ -31,8 +31,8 @@ import (
) )
type AttestationStorage interface { type AttestationStorage interface {
StoreAttestation(ctx context.Context, key string, attestationType string, attestation []byte) error StoreAttestation(ctx context.Context, key string, attestation []byte) error
FetchAttestation(ctx context.Context, key string) ([]byte, string, error) FetchAttestation(ctx context.Context, key string) ([]byte, error)
} }
func NewAttestationStorage() (AttestationStorage, error) { func NewAttestationStorage() (AttestationStorage, error) {
...@@ -53,11 +53,9 @@ type Blob struct { ...@@ -53,11 +53,9 @@ type Blob struct {
bucket *blob.Bucket bucket *blob.Bucket
} }
func (b *Blob) StoreAttestation(ctx context.Context, key, attestationType string, attestation []byte) error { func (b *Blob) StoreAttestation(ctx context.Context, key string, attestation []byte) error {
log.Logger.Infof("storing attestation of type %s at %s", attestationType, key) log.Logger.Infof("storing attestation at %s", key)
w, err := b.bucket.NewWriter(ctx, key, &blob.WriterOptions{ w, err := b.bucket.NewWriter(ctx, key, nil)
ContentType: attestationType,
})
if err != nil { if err != nil {
return err return err
} }
...@@ -67,23 +65,19 @@ func (b *Blob) StoreAttestation(ctx context.Context, key, attestationType string ...@@ -67,23 +65,19 @@ func (b *Blob) StoreAttestation(ctx context.Context, key, attestationType string
return w.Close() 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) log.Logger.Infof("fetching attestation %s", key)
exists, err := b.bucket.Exists(ctx, key) exists, err := b.bucket.Exists(ctx, key)
if err != nil { if err != nil {
return nil, "", err return nil, err
} }
if !exists { if !exists {
return nil, "", nil return nil, nil
}
att, err := b.bucket.Attributes(ctx, key)
if err != nil {
return nil, "", err
} }
data, err := b.bucket.ReadAll(ctx, key) data, err := b.bucket.ReadAll(ctx, key)
if err != nil { if err != nil {
return nil, "", err return nil, err
} }
return data, att.ContentType, nil return data, nil
} }
...@@ -300,8 +300,8 @@ func (v V001Entry) validate() error { ...@@ -300,8 +300,8 @@ func (v V001Entry) validate() error {
return nil return nil
} }
func (v V001Entry) Attestation() (string, []byte) { func (v V001Entry) Attestation() []byte {
return "", nil return nil
} }
func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) {
......
...@@ -35,7 +35,7 @@ type EntryImpl interface { ...@@ -35,7 +35,7 @@ type EntryImpl interface {
IndexKeys() ([]string, error) // the keys that should be added to the external index for this entry 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 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 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) CreateFromArtifactProperties(context.Context, ArtifactProperties) (models.ProposedEntry, error)
} }
......
...@@ -182,8 +182,8 @@ func (v *V001Entry) validate() (pki.Signature, pki.PublicKey, error) { ...@@ -182,8 +182,8 @@ func (v *V001Entry) validate() (pki.Signature, pki.PublicKey, error) {
return sigObj, keyObj, nil return sigObj, keyObj, nil
} }
func (v V001Entry) Attestation() (string, []byte) { func (v V001Entry) Attestation() []byte {
return "", nil return nil
} }
func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) {
......
...@@ -299,8 +299,8 @@ func (v V001Entry) validate() error { ...@@ -299,8 +299,8 @@ func (v V001Entry) validate() error {
return nil return nil
} }
func (v V001Entry) Attestation() (string, []byte) { func (v V001Entry) Attestation() []byte {
return "", nil return nil
} }
func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) {
......
...@@ -193,12 +193,12 @@ func (v *V001Entry) validate() error { ...@@ -193,12 +193,12 @@ func (v *V001Entry) validate() error {
return nil return nil
} }
func (v *V001Entry) Attestation() (string, []byte) { func (v *V001Entry) Attestation() []byte {
if len(v.env.Payload) > viper.GetInt("max_attestation_size") { 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")) 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 { type verifier struct {
......
...@@ -290,8 +290,8 @@ func extractPKCS7SignatureFromJAR(inz *zip.Reader) ([]byte, error) { ...@@ -290,8 +290,8 @@ func extractPKCS7SignatureFromJAR(inz *zip.Reader) ([]byte, error) {
return nil, errors.New("unable to locate signature in JAR file") return nil, errors.New("unable to locate signature in JAR file")
} }
func (v V001Entry) Attestation() (string, []byte) { func (v V001Entry) Attestation() []byte {
return "", nil return nil
} }
func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) {
......
...@@ -353,8 +353,8 @@ func (v V001Entry) validate() error { ...@@ -353,8 +353,8 @@ func (v V001Entry) validate() error {
return nil return nil
} }
func (v V001Entry) Attestation() (string, []byte) { func (v V001Entry) Attestation() []byte {
return "", nil return nil
} }
func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) {
......
...@@ -173,8 +173,8 @@ func (v V001Entry) validate() error { ...@@ -173,8 +173,8 @@ func (v V001Entry) validate() error {
return nil return nil
} }
func (v V001Entry) Attestation() (string, []byte) { func (v V001Entry) Attestation() []byte {
return "", nil return nil
} }
func (v V001Entry) CreateFromArtifactProperties(_ context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { func (v V001Entry) CreateFromArtifactProperties(_ context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) {
......
...@@ -321,8 +321,8 @@ func (v V001Entry) validate() error { ...@@ -321,8 +321,8 @@ func (v V001Entry) validate() error {
return nil return nil
} }
func (v V001Entry) Attestation() (string, []byte) { func (v V001Entry) Attestation() []byte {
return "", nil return nil
} }
func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) {
......
...@@ -48,8 +48,8 @@ func (u BaseUnmarshalTester) Validate() error { ...@@ -48,8 +48,8 @@ func (u BaseUnmarshalTester) Validate() error {
return nil return nil
} }
func (u BaseUnmarshalTester) Attestation() (string, []byte) { func (u BaseUnmarshalTester) Attestation() []byte {
return "", nil return nil
} }
func (u BaseUnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ ArtifactProperties) (models.ProposedEntry, error) { func (u BaseUnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ ArtifactProperties) (models.ProposedEntry, error) {
......
...@@ -313,8 +313,8 @@ func (v V001Entry) Validate() error { ...@@ -313,8 +313,8 @@ func (v V001Entry) Validate() error {
return nil return nil
} }
func (v *V001Entry) Attestation() (string, []byte) { func (v *V001Entry) Attestation() []byte {
return "", nil return nil
} }
func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) { func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment