diff --git a/cmd/csaf_provider/create.go b/cmd/csaf_provider/create.go index 56e5955..f571ca8 100644 --- a/cmd/csaf_provider/create.go +++ b/cmd/csaf_provider/create.go @@ -298,6 +298,17 @@ func createProviderMetadata(c *config, wellknownCSAF string) error { pm := csaf.NewProviderMetadataDomain(c.CanonicalURLPrefix, c.modelTLPs()) 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) if err != nil { return fmt.Errorf("cannot load public key: %v", err) diff --git a/csaf/models.go b/csaf/models.go index d9197d5..8935d41 100644 --- a/csaf/models.go +++ b/csaf/models.go @@ -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. // Returns an error if the validation fails otherwise nil. func (f *Feed) Validate() error {