1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

Adjust default OpenPGP URL and replace fingeprint ans key id.

This commit is contained in:
Sascha L. Teichmann 2021-12-12 22:36:07 +01:00
parent df86b112c3
commit 98525ab758
3 changed files with 10 additions and 7 deletions

View file

@ -309,8 +309,7 @@ func (c *controller) upload(r *http.Request) (interface{}, error) {
warn("Publishers in provider metadata and CSAF do not match.") warn("Publishers in provider metadata and CSAF do not match.")
} }
keyID, fingerprint := key.GetHexKeyID(), key.GetFingerprint() pmd.SetPGP(key.GetFingerprint(), c.cfg.GetOpenPGPURL(key))
pmd.SetPGP(fingerprint, c.cfg.GetOpenPGPURL(keyID))
return nil return nil
}, },

View file

@ -24,7 +24,7 @@ const (
defaultConfigPath = "/usr/lib/casf/config.toml" defaultConfigPath = "/usr/lib/casf/config.toml"
defaultFolder = "/var/www/" defaultFolder = "/var/www/"
defaultWeb = "/var/www/html" defaultWeb = "/var/www/html"
defaultOpenPGPURL = "https://openpgp.circl.lu/pks/lookup?search=${KEY}&op=index" defaultOpenPGPURL = "https://openpgp.circl.lu/pks/lookup?op=get&search=${FINGERPRINT}"
) )
type config struct { type config struct {
@ -70,8 +70,13 @@ func (t *tlp) UnmarshalText(text []byte) error {
return fmt.Errorf("invalid config TLP value: %v", string(text)) return fmt.Errorf("invalid config TLP value: %v", string(text))
} }
func (cfg *config) GetOpenPGPURL(key string) string { func (cfg *config) GetOpenPGPURL(key *crypto.Key) string {
return strings.ReplaceAll(cfg.OpenPGPURL, "${KEY}", "0x"+key) if key == nil {
return cfg.OpenPGPURL
}
return strings.NewReplacer(
"${FINGERPRINT}", "0x"+key.GetFingerprint(),
"${KEY_ID}", "0x"+key.GetHexKeyID()).Replace(cfg.OpenPGPURL)
} }
func (cfg *config) modelTLPs() []csaf.TLPLabel { func (cfg *config) modelTLPs() []csaf.TLPLabel {

View file

@ -110,8 +110,7 @@ func createProviderMetadata(c *config, wellknownCSAF string) error {
if err != nil { if err != nil {
return err return err
} }
keyID, fingerprint := key.GetHexKeyID(), key.GetFingerprint() pm.SetPGP(key.GetFingerprint(), c.GetOpenPGPURL(key))
pm.SetPGP(fingerprint, c.GetOpenPGPURL(keyID))
return util.WriteToFile(path, pm) return util.WriteToFile(path, pm)
} }