mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
create service.json document in provider.
This commit is contained in:
parent
7bafb210cf
commit
7f62caeedc
2 changed files with 49 additions and 0 deletions
|
|
@ -57,6 +57,7 @@ type config struct {
|
||||||
Issuer *string `toml:"issuer"`
|
Issuer *string `toml:"issuer"`
|
||||||
RemoteValidator *csaf.RemoteValidatorOptions `toml:"remote_validator"`
|
RemoteValidator *csaf.RemoteValidatorOptions `toml:"remote_validator"`
|
||||||
Categories *[]string `toml:"categories"`
|
Categories *[]string `toml:"categories"`
|
||||||
|
ServiceDocument bool `toml:"create_service_document"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pmdc *providerMetadataConfig) apply(pmd *csaf.ProviderMetadata) {
|
func (pmdc *providerMetadataConfig) apply(pmd *csaf.ProviderMetadata) {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ func ensureFolders(c *config) error {
|
||||||
for _, create := range []func(*config, string) error{
|
for _, create := range []func(*config, string) error{
|
||||||
createWellknown,
|
createWellknown,
|
||||||
createFeedFolders,
|
createFeedFolders,
|
||||||
|
createService,
|
||||||
createOpenPGPFolder,
|
createOpenPGPFolder,
|
||||||
createProviderMetadata,
|
createProviderMetadata,
|
||||||
} {
|
} {
|
||||||
|
|
@ -61,6 +62,53 @@ func createWellknown(_ *config, wellknown string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// createService creates the ROLIE service document (if configured).
|
||||||
|
func createService(c *config, wellknownCSAF string) error {
|
||||||
|
// no service document needed.
|
||||||
|
if !c.ServiceDocument {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
categories := csaf.ROLIEServiceWorkspaceCollectionCategories{
|
||||||
|
Category: []csaf.ROLIEServiceWorkspaceCollectionCategoriesCategory{{
|
||||||
|
Scheme: "urn:ietf:params:rolie:category:information-type",
|
||||||
|
Term: "csaf",
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
|
||||||
|
var collections []csaf.ROLIEServiceWorkspaceCollection
|
||||||
|
|
||||||
|
for _, t := range c.TLPs {
|
||||||
|
if t == tlpCSAF {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ts := string(t)
|
||||||
|
title := "CSAF feed (TLP:" + strings.ToUpper(ts) + ")"
|
||||||
|
feedName := "csaf-feed-tlp-" + ts + ".json"
|
||||||
|
href := c.CanonicalURLPrefix +
|
||||||
|
"/.well-known/csaf/" + ts + "/" + feedName
|
||||||
|
|
||||||
|
collection := csaf.ROLIEServiceWorkspaceCollection{
|
||||||
|
Title: title,
|
||||||
|
HRef: href,
|
||||||
|
Categories: categories,
|
||||||
|
}
|
||||||
|
collections = append(collections, collection)
|
||||||
|
}
|
||||||
|
|
||||||
|
rsd := &csaf.ROLIEServiceDocument{
|
||||||
|
Service: csaf.ROLIEService{
|
||||||
|
Workspace: []csaf.ROLIEServiceWorkspace{{
|
||||||
|
Title: "CSAF feeds",
|
||||||
|
Collection: collections,
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
path := filepath.Join(wellknownCSAF, "service.json")
|
||||||
|
return util.WriteToFile(path, rsd)
|
||||||
|
}
|
||||||
|
|
||||||
// createFeedFolders creates the feed folders according to the tlp values
|
// createFeedFolders creates the feed folders according to the tlp values
|
||||||
// in the "tlps" config option if they do not already exist.
|
// in the "tlps" config option if they do not already exist.
|
||||||
// No creation for the "csaf" option will be done.
|
// No creation for the "csaf" option will be done.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue