1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 05:40:11 +01:00
This commit is contained in:
Sascha L. Teichmann 2022-04-29 08:52:39 +02:00
parent 8bf48a2de2
commit 06c995c030
3 changed files with 47 additions and 19 deletions

View file

@ -30,23 +30,44 @@ const (
defaultUploadLimit = 50 * 1024 * 1024 // Default limit size of the uploaded file. defaultUploadLimit = 50 * 1024 * 1024 // Default limit size of the uploaded file.
) )
type providerMetadataConfig struct {
ListOnCSAFAggregators *bool `toml:"list_on_CSAF_aggregators"`
MirrorOnCSAFAggregators *bool `toml:"mirror_on_CSAF_aggregators"`
Publisher *csaf.Publisher `toml:"publisher"`
}
// configs contains the config values for the provider. // configs contains the config values for the provider.
type config struct { type config struct {
Password *string `toml:"password"` Password *string `toml:"password"`
Key string `toml:"key"` Key string `toml:"key"`
Folder string `toml:"folder"` Folder string `toml:"folder"`
Web string `toml:"web"` Web string `toml:"web"`
TLPs []tlp `toml:"tlps"` TLPs []tlp `toml:"tlps"`
UploadSignature bool `toml:"upload_signature"` UploadSignature bool `toml:"upload_signature"`
OpenPGPURL string `toml:"openpgp_url"` OpenPGPURL string `toml:"openpgp_url"`
CanonicalURLPrefix string `toml:"canonical_url_prefix"` CanonicalURLPrefix string `toml:"canonical_url_prefix"`
NoPassphrase bool `toml:"no_passphrase"` NoPassphrase bool `toml:"no_passphrase"`
NoValidation bool `toml:"no_validation"` NoValidation bool `toml:"no_validation"`
NoWebUI bool `toml:"no_web_ui"` NoWebUI bool `toml:"no_web_ui"`
DynamicProviderMetaData bool `toml:"dynamic_provider_metadata"` DynamicProviderMetaData bool `toml:"dynamic_provider_metadata"`
Publisher *csaf.Publisher `toml:"publisher"` ProviderMetaData *providerMetadataConfig `toml:"provider_metadata"`
UploadLimit *int64 `toml:"upload_limit"` UploadLimit *int64 `toml:"upload_limit"`
Issuer *string `toml:"issuer"` Issuer *string `toml:"issuer"`
}
func (pmdc *providerMetadataConfig) apply(pmd *csaf.ProviderMetadata) {
if pmdc == nil {
return
}
if pmdc.ListOnCSAFAggregators != nil {
pmd.ListOnCSAFAggregators = pmdc.ListOnCSAFAggregators
}
if pmdc.MirrorOnCSAFAggregators != nil {
pmd.MirrorOnCSAFAggregators = pmdc.MirrorOnCSAFAggregators
}
if pmdc.Publisher != nil {
pmd.Publisher = pmdc.Publisher
}
} }
type tlp string type tlp string
@ -161,8 +182,12 @@ func loadConfig() (*config, error) {
cfg.OpenPGPURL = defaultOpenPGPURL cfg.OpenPGPURL = defaultOpenPGPURL
} }
if cfg.Publisher == nil { if cfg.ProviderMetaData == nil {
cfg.Publisher = &csaf.Publisher{ cfg.ProviderMetaData = &providerMetadataConfig{}
}
if cfg.ProviderMetaData.Publisher == nil {
cfg.ProviderMetaData.Publisher = &csaf.Publisher{
Category: func(c csaf.Category) *csaf.Category { return &c }(csaf.CSAFCategoryVendor), Category: func(c csaf.Category) *csaf.Category { return &c }(csaf.CSAFCategoryVendor),
Name: func(s string) *string { return &s }("ACME"), Name: func(s string) *string { return &s }("ACME"),
Namespace: func(s string) *string { return &s }("https://example.com"), Namespace: func(s string) *string { return &s }("https://example.com"),

View file

@ -185,7 +185,7 @@ func createProviderMetadata(c *config, wellknownCSAF string) error {
return err return err
} }
pm := csaf.NewProviderMetadataDomain(c.CanonicalURLPrefix, c.modelTLPs()) pm := csaf.NewProviderMetadataDomain(c.CanonicalURLPrefix, c.modelTLPs())
pm.Publisher = c.Publisher c.ProviderMetaData.apply(pm)
// Set OpenPGP key. // Set OpenPGP key.
key, err := c.loadCryptoKey() key, err := c.loadCryptoKey()

View file

@ -136,6 +136,9 @@ Provider has many config options described as following:
- no_validation: Validate the uploaded CSAF document against the JSON schema. Default: `false`. - no_validation: Validate the uploaded CSAF document against the JSON schema. Default: `false`.
- no_web_ui: Disable the web interface. Default: `false`. - no_web_ui: Disable the web interface. Default: `false`.
- dynamic_provider_metadata: Take the publisher from the CSAF document. Default: `false`. - dynamic_provider_metadata: Take the publisher from the CSAF document. Default: `false`.
- publisher: Set the publisher. Default: `{"category"= "vendor", "name"= "Example", "namespace"= "https://example.com"}`. - provider_metadata: Configure the provider metadata.
- provider_metadata.list_on_CSAF_aggregators: List on aggregators
- provider_metadata.mirror_on_CSAF_aggregators: Mirror on aggregators
- provider_metadata.publisher: Set the publisher. Default: `{"category"= "vendor", "name"= "Example", "namespace"= "https://example.com"}`.
- upload_limit: Set the upload limit size of the file. Default: `50 MiB`. - upload_limit: Set the upload limit size of the file. Default: `50 MiB`.
- issuer: The issuer of the CA, which if set, restricts the writing permission and the accessing to the web-interface to only the client certificates signed with this CA. - issuer: The issuer of the CA, which if set, restricts the writing permission and the accessing to the web-interface to only the client certificates signed with this CA.