Skip to content

Commit

Permalink
Fix VerifySignature command json marshaling (#188)
Browse files Browse the repository at this point in the history
Temporary fix for
notaryproject/notation-core-go#88

Signed-off-by: rgnote <5878554+rgnote@users.noreply.github.com>
  • Loading branch information
rgnote authored Nov 9, 2022
1 parent a44d663 commit 49ba3a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,18 @@ type VerifySignatureRequest struct {
// Signature represents a signature pulled from the envelope
type Signature struct {
CriticalAttributes CriticalAttributes `json:"criticalAttributes"`
UnprocessedAttributes []interface{} `json:"unprocessedAttributes"`
UnprocessedAttributes []string `json:"unprocessedAttributes"`
CertificateChain [][]byte `json:"certificateChain"`
}

// CriticalAttributes contains all Notary V2 defined critical
// attributes and their values in the signature envelope
type CriticalAttributes struct {
ContentType string `json:"contentType"`
SigningScheme string `json:"signingScheme"`
Expiry *time.Time `json:"expiry,omitempty"`
AuthenticSigningTime *time.Time `json:"authenticSigningTime,omitempty"`
ExtendedAttributes map[interface{}]interface{} `json:"extendedAttributes,omitempty"`
ContentType string `json:"contentType"`
SigningScheme string `json:"signingScheme"`
Expiry *time.Time `json:"expiry,omitempty"`
AuthenticSigningTime *time.Time `json:"authenticSigningTime,omitempty"`
ExtendedAttributes map[string]interface{} `json:"extendedAttributes,omitempty"`
}

// TrustPolicy represents trusted identities that sign the artifacts
Expand Down
14 changes: 7 additions & 7 deletions verification/verifier_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ func (v *Verifier) executePlugin(ctx context.Context, trustPolicy *TrustPolicy,
if err != nil {
return nil, err
}
var attributesToProcess []interface{}
extendedAttributes := make(map[interface{}]interface{})
var attributesToProcess []string
extendedAttributes := make(map[string]interface{})

for _, attr := range getNonPluginExtendedCriticalAttributes(signerInfo) {
extendedAttributes[attr.Key] = attr.Value
attributesToProcess = append(attributesToProcess, attr.Key)
extendedAttributes[attr.Key.(string)] = attr.Value
attributesToProcess = append(attributesToProcess, attr.Key.(string))
}

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

0 comments on commit 49ba3a3

Please sign in to comment.