dgt: validate HTTPS certificate too

This commit is contained in:
Marcos Marado 2021-08-08 14:55:31 +01:00
parent 61ebbd490c
commit 6e08d88e68
1 changed files with 23 additions and 11 deletions

View File

@ -1,17 +1,31 @@
#!/bin/bash
links="$(wget https://tcp.dgterritorio.gov.pt/procurar -o /dev/null -O -|hxnormalize -x -l 10000|hxselect .feed-icon|hxselect a -s '\n')";
fail=0;
# How many links are there? if there is less than 1, something has changed,
# validate manually. If there are more than 1, maybe there's a XLS but also
# other (open) format. Let's validate manually and adjust the script if the
# violation stands.
nlinks="$(echo "$links"|wc -l)";
xls="$(echo "$links"|grep -c -i xls)";
if [ "$(curl https://tcp.dgterritorio.gov.pt/procurar -o /dev/null || echo $?)" -eq "60" ]; then
echo "dgt: erro no certificado HTTPS";
fail=1;
else
links="$(wget https://tcp.dgterritorio.gov.pt/procurar -o /dev/null -O -|hxnormalize -x -l 10000|hxselect .feed-icon|hxselect a -s '\n')";
# TODO: complementar validações com o incumprimento do XLS
# How many links are there? if there is less than 1, something has changed,
# validate manually. If there are more than 1, maybe there's a XLS but also
# other (open) format. Let's validate manually and adjust the script if the
# violation stands.
nlinks="$(echo "$links"|wc -l)";
xls="$(echo "$links"|grep -c -i xls)";
if [ "$nlinks" -eq "1" ] && [ "$xls" -eq "1" ]; then
# TODO: complementar validações com o incumprimento do XLS
if [ "$nlinks" -eq "1" ] && [ "$xls" -eq "1" ]; then
echo "dgt: continua o incumprimento com o uso de XLS";
fail=2;
fi
fi
if [ ! "$fail" ]; then
echo "dgt: algo mudou (nlinks $nlinks, xls $xls), incumprimento potencialmente resolvido (verificar manualmente!)";
else
echo "dgt: Incumprimento mantém-se, a actualizar o README (faça um git diff, valide, e commit!)";
while IFS='' read -r line || [[ -n "$line" ]]; do
test "$(echo "$line"|grep -v -c "dgterritorio")" -eq "1" \
@ -19,6 +33,4 @@ if [ "$nlinks" -eq "1" ] && [ "$xls" -eq "1" ]; then
|| (h=$(echo "$line"|cut -d\| -f1-4); t=$(echo "$line"|cut -d\| -f6-); echo "$h| $(date +%Y/%m/%d) |$t");
done < README.md > new
mv new README.md
else
echo "dgt: algo mudou (nlinks $nlinks, xls $xls), incumprimento potencialmente resolvido (verificar manualmente!)";
fi