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 {

View file

@ -11,6 +11,8 @@ package main
import (
"fmt"
"time"
"github.com/csaf-poc/csaf_distribution/csaf"
)
// MessageType is the kind of the message.
@ -41,6 +43,8 @@ type Requirement struct {
// Domain are the results of a domain.
type Domain struct {
Name string `json:"name"`
Publisher *csaf.Publisher `json:"publisher,omitempty"`
Role *csaf.MetadataRole `json:"role,omitempty"`
Requirements []*Requirement `json:"requirements,omitempty"`
}

View file

@ -9,6 +9,44 @@
<h1>CSAF-Checker - Report</h1>
{{- range .Domains }}
<h2>{{ .Name }}{{ if .HasErrors }} (failed){{ end }}</h2>
<p>
{{ with .Publisher }}
<table>
{{ with .Category }}
<tr>
<td><strong>category:</strong></td>
<td>{{ . }}</td>
</tr>
{{ end }}
{{ with .Name }}
<tr>
<td><strong>name:</strong></td>
<td>{{ . }}</td>
</tr>
{{ end }}
{{ with .Namespace }}
<tr>
<td><strong>namespace:</strong></td>
<td>{{ . }}</td>
</tr>
{{ end }}
{{ with .ContactDetails }}
<tr>
<td><strong>contact details:</strong></td>
<td>{{ . }}</td>
</tr>
{{ end }}
{{ with .IssuingAuthority }}
<tr>
<td><strong>issuing authority:</strong></td>
<td>{{ . }}</td>
</tr>
{{ end }}
<table>
{{ end }}
</br>
{{ with .Role }}<strong>Role:</strong> {{ . }}{{ end }}
</p>
<dl>
{{ range .Requirements }}