Improve error message for inaccessible image
Addresses gitlab-org/gitlab#336525 (comment 666845345)
Since for Docker registry UNAUTHORIZED: authentication required
is returned for invalid image, we might not be sure if the image actually exists and the credentials are invalid or image does not exist. So for that case, docker credentials error message is used.
Invalid host
Command: docker run --pull -it --rm -e DOCKER_IMAGE=asdasdasdasdasdojsdhfjdfh registry.gitlab.com/gitlab-org/security-products/analyzers/container-scanning/tmp/trivy:51df250c0c58f6123be15cdd68597e9ef7a899d2
Log:
[ERROR] [2021-09-02 10:47:52 +0000] [] ▶ The credentials set in DOCKER_USER and DOCKER_PASSWORD are either empty or not valid.Please set valid credentials.
Invalid Image
GitLab Registry
Command: docker run --pull -it --rm -e DOCKER_IMAGE=registry.gitlab.com/asdasdasdasdasdojsdhfjdfh registry.gitlab.com/gitlab-org/security-products/analyzers/container-scanning/tmp/trivy:51df250c0c58f6123be15cdd68597e9ef7a899d2
Log:
[ERROR] [2021-09-02 10:48:06 +0000] [] ▶ The image registry.gitlab.com/asdasdasdasdasdojsdhfjdfh could not be found. To change the image being scanned, use the DOCKER_IMAGE environment variable.For details, see https://docs.gitlab.com/ee/user/application_security/container_scanning/#available-cicd-variables
Docker Registry
Command: docker run --pull -it --rm -e DOCKER_IMAGE=index.docker.io/asdasdasdasdasdojsdhfjdfh registry.gitlab.com/gitlab-org/security-products/analyzers/container-scanning/tmp/trivy:51df250c0c58f6123be15cdd68597e9ef7a899d2
Log:
[ERROR] [2021-09-02 10:50:56 +0000] [] ▶ The credentials set in DOCKER_USER and DOCKER_PASSWORD are either empty or not valid.Please set valid credentials.
Invalid Tag
GitLab Registry
Command: docker run --pull -it --rm -e DOCKER_IMAGE=registry.gitlab.com/gitlab-org/security-products/analyzers/container-scanning/tmp/trivy:invalid registry.gitlab.com/gitlab-org/security-products/analyzers/container-scanning/tmp/trivy:51df250c0c58f6123be15cdd68597e9ef7a899d2
Log:
[ERROR] [2021-09-02 10:49:34 +0000] [] ▶ The image registry.gitlab.com/gitlab-org/security-products/analyzers/container-scanning/tmp/trivy:invalid could not be found. To change the image being scanned, use the DOCKER_IMAGE environment variable.For details, see https://docs.gitlab.com/ee/user/application_security/container_scanning/#available-cicd-variables
Docker Registry
Command: docker run --pull -it --rm -e DOCKER_IMAGE=index.docker.io/alpine:invalid registry.gitlab.com/gitlab-org/security-products/analyzers/container-scanning/tmp/trivy:51df250c0c58f6123be15cdd68597e9ef7a899d2
Log:
[ERROR] [2021-09-02 10:55:57 +0000] [] ▶ The image index.docker.io/alpine:invalid could not be found. To change the image being scanned, use the DOCKER_IMAGE environment variable.For details, see https://docs.gitlab.com/ee/user/application_security/container_scanning/#available-cicd-variables