Skip to content

Commit 73a6cbc

Browse files
anjannathpraveenkumar
authored andcommitted
Verify default bundles downloaded from mirror.openshift.com
this removes the hardcoded hashes for each bundle and instead directly gets the bundle hash from the sha256sum.txt.sig file at mirror.openshift.com by using the helper from the previous commit which returns gpg verified hash for the default bundle
1 parent da7cedd commit 73a6cbc

File tree

4 files changed

+12
-87
lines changed

4 files changed

+12
-87
lines changed

pkg/crc/constants/constants.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ func GetDefaultBundlePath(preset crcpreset.Preset) string {
116116
return filepath.Join(MachineCacheDir, GetDefaultBundle(preset))
117117
}
118118

119+
func GetDefaultBundleDownloadURL(preset crcpreset.Preset) string {
120+
return fmt.Sprintf(DefaultBundleURLBase,
121+
preset.String(),
122+
version.GetBundleVersion(preset),
123+
GetDefaultBundle(preset),
124+
)
125+
}
126+
119127
func GetDefaultBundleSignedHashURL(preset crcpreset.Preset) string {
120128
return fmt.Sprintf(DefaultBundleURLBase,
121129
preset.String(),

pkg/crc/machine/bundle/constants.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

pkg/crc/machine/bundle/constants_test.go

Lines changed: 0 additions & 34 deletions
This file was deleted.

pkg/crc/machine/bundle/metadata.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"path"
1010
"path/filepath"
1111
"regexp"
12-
"runtime"
1312
"strconv"
1413
"strings"
1514
"time"
@@ -286,23 +285,12 @@ func GetBundleNameFromURI(bundleURI string) string {
286285
}
287286
}
288287

289-
type presetDownloadInfo map[crcPreset.Preset]*download.RemoteFile
290-
type bundlesDownloadInfo map[string]presetDownloadInfo
291-
292288
func getBundleDownloadInfo(preset crcPreset.Preset) (*download.RemoteFile, error) {
293-
bundles, ok := bundleLocations[runtime.GOARCH]
294-
if !ok {
295-
return nil, fmt.Errorf("Unsupported architecture: %s", runtime.GOARCH)
296-
}
297-
presetdownloadInfo, ok := bundles[runtime.GOOS]
298-
if !ok {
299-
return nil, fmt.Errorf("Unknown GOOS: %s", runtime.GOOS)
300-
}
301-
downloadInfo, ok := presetdownloadInfo[preset]
302-
if !ok {
303-
return nil, fmt.Errorf("Unknown preset: %s", preset)
289+
sha256sum, err := getDefaultBundleVerifiedHash(preset)
290+
if err != nil {
291+
return nil, fmt.Errorf("unable to get verified hash for default bundle: %w", err)
304292
}
305-
293+
downloadInfo := download.NewRemoteFile(constants.GetDefaultBundleDownloadURL(preset), sha256sum)
306294
return downloadInfo, nil
307295
}
308296

0 commit comments

Comments
 (0)