Skip to content
Open
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
8 changes: 7 additions & 1 deletion containerSecurity/validate_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ check_command_exists () {
hash $1 2>/dev/null || { echo >&2 "This script requires $1 but it's not installed. Aborting."; exit 1; }
}

get_token() {
TOKEN=$($CURL -X POST ${QUALYS_API_SERVER} -H 'Content-Type: application/x-www-form-urlencoded' -d 'username='${USERNAME}'&password='${PASSWORD}'&token=true&permissions=true')
}

get_result () {
echo "Getting result for ${IMAGE_ID}"
CURL_COMMAND="$CURL -s -X GET ${GET_IMAGE_VULNS_URL} -u ${USERNAME}:${PASSWORD} -L -w\\n%{http_code} -o ${IMAGE_ID}.json"
Expand Down Expand Up @@ -102,6 +106,8 @@ CURL=$(which curl)
JQ=$(which jq)
DOCKER=$(which docker)

get_token

check_image_input_type ${IMAGE}

if [ "${IMAGE_INPUT_TYPE}" == "NAME" ]; then
Expand All @@ -113,7 +119,7 @@ else
fi

echo "Image id belonging to ${IMAGE} is: ${IMAGE_ID}"
GET_IMAGE_VULNS_URL="${QUALYS_API_SERVER}/csapi/v1.1/images/${IMAGE_ID}"
GET_IMAGE_VULNS_URL="${QUALYS_API_SERVER}/csapi/v1.3/images/${IMAGE_ID} -H 'accept: application/json' -H 'Authorization: Bearer '${TOKEN}"
echo ${GET_IMAGE_VULNS_URL}

echo "Temporarily tagging image ${IMAGE} with qualys_scan_target:${IMAGE_ID}"
Expand Down