mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-17 04:11:24 +01:00
update interceptor error code (#2836)
* update interceptor error code * update * update error string * update interceptor error code update update error string
This commit is contained in:
parent
45d583b171
commit
274f764622
@ -46,6 +46,18 @@ const (
|
|||||||
SevHigh
|
SevHigh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//String is the output function for sererity variable
|
||||||
|
func (sev Severity) String() string {
|
||||||
|
name := []string{"negligible", "unknown", "low", "medium", "high"}
|
||||||
|
i := int64(sev)
|
||||||
|
switch {
|
||||||
|
case i >= 1 && i <= int64(SevHigh):
|
||||||
|
return name[i-1]
|
||||||
|
default:
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//TableName is required by by beego orm to map ScanJob to table img_scan_job
|
//TableName is required by by beego orm to map ScanJob to table img_scan_job
|
||||||
func (s *ScanJob) TableName() string {
|
func (s *ScanJob) TableName() string {
|
||||||
return ScanJobTable
|
return ScanJobTable
|
||||||
|
@ -207,9 +207,10 @@ func (vh vulnerableHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
imageSev := overview.Sev
|
imageSev := overview.Sev
|
||||||
if imageSev > int(projectVulnerableSeverity) {
|
if imageSev >= int(projectVulnerableSeverity) {
|
||||||
log.Debugf("the image severity is higher then project setting, failing the response.")
|
log.Debugf("the image severity: %q is higher then project setting: %q, failing the response.", models.Severity(imageSev), projectVulnerableSeverity)
|
||||||
http.Error(rw, marshalError("The image scan result doesn't pass the project setting.", http.StatusPreconditionFailed), http.StatusPreconditionFailed)
|
http.Error(rw, marshalError(fmt.Sprintf("The severity of vulnerability of the image: %q is equal or higher than the threshold in project setting: %q.", models.Severity(imageSev), projectVulnerableSeverity),
|
||||||
|
http.StatusPreconditionFailed), http.StatusPreconditionFailed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
vh.next.ServeHTTP(rw, req)
|
vh.next.ServeHTTP(rw, req)
|
||||||
@ -236,7 +237,7 @@ func matchNotaryDigest(img imageInfo) (bool, error) {
|
|||||||
}
|
}
|
||||||
for _, t := range targets {
|
for _, t := range targets {
|
||||||
if t.Tag == img.tag {
|
if t.Tag == img.tag {
|
||||||
log.Debugf("found tag: %s in notary, try to match digest.")
|
log.Debugf("found tag: %s in notary, try to match digest.", img.tag)
|
||||||
d, err := notary.DigestFromTarget(t)
|
d, err := notary.DigestFromTarget(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
Loading…
Reference in New Issue
Block a user