Skip to content

Commit

Permalink
omaha: Write only SHA256 hash for extra files
Browse files Browse the repository at this point in the history
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. This would match what's done in
https://chromium.googlesource.com/chromium/src.git/+/master/docs/updater/protocol_3_1.md
  • Loading branch information
pothos committed Dec 2, 2022
1 parent ed0ef7f commit 53e72ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion backend/pkg/omaha/omaha.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/omaha/omaha_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/Packages/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ function FileListItem(props: FileListItemProps) {
</Grid>
<Grid item>
<Typography component="span" variant="body2" color="textSecondary">
{t('frequent|Hash: {{hash}}', { hash: fileToEdit.hash || '-' })}
{t('frequent|SHA256 Hash: {{hash}}', {
hash: fileToEdit.hash || '-',
})}
</Typography>
</Grid>
</Grid>
Expand Down Expand Up @@ -129,8 +131,9 @@ function FileListItem(props: FileListItemProps) {
<TextField
name="hash"
margin="dense"
label={t('packages|Hash')}
label={t('packages|SHA256 Hash')}
type="text"
helperText={t('packages|From sha256sum')}
fullWidth
value={fileToEdit.hash}
onChange={(e: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) =>
Expand Down

0 comments on commit 53e72ee

Please sign in to comment.