1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

Added publisher and role to domain report.

This commit is contained in:
Sascha L. Teichmann 2022-07-18 22:44:34 +02:00
parent 5caed04dc8
commit 649b5c904b
3 changed files with 74 additions and 2 deletions

View file

@ -208,6 +208,11 @@ func (p *processor) run(reporters []reporter, domains []string) (*Report, error)
for _, r := range reporters {
r.report(p, domain)
}
if err := p.fillMeta(domain); err != nil {
log.Printf("Filling meta data failed: %v\n", err)
}
report.Domains = append(report.Domains, domain)
p.clean()
}
@ -215,6 +220,31 @@ func (p *processor) run(reporters []reporter, domains []string) (*Report, error)
return &report, nil
}
// fillMeta fills the report with extra informations from provider metadata.
func (p *processor) fillMeta(domain *Domain) error {
if p.pmd == nil {
return nil
}
var (
pub csaf.Publisher
role csaf.MetadataRole
)
if err := p.expr.Match([]util.PathEvalMatcher{
{Expr: `$.publisher`, Action: util.ReMarshalMatcher(&pub), Optional: true},
{Expr: `$.role`, Action: util.ReMarshalMatcher(&role), Optional: true},
}, p.pmd); err != nil {
return err
}
domain.Publisher = &pub
domain.Role = &role
return nil
}
// domainChecks compiles a list of checks which should be performed
// for a given domain.
func (p *processor) domainChecks(domain string) []func(*processor, string) error {