Debian Codegraph @

cmd/verify.go

raw symbols SCIP
1 package cmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/"
5 "osscip-go gomod github.com/golang/go/src go1.24.0 os/"
6
7 intotoscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/ "github.com/in-toto/in-toto-golang/in_totoscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/"
8 "github.com/spf13/cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/"
9 )
10
11 var (
12 pubKeyPathsscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/pubKeyPaths. []string
13 linkDirscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/linkDir. string
14 intermediatePathsscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/intermediatePaths. []string
15 )
16
17 var verifyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/verifyCmd. = &cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#{
18 Usescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Use.: "verify",
19 Shortscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Short.: "Verify that the software supply chain of the delivered product",
20 Longscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Long.: `in-toto-verify is the main verification tool of the suite, and
21 it is used to verify that the software supply chain of the delivered
22 product was carried out as defined in the passed in-toto supply chain
23 layout. Evidence for supply chain steps must be available in the form
24 of link metadata files named ‘<step name>.<functionary keyid prefix>.link’.`,
25 RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE.: verifyscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/verify().,
26 }
27
28 func initscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/init().() {
29 rootCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/rootCmd..AddCommandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#AddCommand().(verifyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/verifyCmd.)
30
31 verifyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/verifyCmd..Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringVarPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringVarP().(
32 &layoutPathscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/layoutPath.,
33 "layout",
34 "l",
35 "",
36 `Path to root layout specifying the software supply chain to be verified`,
37 )
38
39 verifyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/verifyCmd..Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringSliceVarPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringSliceVarP().(
40 &pubKeyPathsscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/pubKeyPaths.,
41 "layout-keys",
42 "k",
43 []string{},
44 `Path(s) to PEM formatted public key(s), used to verify the passed
45 root layout's signature(s). Passing at least one key using
46 '--layout-keys' is required. For each passed key the layout
47 must carry a valid signature.`,
48 )
49
50 verifyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/verifyCmd..Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringVarPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringVarP().(
51 &linkDirscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/linkDir.,
52 "link-dir",
53 "d",
54 "",
55 `Path to directory where link metadata files for steps defined in
56 the root layout should be loaded from. If not passed links are
57 loaded from the current working directory.`,
58 )
59
60 verifyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/verifyCmd..Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringSliceVarPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringSliceVarP().(
61 &intermediatePathsscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/intermediatePaths.,
62 "intermediate-certs",
63 "i",
64 []string{},
65 `Path(s) to PEM formatted certificates, used as intermediaries to verify
66 the chain of trust to the layout's trusted root. These will be used in
67 addition to any intermediates in the layout.`,
68 )
69
70 verifyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/verifyCmd..MarkFlagRequiredscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#MarkFlagRequired().("layout")
71 verifyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/verifyCmd..MarkFlagRequiredscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#MarkFlagRequired().("layout-keys")
72
73 verifyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/verifyCmd..Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolVarscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolVar().(
74 &lineNormalizationscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/lineNormalization.,
75 "normalize-line-endings",
76 false,
77 `Enable line normalization in order to support different
78 operating systems. It is done by replacing all line separators
79 with a new line character.`,
80 )
81 }
82
83 func verifyscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/verify().(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#, args []string) error {
84 layoutMb, err := intotoscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/.LoadMetadatascip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/LoadMetadata().(layoutPathscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/layoutPath.)
85 if err != nil {
86 return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("failed to load layout at %s: %w", layoutPathscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/layoutPath., err)
87 }
88
89 layoutKeys := make(map[string]intotoscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/.Keyscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/Key#, len(pubKeyPathsscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/pubKeyPaths.))
90
91 for _, pubKeyPath := range pubKeyPathsscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/pubKeyPaths. {
92 var pubKey intotoscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/.Keyscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/Key#
93
94 if err := pubKey.LoadKeyDefaultsscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/Key#LoadKeyDefaults().(pubKeyPath); err != nil {
95 return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("invalid key at %s: %w", pubKeyPath, err)
96 }
97
98 layoutKeys[pubKey.KeyIDscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/Key#KeyID.] = pubKey
99 }
100
101 intermediatePems := make([][]byte, 0, len(intermediatePathsscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/intermediatePaths.))
102 for _, intermediate := range intermediatePathsscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/intermediatePaths. {
103 pemBytes, err := osscip-go gomod github.com/golang/go/src go1.24.0 os/.ReadFilescip-go gomod github.com/golang/go/src go1.24.0 os/ReadFile().(intermediate)
104 if err != nil {
105 return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("failed to read intermediate %s: %w", intermediate, err)
106 }
107
108 intermediatePems = append(intermediatePems, pemBytes)
109 }
110
111 _, err = intotoscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/.InTotoVerifyscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/InTotoVerify().(layoutMb, layoutKeys, linkDirscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/linkDir., "", make(map[string]string), intermediatePems, lineNormalizationscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/lineNormalization.)
112 if err != nil {
113 return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("inspection failed: %w", err)
114 }
115
116 return nil
117 }