Skip to content

Improve error message when image not found and credentials are invalid

Sashi Kumar Kumaresan requested to merge sk/336525-fix-error-msg into master

Why is this change being made?

Addresses gitlab-org/gitlab#336525 (closed)

This MR updates the stderr message returned when an image to be scanned is not found and when the docker credentials provided using DOCKER_USERNAME and DOCKER_PASSWORD are invalid.

Before:

[ERROR] [2021-08-24 10:51:04 +0000] []  ▶  2021-08-24T10:51:04.025Z	FATAL	scan error: unable to initialize a scanner: unable to initialize a docker scanner: 3 errors occurred:
	* unable to inspect the image (registry.gitlab.com/sashi_kumar/container-scanning-match/master:invalid): Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
	* unable to initialize Podman client: no podman socket found: stat podman/podman.sock: no such file or directory
	* GET https://registry.gitlab.com/v2/sashi_kumar/container-scanning-match/master/manifests/invalid: MANIFEST_UNKNOWN: manifest unknown; map[Tag:invalid]

After

[ERROR] [2021-08-24 10:53:58 +0000] []  ▶  The image registry.gitlab.com/sashi_kumar/container-scanning-match/master: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

Scan using image from this tag: https://gitlab.com/sashi_kumar/container-scanning-match/-/jobs/1529254732

Edited by Sashi Kumar Kumaresan

Merge request reports