mirror of
https://github.com/safing/portbase
synced 2025-09-04 11:40:23 +00:00
Require download policy to be stricter
This commit is contained in:
parent
109f51e834
commit
5accaad794
2 changed files with 10 additions and 4 deletions
|
@ -67,7 +67,7 @@ func ParseIndexFile(indexData []byte, channel string, lastIndexRelease time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to old format if there are no releases and no channel is defined.
|
// Fallback to old format if there are no releases and no channel is defined.
|
||||||
// TODO: Remove in v0.10
|
// TODO: Remove in v1
|
||||||
if len(indexFile.Releases) == 0 && indexFile.Channel == "" {
|
if len(indexFile.Releases) == 0 && indexFile.Channel == "" {
|
||||||
return loadOldIndexFormat(indexData, channel)
|
return loadOldIndexFormat(indexData, channel)
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,8 @@ func loadOldIndexFormat(indexData []byte, channel string) (*IndexFile, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &IndexFile{
|
return &IndexFile{
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
Published: time.Now(),
|
// Do NOT define `Published`, as this would break the "is newer" check.
|
||||||
Releases: releases,
|
Releases: releases,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package updater
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -103,6 +104,11 @@ func (reg *ResourceRegistry) Initialize(storageDir *utils.DirStructure) error {
|
||||||
return fmt.Errorf("verification enabled for prefix %q, but no trust store configured", prefix)
|
return fmt.Errorf("verification enabled for prefix %q, but no trust store configured", prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DownloadPolicy must be equal or stricter than DiskLoadPolicy.
|
||||||
|
if opts.DiskLoadPolicy < opts.DownloadPolicy {
|
||||||
|
return errors.New("verification download policy must be equal or stricter than the disk load policy")
|
||||||
|
}
|
||||||
|
|
||||||
// Warn if all policies are disabled.
|
// Warn if all policies are disabled.
|
||||||
if opts.DownloadPolicy == SignaturePolicyDisable &&
|
if opts.DownloadPolicy == SignaturePolicyDisable &&
|
||||||
opts.DiskLoadPolicy == SignaturePolicyDisable {
|
opts.DiskLoadPolicy == SignaturePolicyDisable {
|
||||||
|
|
Loading…
Add table
Reference in a new issue