1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 18:15:42 +01:00

Write directory_urls in provider if write indices.

This commit is contained in:
Sascha L. Teichmann 2022-07-30 12:20:21 +02:00
parent 4c0785c060
commit 8af0aeea46
2 changed files with 23 additions and 0 deletions

View file

@ -298,6 +298,17 @@ func createProviderMetadata(c *config, wellknownCSAF string) error {
pm := csaf.NewProviderMetadataDomain(c.CanonicalURLPrefix, c.modelTLPs()) pm := csaf.NewProviderMetadataDomain(c.CanonicalURLPrefix, c.modelTLPs())
c.ProviderMetaData.apply(pm) c.ProviderMetaData.apply(pm)
// We have directory based distributions.
if c.WriteIndices {
// Every TLP as a distribution?
for _, t := range c.TLPs {
if t != tlpCSAF {
pm.AddDirectoryDistribution(
c.CanonicalURLPrefix + "/.well-known/csaf/" + string(t))
}
}
}
key, err := loadCryptoKeyFromFile(c.OpenPGPPublicKey) key, err := loadCryptoKeyFromFile(c.OpenPGPPublicKey)
if err != nil { if err != nil {
return fmt.Errorf("cannot load public key: %v", err) return fmt.Errorf("cannot load public key: %v", err)

View file

@ -466,6 +466,18 @@ func (pmd *ProviderMetadata) Defaults() {
} }
} }
// AddDirectoryDistribution adds a directory based distribution
// with a given url to the provider metadata.
func (pmd *ProviderMetadata) AddDirectoryDistribution(url string) {
// Avoid duplicates.
for i := range pmd.Distributions {
if pmd.Distributions[i].DirectoryURL == url {
return
}
}
pmd.Distributions = append(pmd.Distributions, Distribution{DirectoryURL: url})
}
// Validate checks if the feed is valid. // Validate checks if the feed is valid.
// Returns an error if the validation fails otherwise nil. // Returns an error if the validation fails otherwise nil.
func (f *Feed) Validate() error { func (f *Feed) Validate() error {