Skip to content

Commit

Permalink
Validate stuff returned by the curl.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Jun 23, 2023
1 parent 8938ed7 commit 5a33a13
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docker/update_description.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ DOCKERHUB_PASS="${DOCKERHUB_PASS}"

# Get the JWT token
TOKEN="$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${DOCKERHUB_USER}'", "password": "'${DOCKERHUB_PASS}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)"
if [ -z "${TOKEN}" -o "${TOKEN}" = "null" ]
then
echo "ERROR: Invalid or no JWT TOKEN returned!" 1>&2
exit 1
fi

BCSUM1="`jq -r .nonce < /dev/null | md5sum_q`"
BCSUM2="`echo | md5sum_q`"

OLDCSUM="`curl -s -H "Authorization: JWT ${TOKEN}" "https://hub.docker.com/v2/repositories/${DOCKER_REPO}/" | jq -r .full_description | md5sum_q`"
NEWCSUM="`md5sum_q "${1}"`"
Expand All @@ -22,6 +30,11 @@ then
# description is up to date already
exit 0
fi
if [ "${OLDCSUM}" = "${BCSUM1}" -o "${OLDCSUM}" = "${BCSUM2}" ]
then
echo "ERROR: Empty description read!" 1>&2
exit 1
fi

MYNAME="`basename "${0}"`"
DESCRIPTION_FILE="`mktemp -t ${MYNAME}.XXXXXXX`"
Expand Down

0 comments on commit 5a33a13

Please sign in to comment.