77
88set -euo pipefail
99
10+ trap ' kill 0' SIGINT
11+
1012status=0
1113green=' \e[1;32m' ; red=' \e[1;31m' ; cyan=' \e[1;36m' ; yellow=' \e[1;33m' ; reset=' \e[0m'
1214user_agent=" Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
@@ -21,9 +23,11 @@ while IFS=: read -r filepath url; do
2123 (
2224 code=$( curl -k -gsLm30 --retry 3 --retry-delay 3 --retry-connrefused -o /dev/null -w " %{http_code}" -I " $url " ) || code=000
2325 if [ " $code " -lt 200 ] || [ " $code " -ge 400 ]; then
26+ sleep 1
2427 code=$( curl -k -gsLm30 --retry 3 --retry-delay 3 --retry-connrefused -o /dev/null -w " %{http_code}" -r 0-0 -A " $user_agent " " $url " ) || code=000
2528 fi
2629 if [ " $code " -lt 200 ] || [ " $code " -ge 400 ]; then
30+ sleep 1
2731 request_id=$( curl -sS -G -H ' Accept: application/json' \
2832 --data-urlencode " host=$url " \
2933 --data-urlencode " max_nodes=1" \
@@ -45,11 +49,16 @@ while IFS=: read -r filepath url; do
4549 done
4650 fi
4751 fi
52+ # Treat Cloudflare JS-challenge and rate-limit as success.
53+ if [[ " $code " == " 403" || " $code " == " 429" || " $code " == " 503" ]]; then
54+ printf " ${yellow} WARN %s${reset} ${cyan} %s${reset} %s\n" " $code " " $url " " $filepath "
55+ exit 0
56+ fi
4857 if [ " $code " -lt 200 ] || [ " $code " -ge 400 ]; then
49- printf " ${red} %s${reset} ${yellow} %s${reset} %s\n" " $code " " $url " " $filepath " >&2
58+ printf " ${red} FAIL %s${reset} ${yellow} %s${reset} %s\n" " $code " " $url " " $filepath " >&2
5059 exit 1
5160 else
52- printf " ${green} %s${reset} ${cyan} %s${reset} %s\n" " $code " " $url " " $filepath "
61+ printf " ${green} OK %s${reset} ${cyan} %s${reset} %s\n" " $code " " $url " " $filepath "
5362 exit 0
5463 fi
5564 ) &
@@ -58,7 +67,7 @@ while IFS=: read -r filepath url; do
5867 sleep 1
5968 done
6069 done < <(
61- pattern=' (?!.*@lint-ignore)(?<!git\+)(?<!\$\{)https?://(?![^\s<>\")]*[<>\{\}\$])[^[:space:]<>")\[\]\\]+'
70+ pattern=' (?!.*@lint-ignore)(?<!git\+)(?<!\$\{)https?://(?![^/]*@)(?![^ \s<>\")]*[<>\{\}\$])[^[:space:]<>")\[\]\\| ]+'
6271 excludes=(
6372 ' :(exclude,glob)**/.*'
6473 ' :(exclude,glob)**/*.lock'
@@ -77,6 +86,7 @@ while IFS=: read -r filepath url; do
7786 git --no-pager grep --no-color -I -P -o " $pattern " -- " ${paths[@]} " " ${excludes[@]} " \
7887 | sed -E ' s/[^/[:alnum:]]+$//' \
7988 | grep -Ev ' ://(0\.0\.0\.0|127\.0\.0\.1|localhost)([:/])' \
89+ | grep -Ev ' ://[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' \
8090 | grep -Ev ' fwdproxy:8080' \
8191 || true
8292)
0 commit comments