Skip to content

Commit a2cf498

Browse files
authored
improve signature skipping (#447)
* improve signature skipping #445 * update README for #445 * avoid unnecessary download #445 * fix linter : use CommandContext Signed-off-by: Denis Vaumoron <dvaumoron@gmail.com>
1 parent 59e356c commit a2cf498

File tree

13 files changed

+121
-61
lines changed

13 files changed

+121
-61
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,15 @@ If set to true **tenv** disable tracking of last use date for installed versions
787787
</details>
788788

789789

790+
<details markdown="1"><summary><b>TENV_VALIDATION</b></summary><br>
791+
792+
String (Default: signature)
793+
794+
Set **tenv** validation, known values are "signature" (check SHA256 and its signature, see [signature support](#signature-support)), "sha" (only check SHA256), "none" (no validation).
795+
796+
</details>
797+
798+
790799
<details markdown="1"><summary><b>GITHUB_ACTIONS</b></summary><br>
791800

792801
String (Default: false)

cmd/tenv/subcmd.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func newDetectCmd(versionManager versionmanager.VersionManager, params subCmdPar
7676
descBuilder.WriteString(versionManager.FolderName)
7777
descBuilder.WriteString(" current version.")
7878

79+
skipSum, skipSign := false, false
7980
forceInstall, forceNoInstall := false, false
8081

8182
detectCmd := &cobra.Command{
@@ -102,7 +103,7 @@ func newDetectCmd(versionManager versionmanager.VersionManager, params subCmdPar
102103
}
103104

104105
flags := detectCmd.Flags()
105-
addInstallationFlags(flags, conf, params)
106+
addInstallationFlags(flags, conf, params, &skipSum, &skipSign)
106107
addOptionalInstallationFlags(flags, conf, params, &forceInstall, &forceNoInstall)
107108
addRemoteFlags(flags, conf, params)
108109

@@ -133,6 +134,8 @@ If a parameter is passed, available options:
133134
descBuilder.WriteString(versionManager.FolderName)
134135
descBuilder.WriteString(" files to detect which version is maximally allowed or minimally required")
135136

137+
skipSum, skipSign := false, false
138+
136139
installCmd := &cobra.Command{
137140
Use: "install [version]",
138141
Short: loghelper.Concat("Install a specific version of ", versionManager.FolderName, "."),
@@ -157,7 +160,7 @@ If a parameter is passed, available options:
157160
}
158161

159162
flags := installCmd.Flags()
160-
addInstallationFlags(flags, conf, params)
163+
addInstallationFlags(flags, conf, params, &skipSum, &skipSign)
161164
addRemoteFlags(flags, conf, params)
162165

163166
return installCmd
@@ -364,6 +367,7 @@ Available parameter options:
364367
descBuilder.WriteString(versionManager.FolderName)
365368
descBuilder.WriteString(" files to detect which version is maximally allowed or minimally required")
366369

370+
skipSum, skipSign := false, false
367371
forceInstall, forceNoInstall, workingDir := false, false, false
368372

369373
useCmd := &cobra.Command{
@@ -381,7 +385,7 @@ Available parameter options:
381385
}
382386

383387
flags := useCmd.Flags()
384-
addInstallationFlags(flags, conf, params)
388+
addInstallationFlags(flags, conf, params, &skipSum, &skipSign)
385389
addOptionalInstallationFlags(flags, conf, params, &forceInstall, &forceNoInstall)
386390
addRemoteFlags(flags, conf, params)
387391
flags.BoolVarP(&workingDir, "working-dir", "w", false, loghelper.Concat("create ", versionManager.VersionFiles[0].Name, " file in working directory"))
@@ -393,11 +397,12 @@ func addDescendingFlag(flags *pflag.FlagSet, pReverseOrder *bool) {
393397
flags.BoolVarP(pReverseOrder, "descending", "d", false, "display list in descending version order")
394398
}
395399

396-
func addInstallationFlags(flags *pflag.FlagSet, conf *config.Config, params subCmdParams) {
400+
func addInstallationFlags(flags *pflag.FlagSet, conf *config.Config, params subCmdParams, pSkipSum *bool, pSkipSign *bool) {
397401
flags.StringVarP(&conf.Arch, "arch", "a", conf.Arch, "specify arch for binaries downloading")
398402
if params.pPublicKeyPath != nil {
399403
flags.StringVarP(params.pPublicKeyPath, "key-file", "k", *params.pPublicKeyPath, "local path to PGP public key file (replace check against remote one)")
400-
flags.BoolVarP(&conf.SkipSignature, "skip-signature", "s", false, "skip signature checking")
404+
flags.BoolVar(pSkipSum, "skip-sha", false, "skip SHA256 checksum checking")
405+
flags.BoolVarP(pSkipSign, "skip-signature", "s", false, "skip signature checking")
401406
}
402407
}
403408

config/config.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,25 @@ const (
4545
defaultDirName = ".tenv"
4646
)
4747

48+
const (
49+
SignValidation ValidationMode = iota
50+
ShaValidation
51+
NoValidation
52+
)
53+
54+
type ValidationMode uint8
55+
56+
func ParseValidationMode(mode string) ValidationMode {
57+
switch mode {
58+
case "none":
59+
return NoValidation
60+
case "sha":
61+
return ShaValidation
62+
default:
63+
return SignValidation
64+
}
65+
}
66+
4867
type Config struct {
4968
Arch string
5069
Atmos RemoteConfig
@@ -59,14 +78,14 @@ type Config struct {
5978
RemoteConfPath string
6079
RootPath string
6180
SkipInstall bool
62-
SkipSignature bool
6381
Tf RemoteConfig
6482
TfKeyPathOrURL string
6583
Tg RemoteConfig
6684
Tm RemoteConfig
6785
Tofu RemoteConfig
6886
TofuKeyPathOrURL string
6987
UserPath string
88+
Validation ValidationMode
7089
WorkPath string
7190
}
7291

@@ -89,6 +108,7 @@ func DefaultConfig() (Config, error) {
89108
Tofu: makeDefaultRemoteConfig(tofuurl.Github, githuburl.Base),
90109
UserPath: userPath,
91110
WorkPath: ".",
111+
Validation: SignValidation,
92112
TfKeyPathOrURL: terraformurl.PublicKey,
93113
TofuKeyPathOrURL: tofuurl.PublicKey,
94114
}, nil
@@ -145,6 +165,7 @@ func InitConfigFromEnv() (Config, error) {
145165
Tofu: makeRemoteConfig(getenv, envname.TofuRemoteURL, envname.TofuListURL, envname.TofuInstallMode, envname.TofuListMode, tofuurl.Github, githuburl.Base),
146166
TofuKeyPathOrURL: getenv.WithDefault(tofuurl.PublicKey, envname.TofuOpenTofuPGPKey),
147167
UserPath: userPath,
168+
Validation: ParseValidationMode(getenv(envname.TenvValidation)),
148169
WorkPath: ".",
149170
}, nil
150171
}
@@ -174,6 +195,15 @@ func (conf *Config) InitDisplayer(proxyCall bool) {
174195
}
175196
}
176197

198+
func (conf *Config) InitValidation(skipSum bool, skipSign bool) {
199+
switch {
200+
case skipSum: // higher priority to --skip-sha
201+
conf.Validation = NoValidation
202+
case skipSign && conf.Validation != NoValidation:
203+
conf.Validation = ShaValidation
204+
}
205+
}
206+
177207
func (conf *Config) InitInstall(forceInstall bool, forceNoInstall bool) {
178208
switch {
179209
case forceNoInstall: // higher priority to --no-install

config/envname/env.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const (
5959
TenvRootPath = tenvPrefix + rootPath
6060
TenvSkipLastUse = tenvPrefix + "SKIP_LAST_USE"
6161
TenvToken = tenvPrefix + token
62+
TenvValidation = tenvPrefix + "VALIDATION"
6263

6364
TfenvPrefix = "TFENV_"
6465
TfenvTerraformPrefix = TfenvPrefix + "TERRAFORM_"

go.mod

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/hashicorp/hcl/v2 v2.24.0
1818
github.com/spf13/cobra v1.10.1
1919
github.com/spf13/pflag v1.0.10
20-
github.com/stretchr/testify v1.11.1
20+
github.com/stretchr/testify v1.10.0
2121
github.com/zclconf/go-cty v1.17.0
2222
gopkg.in/yaml.v3 v3.0.1
2323
)
@@ -30,7 +30,7 @@ require (
3030
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
3131
github.com/atotto/clipboard v0.1.4 // indirect
3232
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
33-
github.com/charmbracelet/colorprofile v0.3.1 // indirect
33+
github.com/charmbracelet/colorprofile v0.3.2 // indirect
3434
github.com/charmbracelet/x/ansi v0.10.1 // indirect
3535
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
3636
github.com/charmbracelet/x/term v0.2.1 // indirect
@@ -40,7 +40,7 @@ require (
4040
github.com/go-test/deep v1.1.0 // indirect
4141
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4242
github.com/kr/pretty v0.2.1 // indirect
43-
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
43+
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
4444
github.com/mattn/go-colorable v0.1.14 // indirect
4545
github.com/mattn/go-isatty v0.0.20 // indirect
4646
github.com/mattn/go-localereader v0.0.1 // indirect
@@ -54,12 +54,12 @@ require (
5454
github.com/rivo/uniseg v0.4.7 // indirect
5555
github.com/sahilm/fuzzy v0.1.1 // indirect
5656
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
57-
golang.org/x/crypto v0.39.0 // indirect
58-
golang.org/x/mod v0.25.0 // indirect
59-
golang.org/x/net v0.41.0 // indirect
60-
golang.org/x/sync v0.15.0 // indirect
57+
golang.org/x/crypto v0.42.0 // indirect
58+
golang.org/x/mod v0.28.0 // indirect
59+
golang.org/x/net v0.44.0 // indirect
60+
golang.org/x/sync v0.17.0 // indirect
6161
golang.org/x/sys v0.36.0 // indirect
62-
golang.org/x/text v0.26.0 // indirect
63-
golang.org/x/tools v0.34.0 // indirect
62+
golang.org/x/text v0.29.0 // indirect
63+
golang.org/x/tools v0.37.0 // indirect
6464
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
6565
)

go.sum

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u
2424
github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg=
2525
github.com/charmbracelet/bubbletea v1.3.9 h1:OBYdfRo6QnlIcXNmcoI2n1NNS65Nk6kI2L2FO1puS/4=
2626
github.com/charmbracelet/bubbletea v1.3.9/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
27-
github.com/charmbracelet/colorprofile v0.3.1 h1:k8dTHMd7fgw4bnFd7jXTLZrSU/CQrKnL3m+AxCzDz40=
28-
github.com/charmbracelet/colorprofile v0.3.1/go.mod h1:/GkGusxNs8VB/RSOh3fu0TJmQ4ICMMPApIIVn0KszZ0=
27+
github.com/charmbracelet/colorprofile v0.3.2 h1:9J27WdztfJQVAQKX2WOlSSRB+5gaKqqITmrvb1uTIiI=
28+
github.com/charmbracelet/colorprofile v0.3.2/go.mod h1:mTD5XzNeWHj8oqHb+S1bssQb7vIHbepiebQ2kPKVKbI=
2929
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
3030
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
3131
github.com/charmbracelet/x/ansi v0.10.1 h1:rL3Koar5XvX0pHGfovN03f5cxLbCF2YvLeyz7D2jVDQ=
@@ -67,8 +67,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
6767
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
6868
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
6969
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
70-
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
71-
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
70+
github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
71+
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
7272
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
7373
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
7474
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
@@ -107,8 +107,8 @@ github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
107107
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
108108
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
109109
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
110-
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
111-
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
110+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
111+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
112112
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
113113
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
114114
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
@@ -122,17 +122,17 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
122122
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
123123
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
124124
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
125-
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
126-
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
125+
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
126+
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
127127
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
128128
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
129129
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
130130
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
131131
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
132132
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
133133
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
134-
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
135-
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
134+
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
135+
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
136136
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
137137
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
138138
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
@@ -142,17 +142,17 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
142142
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
143143
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
144144
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
145-
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
146-
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
145+
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
146+
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
147147
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
148148
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
149149
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
150150
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
151151
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
152152
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
153153
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
154-
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
155-
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
154+
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
155+
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
156156
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
157157
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
158158
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -192,16 +192,16 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
192192
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
193193
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
194194
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
195-
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
196-
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
195+
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
196+
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
197197
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
198198
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
199199
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
200200
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
201201
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
202202
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
203-
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
204-
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
203+
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
204+
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
205205
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
206206
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
207207
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=

pkg/check/cosign/check.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package cosigncheck
2020

2121
import (
22+
"context"
2223
"errors"
2324
"os"
2425
"os/exec"
@@ -40,7 +41,7 @@ var (
4041
ErrNotInstalled = errors.New("cosign executable not found")
4142
)
4243

43-
func Check(data []byte, dataSig []byte, dataCert []byte, certIdentity string, certOidcIssuer string, displayer loghelper.Displayer) error {
44+
func Check(ctx context.Context, data []byte, dataSig []byte, dataCert []byte, certIdentity string, certOidcIssuer string, displayer loghelper.Displayer) error {
4445
_, err := exec.LookPath(cosignExecName)
4546
if err != nil {
4647
return ErrNotInstalled
@@ -70,7 +71,7 @@ func Check(data []byte, dataSig []byte, dataCert []byte, certIdentity string, ce
7071
}
7172

7273
var outBuffer, errBuffer strings.Builder
73-
cmd := exec.Command(cosignExecName, cmdArgs...)
74+
cmd := exec.CommandContext(ctx, cosignExecName, cmdArgs...)
7475
cmd.Stdout = &outBuffer
7576
cmd.Stderr = &errBuffer
7677

pkg/check/cosign/check_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,35 @@ var dataCert []byte
4646

4747
func TestCosignCheckCorrect(t *testing.T) { //nolint
4848
t.SkipNow()
49-
if err := cosigncheck.Check(data, dataSig, dataCert, identity, issuer, loghelper.InertDisplayer); err != nil {
49+
if err := cosigncheck.Check(t.Context(), data, dataSig, dataCert, identity, issuer, loghelper.InertDisplayer); err != nil {
5050
t.Error("Unexpected error :", err)
5151
}
5252
}
5353

5454
func TestCosignCheckErrorCert(t *testing.T) { //nolint
5555
t.SkipNow()
56-
if cosigncheck.Check(data, dataSig, dataCert[1:], identity, issuer, loghelper.InertDisplayer) == nil {
56+
if cosigncheck.Check(t.Context(), data, dataSig, dataCert[1:], identity, issuer, loghelper.InertDisplayer) == nil {
5757
t.Error("Should fail on erroneous certificate")
5858
}
5959
}
6060

6161
func TestCosignCheckErrorIdentity(t *testing.T) { //nolint
6262
t.SkipNow()
63-
if cosigncheck.Check(data, dataSig, dataCert, "me", issuer, loghelper.InertDisplayer) == nil {
63+
if cosigncheck.Check(t.Context(), data, dataSig, dataCert, "me", issuer, loghelper.InertDisplayer) == nil {
6464
t.Error("Should fail on erroneous issuer")
6565
}
6666
}
6767

6868
func TestCosignCheckErrorIssuer(t *testing.T) { //nolint
6969
t.SkipNow()
70-
if cosigncheck.Check(data, dataSig, dataCert, identity, "http://myself.com", loghelper.InertDisplayer) == nil {
70+
if cosigncheck.Check(t.Context(), data, dataSig, dataCert, identity, "http://myself.com", loghelper.InertDisplayer) == nil {
7171
t.Error("Should fail on erroneous issuer")
7272
}
7373
}
7474

7575
func TestCosignCheckErrorSig(t *testing.T) { //nolint
7676
t.SkipNow()
77-
if cosigncheck.Check(data, dataSig[1:], dataCert, identity, issuer, loghelper.InertDisplayer) == nil {
77+
if cosigncheck.Check(t.Context(), data, dataSig[1:], dataCert, identity, issuer, loghelper.InertDisplayer) == nil {
7878
t.Error("Should fail on erroneous signature")
7979
}
8080
}

versionmanager/retriever/atmos/atmosretriever.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ func (r AtmosRetriever) Install(ctx context.Context, versionStr string, targetPa
103103
return err
104104
}
105105

106-
dataSums, err := download.Bytes(ctx, assetURLs[1], r.conf.Displayer.Display, download.NoCheck, requestOptions...)
107-
if err != nil {
108-
return err
109-
}
106+
if r.conf.Validation != config.NoValidation {
107+
dataSums, err := download.Bytes(ctx, assetURLs[1], r.conf.Displayer.Display, download.NoCheck, requestOptions...)
108+
if err != nil {
109+
return err
110+
}
110111

111-
if err = sha256check.Check(data, dataSums, fileName); err != nil {
112-
return err
112+
if err = sha256check.Check(data, dataSums, fileName); err != nil {
113+
return err
114+
}
113115
}
114116

115117
err = os.MkdirAll(targetPath, rwePerm)

0 commit comments

Comments
 (0)