Skip to content
Draft
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
12 changes: 7 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#!/bin/bash

if [ $# == 0 ]; then
echo "Usage: url [grade] [followRedirects]"
echo "Usage: url [api-key] [grade] [followRedirects]"
echo "* url: URL to analyse."
echo "* api-key: Your Security Headers API key."
echo "* grade: The desired security grade of your HTTP response headers. Possible grades: A+, A, B, C, D, E, F. Defaults to B."
echo "* followRedirects: Follow redirects. Defaults to on, set to off or false to disable."
exit 1
fi


GRADE=${2:-'B'}
FOLLOW_REDIRECTS=${3-'1'}
APIKEY=$2
GRADE=${3:-'B'}
FOLLOW_REDIRECTS=${4-'1'}
FOLLOW_REDIRECTS=${FOLLOW_REDIRECTS/true/1}
FOLLOW_REDIRECTS=${FOLLOW_REDIRECTS/on/1}
FOLLOW_REDIRECTS=${FOLLOW_REDIRECTS/false/0}
FOLLOW_REDIRECTS=${FOLLOW_REDIRECTS/off/0}


declare -A grades=(
['A+']=7
['A']=6
Expand All @@ -26,7 +28,7 @@ declare -A grades=(
['F']=1
)

RATING=$(curl -s -L "https://securityheaders.com/?hide=on&followRedirects=$FOLLOW_REDIRECTS&q=$1" -I | sed -En 's/x-grade: (.*)/\1/p' | tr -d '\r')
RATING=$(curl -H "x-api-key: $APIKEY" -s -L "https://api.securityheaders.com/?hide=on&followRedirects=$FOLLOW_REDIRECTS&q=$1" | jq -r '.summary.grade')

echo "::set-output name=rating::$RATING"

Expand Down