Skip to content

Commit

Permalink
audit: report any errors above 400 as potentially not supporting audit (
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat authored and aeschright committed Jan 18, 2019
1 parent ef677a5 commit 193a5cf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,16 @@ function auditCmd (args, cb) {
}).then((auditReport) => {
return audit.submitForFullReport(auditReport)
}).catch((err) => {
if (err.statusCode === 404 || err.statusCode >= 500) {
const ne = new Error(`Your configured registry (${opts.registry}) does not support audit requests.`)
if (err.statusCode >= 400) {
let msg
if (err.statusCode === 401) {
msg = `Either your login credentials are invalid or your registry (${opts.registry}) does not support audit.`
} else if (err.statusCode === 404) {
msg = `Your configured registry (${opts.registry}) does not support audit requests.`
} else {
msg = `Your configured registry (${opts.registry}) does not support audit requests, or the audit endpoint is temporarily unavailable.`
}
const ne = new Error(msg)
ne.code = 'ENOAUDIT'
ne.wrapped = err
throw ne
Expand Down

0 comments on commit 193a5cf

Please sign in to comment.