Skip to content

Commit 49ba3a3

Browse files
authored
Fix VerifySignature command json marshaling (#188)
Temporary fix for notaryproject/notation-core-go#88 Signed-off-by: rgnote <[email protected]>
1 parent a44d663 commit 49ba3a3

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

plugin/plugin.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,18 @@ type VerifySignatureRequest struct {
185185
// Signature represents a signature pulled from the envelope
186186
type Signature struct {
187187
CriticalAttributes CriticalAttributes `json:"criticalAttributes"`
188-
UnprocessedAttributes []interface{} `json:"unprocessedAttributes"`
188+
UnprocessedAttributes []string `json:"unprocessedAttributes"`
189189
CertificateChain [][]byte `json:"certificateChain"`
190190
}
191191

192192
// CriticalAttributes contains all Notary V2 defined critical
193193
// attributes and their values in the signature envelope
194194
type CriticalAttributes struct {
195-
ContentType string `json:"contentType"`
196-
SigningScheme string `json:"signingScheme"`
197-
Expiry *time.Time `json:"expiry,omitempty"`
198-
AuthenticSigningTime *time.Time `json:"authenticSigningTime,omitempty"`
199-
ExtendedAttributes map[interface{}]interface{} `json:"extendedAttributes,omitempty"`
195+
ContentType string `json:"contentType"`
196+
SigningScheme string `json:"signingScheme"`
197+
Expiry *time.Time `json:"expiry,omitempty"`
198+
AuthenticSigningTime *time.Time `json:"authenticSigningTime,omitempty"`
199+
ExtendedAttributes map[string]interface{} `json:"extendedAttributes,omitempty"`
200200
}
201201

202202
// TrustPolicy represents trusted identities that sign the artifacts

verification/verifier_helpers.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,12 @@ func (v *Verifier) executePlugin(ctx context.Context, trustPolicy *TrustPolicy,
253253
if err != nil {
254254
return nil, err
255255
}
256-
var attributesToProcess []interface{}
257-
extendedAttributes := make(map[interface{}]interface{})
256+
var attributesToProcess []string
257+
extendedAttributes := make(map[string]interface{})
258258

259259
for _, attr := range getNonPluginExtendedCriticalAttributes(signerInfo) {
260-
extendedAttributes[attr.Key] = attr.Value
261-
attributesToProcess = append(attributesToProcess, attr.Key)
260+
extendedAttributes[attr.Key.(string)] = attr.Value
261+
attributesToProcess = append(attributesToProcess, attr.Key.(string))
262262
}
263263

264264
var certChain [][]byte
@@ -316,10 +316,10 @@ func getNonPluginExtendedCriticalAttributes(signerInfo *signature.SignerInfo) []
316316
var criticalExtendedAttrs []signature.Attribute
317317
for _, attr := range signerInfo.SignedAttributes.ExtendedAttributes {
318318
attrStrKey, ok := attr.Key.(string)
319-
if ok && isPresent(attrStrKey, VerificationPluginHeaders) { // filter the plugin extended attributes
320-
continue
319+
if ok && !isPresent(attrStrKey, VerificationPluginHeaders) { // filter the plugin extended attributes
320+
// TODO support other attribute types (COSE attribute keys can be numbers)
321+
criticalExtendedAttrs = append(criticalExtendedAttrs, attr)
321322
}
322-
criticalExtendedAttrs = append(criticalExtendedAttrs, attr)
323323
}
324324
return criticalExtendedAttrs
325325
}

0 commit comments

Comments
 (0)