Skip to content

Commit

Permalink
fix: Add contract version to plugin sign request and plugin verify re…
Browse files Browse the repository at this point in the history
…quest (notaryproject#390)

Add contract version to plugin sign request and plugin verify request.
As per [specification](https://github.com/notaryproject/specifications/blob/main/specs/plugin-extensibility.md) `contractVersion` is a mandatory field.

Signed-off-by: Pritesh Bandi <[email protected]>
  • Loading branch information
priteshbandi authored Mar 21, 2024
1 parent e686d8b commit b8136e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
17 changes: 10 additions & 7 deletions signer/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func (s *PluginSigner) generateSignatureEnvelope(ctx context.Context, desc ocisp
}
// Execute plugin sign command.
req := &plugin.GenerateEnvelopeRequest{
ContractVersion: plugin.ContractVersion,
KeyID: s.keyID,
Payload: payloadBytes,
SignatureEnvelopeType: opts.SignatureMediaType,
Expand Down Expand Up @@ -247,8 +248,9 @@ func (s *PluginSigner) mergeConfig(config map[string]string) map[string]string {

func (s *PluginSigner) describeKey(ctx context.Context, config map[string]string) (*plugin.DescribeKeyResponse, error) {
req := &plugin.DescribeKeyRequest{
KeyID: s.keyID,
PluginConfig: config,
ContractVersion: plugin.ContractVersion,
KeyID: s.keyID,
PluginConfig: config,
}
resp, err := s.plugin.DescribeKey(ctx, req)
if err != nil {
Expand Down Expand Up @@ -344,11 +346,12 @@ func (s *pluginPrimitiveSigner) Sign(payload []byte) ([]byte, []*x509.Certificat
}

req := &plugin.GenerateSignatureRequest{
KeyID: s.keyID,
KeySpec: keySpec,
Hash: keySpecHash,
Payload: payload,
PluginConfig: s.pluginConfig,
ContractVersion: plugin.ContractVersion,
KeyID: s.keyID,
KeySpec: keySpec,
Hash: keySpecHash,
Payload: payload,
PluginConfig: s.pluginConfig,
}

resp, err := s.plugin.GenerateSignature(s.ctx, req)
Expand Down
7 changes: 4 additions & 3 deletions verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,10 @@ func executePlugin(ctx context.Context, installedPlugin pluginframework.VerifyPl
}

req := &pluginframework.VerifySignatureRequest{
Signature: signature,
TrustPolicy: policy,
PluginConfig: pluginConfig,
ContractVersion: pluginframework.ContractVersion,
Signature: signature,
TrustPolicy: policy,
PluginConfig: pluginConfig,
}
return installedPlugin.VerifySignature(ctx, req)
}
Expand Down

0 comments on commit b8136e2

Please sign in to comment.