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 9, 2019
1 parent c5b6056 commit f58b43e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/audit.js
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 f58b43e

Please sign in to comment.