Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: wang yan <wangyan@vmware.com>
  • Loading branch information
wy65701436 committed Oct 9, 2024
1 parent 641d266 commit 04ad795
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/server/middleware/v2auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func Middleware() func(http.Handler) http.Handler {
// the header is needed for "docker manifest" commands: https://github.com/docker/cli/issues/989
rw.Header().Set("Docker-Distribution-Api-Version", "registry/2.0")
rw.Header().Set("Www-Authenticate", challenge)
lib_http.SendError(rw, errors.UnauthorizedError(err).WithMessagef(err.Error()))
lib_http.SendError(rw, errors.UnauthorizedError(err).WithMessage(err.Error()))
return
}
next.ServeHTTP(rw, req)
Expand Down
6 changes: 3 additions & 3 deletions src/server/middleware/vulnerable/vulnerable.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func Middleware() func(http.Handler) http.Handler {
// No report yet?
msg := fmt.Sprintf(`current image without vulnerability scanning cannot be pulled due to configured policy in 'Prevent images with vulnerability severity of "%s" or higher from running.' `+
`To continue with pull, please contact your project administrator for help.`, projectSeverity)
return errors.New(nil).WithCode(errors.PROJECTPOLICYVIOLATION).WithMessagef(msg)
return errors.New(nil).WithCode(errors.PROJECTPOLICYVIOLATION).WithMessage(msg)
}

logger.Errorf("get vulnerability summary of the artifact %s@%s failed, error: %v", art.RepositoryName, art.Digest, err)
Expand All @@ -122,7 +122,7 @@ func Middleware() func(http.Handler) http.Handler {
if !vulnerable.IsScanSuccess() {
msg := fmt.Sprintf(`current image with "%s" status of vulnerability scanning cannot be pulled due to configured policy in 'Prevent images with vulnerability severity of "%s" or higher from running.' `+
`To continue with pull, please contact your project administrator for help.`, vulnerable.ScanStatus, projectSeverity)
return errors.New(nil).WithCode(errors.PROJECTPOLICYVIOLATION).WithMessagef(msg)
return errors.New(nil).WithCode(errors.PROJECTPOLICYVIOLATION).WithMessage(msg)
}

// Do judgement
Expand All @@ -134,7 +134,7 @@ func Middleware() func(http.Handler) http.Handler {
msg := fmt.Sprintf(`current image with %d %s cannot be pulled due to configured policy in 'Prevent images with vulnerability severity of "%s" or higher from running.' `+
`To continue with pull, please contact your project administrator to exempt matched vulnerabilities through configuring the CVE allowlist.`,
vulnerable.VulnerabilitiesCount, thing, projectSeverity)
return errors.New(nil).WithCode(errors.PROJECTPOLICYVIOLATION).WithMessagef(msg)
return errors.New(nil).WithCode(errors.PROJECTPOLICYVIOLATION).WithMessage(msg)
}

// Print scannerPull CVE list
Expand Down

0 comments on commit 04ad795

Please sign in to comment.