mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Merge pull request #238 from csaf-poc/publisher-in-report
Added publisher and role to domain report.
This commit is contained in:
commit
cca460c77b
3 changed files with 77 additions and 2 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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"`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,47 @@
|
|||
<h1>CSAF-Checker - Report</h1>
|
||||
{{- range .Domains }}
|
||||
<h2>{{ .Name }}{{ if .HasErrors }} (failed){{ end }}</h2>
|
||||
<p>
|
||||
{{ with .Publisher }}
|
||||
<fieldset>
|
||||
<legend>Publisher</legend>
|
||||
<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>
|
||||
</fieldset>
|
||||
{{ end }}
|
||||
</br>
|
||||
{{ with .Role }}<strong>Role:</strong> {{ . }}{{ end }}
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
{{ range .Requirements }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue