Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/dockerregistry/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,29 +118,30 @@ func (t *manifests) getDigest(path string, subtype PathSubType) ([]byte, error)
// - (false, err) on verification errors or unknown decisions.
//
// Logging
// - Error on verification error (includes repo/digest).
// - Warn on deny (includes original path).
// - Error on verification error.
Comment thread
thijmv marked this conversation as resolved.
// - Warn on deny.
// - Debug on skip.
func (t *manifests) verify(
path string,
repo string,
digest core.Digest,
blob store.FileReader,
) (bool, error) {
l := log.With("path", path, "repo", repo, "digest", digest)
decision, err := t.verification(repo, digest, blob)
if err != nil {
log.With("repo", repo, "digest", digest).Errorf("Error while performing image validation %s", err)
l.With("error", err).Error("Error while performing image validation")
return false, err
}

switch decision {
case DecisionAllow:
return true, nil
case DecisionDeny:
log.With("repo", repo, "digest", digest).Warnf("Verification failed %s", path)
l.Warn("Verification failed")
return false, nil
case DecisionSkip:
log.With("repo", repo, "digest", digest).Debugf("Verification skipped for %s", path)
l.Debug("Verification skipped")
return true, nil
default:
return false, fmt.Errorf("unknown verification decision: %d", decision)
Expand Down
9 changes: 7 additions & 2 deletions utils/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@ func Wrap(h ErrHandler) http.HandlerFunc {
}
w.WriteHeader(status)
if _, err := w.Write([]byte(errMsg)); err != nil {
log.Errorf("Failed to write error response: %s", err)
log.With("error", err).Error("Failed to write error response")
}
} else {
status = http.StatusOK
}
if status >= 400 && status != 404 {
log.Infof("%d %s %s %s", status, r.Method, r.URL.Path, errMsg)
log.With(
"status", status,
"method", r.Method,
"path", r.URL.Path,
"error", errMsg,
).Info("Handler returned error response")
}
}
}
Loading