Skip to content

Commit 5ae174b

Browse files
authored
Merge pull request cli#11511 from cli/eugene/trusted_root_flag_for_release_verify
Hidden trusted root flag for release verify
2 parents f648924 + 7316ddc commit 5ae174b

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

pkg/cmd/release/shared/attestation.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ type Verifier interface {
2525
}
2626

2727
type AttestationVerifier struct {
28-
AttClient api.Client
29-
HttpClient *http.Client
30-
IO *iostreams.IOStreams
28+
AttClient api.Client
29+
HttpClient *http.Client
30+
IO *iostreams.IOStreams
31+
TrustedRoot string
3132
}
3233

3334
func (v *AttestationVerifier) VerifyAttestation(art *artifact.DigestedArtifact, att *api.Attestation) (*verification.AttestationProcessingResult, error) {
@@ -41,6 +42,7 @@ func (v *AttestationVerifier) VerifyAttestation(art *artifact.DigestedArtifact,
4142
Logger: att_io.NewHandler(v.IO),
4243
NoPublicGood: true,
4344
TrustDomain: td,
45+
TrustedRoot: v.TrustedRoot,
4446
})
4547
if err != nil {
4648
return nil, err

pkg/cmd/release/verify-asset/verify_asset.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type VerifyAssetOptions struct {
2424
BaseRepo ghrepo.Interface
2525
Exporter cmdutil.Exporter
2626
AssetFilePath string
27+
TrustedRoot string
2728
}
2829

2930
type VerifyAssetConfig struct {
@@ -93,9 +94,10 @@ func NewCmdVerifyAsset(f *cmdutil.Factory, runF func(*VerifyAssetConfig) error)
9394
attClient := api.NewLiveClient(httpClient, baseRepo.RepoHost(), att_io.NewHandler(io))
9495

9596
attVerifier := &shared.AttestationVerifier{
96-
AttClient: attClient,
97-
HttpClient: httpClient,
98-
IO: io,
97+
AttClient: attClient,
98+
HttpClient: httpClient,
99+
IO: io,
100+
TrustedRoot: opts.TrustedRoot,
99101
}
100102

101103
config := &VerifyAssetConfig{
@@ -114,6 +116,8 @@ func NewCmdVerifyAsset(f *cmdutil.Factory, runF func(*VerifyAssetConfig) error)
114116
},
115117
}
116118
cmdutil.AddFormatFlags(cmd, &opts.Exporter)
119+
cmd.Flags().StringVarP(&opts.TrustedRoot, "custom-trusted-root", "", "", "Path to a trusted_root.jsonl file; likely for offline verification.")
120+
cmd.Flags().MarkHidden("custom-trusted-root")
117121

118122
return cmd
119123
}

pkg/cmd/release/verify/verify.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ import (
2323
)
2424

2525
type VerifyOptions struct {
26-
TagName string
27-
BaseRepo ghrepo.Interface
28-
Exporter cmdutil.Exporter
26+
TagName string
27+
BaseRepo ghrepo.Interface
28+
Exporter cmdutil.Exporter
29+
TrustedRoot string
2930
}
3031

3132
type VerifyConfig struct {
@@ -87,9 +88,10 @@ func NewCmdVerify(f *cmdutil.Factory, runF func(config *VerifyConfig) error) *co
8788
attClient := api.NewLiveClient(httpClient, baseRepo.RepoHost(), att_io.NewHandler(io))
8889

8990
attVerifier := &shared.AttestationVerifier{
90-
AttClient: attClient,
91-
HttpClient: httpClient,
92-
IO: io,
91+
AttClient: attClient,
92+
HttpClient: httpClient,
93+
IO: io,
94+
TrustedRoot: opts.TrustedRoot,
9395
}
9496

9597
config := &VerifyConfig{
@@ -107,6 +109,8 @@ func NewCmdVerify(f *cmdutil.Factory, runF func(config *VerifyConfig) error) *co
107109
},
108110
}
109111
cmdutil.AddFormatFlags(cmd, &opts.Exporter)
112+
cmd.Flags().StringVarP(&opts.TrustedRoot, "custom-trusted-root", "", "", "Path to a trusted_root.jsonl file; likely for offline verification.")
113+
cmd.Flags().MarkHidden("custom-trusted-root")
110114

111115
return cmd
112116
}

0 commit comments

Comments
 (0)