mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-28 11:46:20 -04:00
Show vulnerabilities
This commit is contained in:
parent
5c7c3f1ed7
commit
eae3f5ee67
2 changed files with 45 additions and 1 deletions
|
@ -38,7 +38,9 @@
|
||||||
{{ $value.Created.Format "02 Jan, 2006 15:04:05 UTC" }}
|
{{ $value.Created.Format "02 Jan, 2006 15:04:05 UTC" }}
|
||||||
</td>
|
</td>
|
||||||
<td >
|
<td >
|
||||||
|
<a href="/repo/{{ $value.Name | urlquery }}/{{ $value.Tag }}/vulns">
|
||||||
{{ $value.VulnerabilityReport.BadVulns }}
|
{{ $value.VulnerabilityReport.BadVulns }}
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -274,5 +274,47 @@ func (rc *registryController) vulnerabilities(c echo.Context) error {
|
||||||
if tag == "" {
|
if tag == "" {
|
||||||
return c.String(http.StatusNotFound, "No tag given")
|
return c.String(http.StatusNotFound, "No tag given")
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
m1, err := r.ManifestV1(repo, tag)
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"error": err,
|
||||||
|
"repo": repo,
|
||||||
|
"tag": tag,
|
||||||
|
}).Warn("getting v1 manifest failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, h := range m1.History {
|
||||||
|
var comp v1Compatibility
|
||||||
|
if err := json.Unmarshal([]byte(h.V1Compatibility), &comp); err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"error": err,
|
||||||
|
"repo": repo,
|
||||||
|
"tag": tag,
|
||||||
|
}).Warn("unmarshal v1compatibility failed")
|
||||||
|
return c.String(http.StatusInternalServerError, "unmarshal v1compatibility failed")
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
result := clair.VulnerabilityReport{}
|
||||||
|
|
||||||
|
if rc.cl != nil {
|
||||||
|
result, err = rc.cl.Vulnerabilities(rc.reg, repo, tag, m1)
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"error": err,
|
||||||
|
"repo": repo,
|
||||||
|
"tag": tag,
|
||||||
|
}).Error("error during vulnerability scanning.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.Render(http.StatusOK, "vulns", result)
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"error": err,
|
||||||
|
}).Error("error during template rendering")
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue