-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbadssl-report.sh
More file actions
executable file
·32 lines (26 loc) · 1.07 KB
/
badssl-report.sh
File metadata and controls
executable file
·32 lines (26 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
function run_tests(){
json_file="$DIR/badssl-endpoints.json"
json_file_alternative_url="https://raw.githubusercontent.com/hareldev/badssl-report/main/badssl-endpoints.json"
if [[ -f "$json_file" ]]; then
file_content=$(cat $json_file)
else
file_content=$(curl -sSL --fail "${json_file_alternative_url}")
fi
echo "type status-code result"
for row in $(echo "$file_content" | jq -r '.[] | @base64'); do
_jq() {
echo "${row}" | base64 --decode | jq -r "${1}"
}
# Set each property of the row to a variable
url=$(_jq '.url')
base_name=$(_jq '.base_name')
description=$(_jq '.description') # for future use
# Utilize your variables
url_response=$(curl -s -I --head --fail --tlsv1 "${url}" 2>/dev/null -w "%{http_code}\n" | tail -n 1);
status=$([ "$url_response" == "200" ] && echo "GOOD" || echo "BAD")
echo "$base_name $url_response $status";
done
}
run_tests | column -t