MCPcopy Create free account
hub / github.com/containerd/nerdctl / VerifyNotation

Function VerifyNotation

pkg/signutil/notationutil.go:62–98  ·  view source on GitHub ↗

VerifyNotation verifies an image(`rawRef`) with the pre-configured notation trust policy `hostsDirs` are used to resolve image `rawRef`

(ctx context.Context, rawRef string, hostsDirs []string)

Source from the content-addressed store, hash-verified

60// VerifyNotation verifies an image(`rawRef`) with the pre-configured notation trust policy
61// `hostsDirs` are used to resolve image `rawRef`
62func VerifyNotation(ctx context.Context, rawRef string, hostsDirs []string) (string, error) {
63 digest, err := imgutil.ResolveDigest(ctx, rawRef, false, hostsDirs)
64 if err != nil {
65 log.G(ctx).WithError(err).Errorf("unable to resolve digest for an image %s: %v", rawRef, err)
66 return rawRef, err
67 }
68 ref := rawRef
69 if !strings.Contains(ref, "@") {
70 ref += "@" + digest
71 }
72
73 log.G(ctx).Debugf("verifying image: %s", ref)
74
75 notationExecutable, err := exec.LookPath("notation")
76 if err != nil {
77 log.G(ctx).WithError(err).Error("notation executable not found in path $PATH")
78 log.G(ctx).Info("you might consider installing notation from: https://notaryproject.dev/docs/installation/cli/")
79 return ref, err
80 }
81
82 notationCmd := exec.Command(notationExecutable, []string{"verify"}...)
83 notationCmd.Env = os.Environ()
84
85 notationCmd.Args = append(notationCmd.Args, ref)
86
87 log.G(ctx).Debugf("running %s %v", notationExecutable, notationCmd.Args)
88
89 err = processNotationIO(notationCmd)
90 if err != nil {
91 return ref, err
92 }
93 if err := notationCmd.Wait(); err != nil {
94 return ref, err
95 }
96
97 return ref, nil
98}
99
100func processNotationIO(notationCmd *exec.Cmd) error {
101 stdout, err := notationCmd.StdoutPipe()

Callers 1

VerifyFunction · 0.85

Calls 6

ResolveDigestFunction · 0.92
processNotationIOFunction · 0.85
InfoMethod · 0.80
CommandMethod · 0.65
ErrorMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…