From c9c6a9fd4f96f2373c6d217f1ea0be7fdaeda790 Mon Sep 17 00:00:00 2001 From: Kai Lueke Date: Wed, 30 Nov 2022 15:01:05 +0100 Subject: [PATCH] omaha: Write only SHA256 hash for extra files For extra files there is only one hash attribute but it was used for both a SHA1 and SHA256 entry in the Omaha response. On the wire and in the UI it's unclear which of the formats it should be. Since we use Omaha more in free style let's only set the SHA256 entry and expect the user to supply this hash in the UI. With a change in go-omaha we can also omit the empty regular SHA1 hash entry but in any case the client would be expected to know about the SHA256 attribute and use this instead. --- backend/pkg/omaha/omaha.go | 1 - backend/pkg/omaha/omaha_test.go | 2 +- frontend/src/components/Packages/FileList.tsx | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/pkg/omaha/omaha.go b/backend/pkg/omaha/omaha.go index ae3d17f4f..57bb71d67 100644 --- a/backend/pkg/omaha/omaha.go +++ b/backend/pkg/omaha/omaha.go @@ -220,7 +220,6 @@ func (h *Handler) prepareUpdateCheck(appResp *omahaSpec.AppResponse, pkg *api.Pa fpkg := manifest.AddPackage() fpkg.Name = pkgFile.Name.String if pkgFile.Hash.Valid { - fpkg.SHA1 = pkgFile.Hash.String fpkg.SHA256 = pkgFile.Hash.String } if pkgFile.Size.Valid && pkgFile.Size.String != "" { diff --git a/backend/pkg/omaha/omaha_test.go b/backend/pkg/omaha/omaha_test.go index 30c2a42d9..e74b2df58 100644 --- a/backend/pkg/omaha/omaha_test.go +++ b/backend/pkg/omaha/omaha_test.go @@ -329,7 +329,7 @@ func TestMultiPackageResponse(t *testing.T) { extraFile1Size, _ := strconv.ParseUint(extraFile1.Size.String, 10, 64) assert.Equal(t, extraFile1Size, shippedExtraFile1.Size) - assert.Equal(t, extraFile1.Hash.String, shippedExtraFile1.SHA1) + assert.Equal(t, extraFile1.Hash.String, shippedExtraFile1.SHA256) extraFile2 := extraFiles[1] shippedExtraFile2 := packages[2] diff --git a/frontend/src/components/Packages/FileList.tsx b/frontend/src/components/Packages/FileList.tsx index 8cc71ca47..7c052da4a 100644 --- a/frontend/src/components/Packages/FileList.tsx +++ b/frontend/src/components/Packages/FileList.tsx @@ -60,7 +60,7 @@ function FileListItem(props: FileListItemProps) { - {t('frequent|Hash: {{hash}}', { hash: fileToEdit.hash || '-' })} + {t('frequent|SHA256 Hash: {{hash}}', { hash: fileToEdit.hash || '-' })} @@ -129,7 +129,7 @@ function FileListItem(props: FileListItemProps) {