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

Replaced JSON schema library with a MIT licenensed one.

This commit is contained in:
Sascha L. Teichmann 2021-12-03 02:28:16 +01:00
parent 78f0b2db0b
commit 8c272fef2a
6 changed files with 56 additions and 36 deletions

View file

@ -27,6 +27,7 @@ type config struct {
OpenPGPURL string `toml:"openpgp_url"`
Domain string `toml:"domain"`
NoPassphrase bool `toml:"no_passphrase"`
NoValidation bool `toml:"no_validation"`
DynamicProviderMetaData bool `toml:"dynamic_provider_metadata"`
Publisher *csaf.Publisher `toml:"publisher"`
}

View file

@ -190,23 +190,26 @@ func (c *controller) upload(rw http.ResponseWriter, r *http.Request) {
return
}
validationErrors, err := csaf.Validate(data)
if err != nil {
c.failed(rw, "upload.html", err)
return
}
if len(validationErrors) > 0 {
c.multiFailed(rw, "upload.html", validationErrors)
return
}
var content interface{}
if err := json.Unmarshal(data, &content); err != nil {
c.failed(rw, "upload.html", err)
return
}
// Validate againt JSON schema.
if !c.cfg.NoValidation {
validationErrors, err := csaf.ValidateCSAF(content)
if err != nil {
c.failed(rw, "upload.html", err)
return
}
if len(validationErrors) > 0 {
c.multiFailed(rw, "upload.html", validationErrors)
return
}
}
ex, err := newExtraction(content)
if err != nil {
c.failed(rw, "upload.html", err)

View file

@ -9,7 +9,7 @@
<h1>CSAF-Provider - CSAF uploaded</h1>
{{ if .Error }}
{{ if eq (len .Error) 1 }}
<strong>Error: <tt>{{ .Error }}.</tt></strong>
<strong>Error: <tt>{{ index .Error 0 }}.</tt></strong>
{{ else }}
<p>
Errors: