Skip to content

Commit

Permalink
fix: resolve comments
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <junjiegao@microsoft.com>
  • Loading branch information
JeyJeyGao committed Dec 2, 2022
1 parent eabcdf4 commit 148a7d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
13 changes: 7 additions & 6 deletions notation.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ func Sign(ctx context.Context, signer Signer, repo registry.Repository, opts Sig
if err != nil {
return ocispec.Descriptor{}, err
}
logger.Debug("generate annotation")
logger.Debug("generating annotation")
annotations, err := generateAnnotations(signerInfo)
if err != nil {
return ocispec.Descriptor{}, err
}
logger.Debugf("push signature, artifact descriptor: %+v, annotations: %+v", targetDesc, annotations)
logger.Debugf("generated annotations: %+v", annotations)
logger.Debugf("pushing signature of artifact descriptor: %+v", targetDesc)
_, _, err = repo.PushSignature(ctx, opts.SignatureMediaType, sig, targetDesc, annotations)
if err != nil {
return ocispec.Descriptor{}, err
Expand Down Expand Up @@ -193,7 +194,7 @@ func Verify(ctx context.Context, verifier Verifier, repo registry.Repository, re
}

// passing nil signature to check 'skip'
logger.Info("passing a nil signature to check 'skip' level")
logger.Info("Checking whether signature verification should be skipped or not")
outcome, err := verifier.Verify(ctx, ocispec.Descriptor{}, nil, opts)
if err != nil {
if outcome == nil {
Expand All @@ -203,7 +204,7 @@ func Verify(ctx context.Context, verifier Verifier, repo registry.Repository, re
logger.Infoln("verification skipped for", remoteOpts.ArtifactReference)
return ocispec.Descriptor{}, []*VerificationOutcome{outcome}, nil
}
logger.Info("check over. not 'skip' level")
logger.Info("Trust policy is not configured to skip signature verification")

// check MaxSignatureAttempts
if remoteOpts.MaxSignatureAttempts <= 0 {
Expand Down Expand Up @@ -234,7 +235,7 @@ func Verify(ctx context.Context, verifier Verifier, repo registry.Repository, re
numOfSignatureProcessed := 0

// get signature manifests
logger.Debug("fetch signature manifest")
logger.Debug("fetching signature manifest")
err = repo.ListSignatures(ctx, artifactDescriptor, func(signatureManifests []ocispec.Descriptor) error {
// process signatures
for _, sigManifestDesc := range signatureManifests {
Expand Down Expand Up @@ -263,7 +264,7 @@ func Verify(ctx context.Context, verifier Verifier, repo registry.Repository, re
// at this point, the signature is verified successfully. Add
// it to the verificationOutcomes.
verificationOutcomes = append(verificationOutcomes, outcome)
logger.Debugf("successfully verified signature with digest %v", sigManifestDesc.Digest)
logger.Debugf("Signature verification succeeded for signature with digest %v", sigManifestDesc.Digest)

// early break on success
return errDoneVerification
Expand Down
7 changes: 3 additions & 4 deletions signer/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ func NewFromPlugin(plugin plugin.Plugin, keyID string, pluginConfig map[string]s
// marshalled envelope.
func (s *pluginSigner) Sign(ctx context.Context, desc ocispec.Descriptor, opts notation.SignOptions) ([]byte, *signature.SignerInfo, error) {
logger := log.GetLogger(ctx)
logger.Debugf("plugin signing for %v", desc.Digest)

logger.Debugf("invoking plugin's get-plugin-metadata command")
req := &proto.GetMetadataRequest{
PluginConfig: s.mergeConfig(opts.PluginConfig),
}
Expand All @@ -58,7 +57,7 @@ func (s *pluginSigner) Sign(ctx context.Context, desc ocispec.Descriptor, opts n
return nil, nil, err
}

logger.Debugf("plugin %v with capabilities %v", metadata.Name, metadata.Capabilities)
logger.Debugf("using plugin %v with capabilities %v to sign artifact %v", metadata.Name, metadata.Capabilities, desc.Digest)
if metadata.HasCapability(proto.CapabilitySignatureGenerator) {
return s.generateSignature(ctx, desc, opts)
} else if metadata.HasCapability(proto.CapabilityEnvelopeGenerator) {
Expand Down Expand Up @@ -130,7 +129,7 @@ func (s *pluginSigner) generateSignatureEnvelope(ctx context.Context, desc ocisp
)
}

logger.Debug("verify signature envelope generated by plugin")
logger.Debug("verifying signature envelope generated by the plugin")
sigEnv, err := signature.ParseEnvelope(opts.SignatureMediaType, resp.SignatureEnvelope)
if err != nil {
return nil, nil, err
Expand Down
2 changes: 1 addition & 1 deletion signer/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ func (s *genericSigner) Sign(ctx context.Context, desc ocispec.Descriptor, opts
logger.Debugf("sign request:")
logger.Debugf(" ContentType: %v", signReq.Payload.ContentType)
logger.Debugf(" Content: %s", string(signReq.Payload.Content))
logger.Debugf(" Expiry: %v", signReq.Expiry)
logger.Debugf(" SigningTime: %v", signReq.SigningTime)
logger.Debugf(" Expiry: %v", signReq.Expiry)
logger.Debugf(" SigningScheme: %v", signReq.SigningScheme)
logger.Debugf(" SigningAgent: %v", signReq.SigningAgent)

Expand Down

0 comments on commit 148a7d6

Please sign in to comment.