diff --git a/cmd/csaf_checker/processor.go b/cmd/csaf_checker/processor.go index 3f1d26f..c9510d7 100644 --- a/cmd/csaf_checker/processor.go +++ b/cmd/csaf_checker/processor.go @@ -220,6 +220,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() } @@ -227,6 +232,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 { diff --git a/cmd/csaf_checker/report.go b/cmd/csaf_checker/report.go index 1c48749..3dbeb0d 100644 --- a/cmd/csaf_checker/report.go +++ b/cmd/csaf_checker/report.go @@ -11,6 +11,8 @@ package main import ( "fmt" "time" + + "github.com/csaf-poc/csaf_distribution/csaf" ) // MessageType is the kind of the message. @@ -40,8 +42,10 @@ type Requirement struct { // Domain are the results of a domain. type Domain struct { - Name string `json:"name"` - Requirements []*Requirement `json:"requirements,omitempty"` + Name string `json:"name"` + Publisher *csaf.Publisher `json:"publisher,omitempty"` + Role *csaf.MetadataRole `json:"role,omitempty"` + Requirements []*Requirement `json:"requirements,omitempty"` } // ReportTime stores the time of the report. diff --git a/cmd/csaf_checker/tmpl/report.html b/cmd/csaf_checker/tmpl/report.html index b56f662..29e83ef 100644 --- a/cmd/csaf_checker/tmpl/report.html +++ b/cmd/csaf_checker/tmpl/report.html @@ -9,6 +9,47 @@

CSAF-Checker - Report

{{- range .Domains }}

{{ .Name }}{{ if .HasErrors }} (failed){{ end }}

+

+ {{ with .Publisher }} +

+ Publisher + + {{ with .Category }} + + + + + {{ end }} + {{ with .Name }} + + + + + {{ end }} + {{ with .Namespace }} + + + + + {{ end }} + {{ with .ContactDetails }} + + + + + {{ end }} + {{ with .IssuingAuthority }} + + + + + {{ end }} +
Category:{{ . }}
Name:{{ . }}
Namespace:{{ . }}
Contact Details:{{ . }}
Issuing Authority:{{ . }}
+
+ {{ end }} +
+ {{ with .Role }}Role: {{ . }}{{ end }} +

{{ range .Requirements }}