mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
fix config
This commit is contained in:
parent
4b7b93bd1d
commit
d2d3611278
1 changed files with 8 additions and 5 deletions
|
|
@ -151,13 +151,16 @@ func (cfg *config) HasCategories() bool {
|
||||||
return cfg.Categories != nil
|
return cfg.Categories != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// categoryExprPrefix is the prefix for dynamic categories.
|
||||||
|
const categoryExprPrefix = "expr:"
|
||||||
|
|
||||||
// HasDynamicCategories tells if dynamic categories are configured.
|
// HasDynamicCategories tells if dynamic categories are configured.
|
||||||
func (cfg *config) HasDynamicCategories() bool {
|
func (cfg *config) HasDynamicCategories() bool {
|
||||||
if !cfg.HasCategories() {
|
if !cfg.HasCategories() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, cat := range *cfg.Categories {
|
for _, cat := range *cfg.Categories {
|
||||||
if strings.HasPrefix(cat, "dynamic:") {
|
if strings.HasPrefix(cat, categoryExprPrefix) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -170,7 +173,7 @@ func (cfg *config) HasStaticCategories() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, cat := range *cfg.Categories {
|
for _, cat := range *cfg.Categories {
|
||||||
if !strings.HasPrefix(cat, "expr:") {
|
if !strings.HasPrefix(cat, categoryExprPrefix) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +187,7 @@ func (cfg *config) StaticCategories() []string {
|
||||||
}
|
}
|
||||||
cats := make([]string, 0, len(*cfg.Categories))
|
cats := make([]string, 0, len(*cfg.Categories))
|
||||||
for _, cat := range *cfg.Categories {
|
for _, cat := range *cfg.Categories {
|
||||||
if !strings.HasPrefix(cat, "expr:") {
|
if !strings.HasPrefix(cat, categoryExprPrefix) {
|
||||||
cats = append(cats, cat)
|
cats = append(cats, cat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -198,8 +201,8 @@ func (cfg *config) DynamicCategories() []string {
|
||||||
}
|
}
|
||||||
cats := make([]string, 0, len(*cfg.Categories))
|
cats := make([]string, 0, len(*cfg.Categories))
|
||||||
for _, cat := range *cfg.Categories {
|
for _, cat := range *cfg.Categories {
|
||||||
if strings.HasPrefix(cat, "expr:") {
|
if strings.HasPrefix(cat, categoryExprPrefix) {
|
||||||
cats = append(cats, cat[len("expr:"):])
|
cats = append(cats, cat[len(categoryExprPrefix):])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cats
|
return cats
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue