-
Notifications
You must be signed in to change notification settings - Fork 2
/
pull-blacklist
executable file
·70 lines (56 loc) · 3.44 KB
/
pull-blacklist
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
set -e
### Generic constants ###
TMP_FILE='/tmp/tac-blacklist'
DATE_FILE='update-date.txt'
### TousAntiCovid constants ###
SRC_URL_TAC_EUDCC='https://app-static.tousanticovid.gouv.fr/json/blacklist/v2/CertList/dcc/ITERATOR/certlist.pb.gz'
BLACKLIST_FILE_TAC_EUDCC='blacklist-TAC-EUDCC.txt'
SRC_URL_TAC_2DDOC='https://app-static.tousanticovid.gouv.fr/json/blacklist/v2/CertList/2ddoc/ITERATOR/2ddoc_list.pb.gz'
BLACKLIST_FILE_TAC_2DDOC='blacklist-TAC-2D-DOC.txt'
### TousAntiCovid Verif constants ###
ACCESS_TOKEN='eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJqUG0zZ1BzUlZaMWRRUmhHOG1HMGhFN3Jlb2ZXTTNINzJCV1RtajdJcFd3In0.eyJleHAiOjE2ODUxODU5MDYsImlhdCI6MTYyMjExMzkwNiwianRpIjoiOTdjODgyM2EtNjlhZS00NzA4LWE4N2UtNzYxM2NhNGU3ODU5IiwiaXNzIjoiaHR0cHM6Ly9hdXRoLm1lc3NlcnZpY2VzLmluZ3JvdXBlLmNvbS9hdXRoL3JlYWxtcy9QSU5HIiwiYXVkIjoiYWNjb3VudCIsInN1YiI6ImVhMWY1NWVlLTUxMGMtNGMxNi05MWQ4LTE1MjI4OGJhZDViYSIsInR5cCI6IkJlYXJlciIsImF6cCI6InRhY3YtY2xpZW50LWxpdGUiLCJzZXNzaW9uX3N0YXRlIjoiNjk5ODExY2YtODFlZS00ZmNkLTk4NDctY2FkMGJmYjZhOTdiIiwiYWNyIjoiMSIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJST0xFX1ZFUklGWV9DT05UUk9MXzJERE9DX0wxIiwiUk9MRV9WRVJJRllfQ09OVFJPTF8yRERPQ19CMiIsIm9mZmxpbmVfYWNjZXNzIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6ImVtYWlsIHByb2ZpbGUgb2ZmbGluZV9hY2Nlc3MiLCJzaXJlbiI6IjAwMDAwMDAwMCIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoidGFjdi1tb2JpbGUtbGl0ZSIsImdpdmVuX25hbWUiOiIiLCJmYW1pbHlfbmFtZSI6IiJ9.mpfrIP8ayElTm7yoVayCF11oYrDQEnauk9hbbVBw8idAiE6OsMlWNloZtUbbnwrJZsMX3_NoEyzkiB3HNbxyhPWp7eRZ7qhn8XjZVgg6sVytXqcVZo9R5-Q9JftMKv7JelsY3PsaOo5x-pYOX30ancPRjd78TeenorGopsVN_LLRLQpenfgjjgwx-srZnLa-TFYTcbSvXozfJT7uk5CHyz_MIFLM7pl9Zdt66yTGBkLIyOLFsV5vPeH5SYvgRNDYdxZy4XMo6Gyfz0lAI9Xfcjs20NBoOQMV4JREH4Z-IcJJXeszC9QeA1-tRmxujqIRuyvBal7msLy7Zimd2q7i3Q'
SRC_URL_TACV_EUDCC='https://portail.tacv.myservices-ingroupe.com/api/client/configuration/blacklist/tacv/dcc/ITERATOR'
BLACKLIST_FILE_TACV_EUDCC='blacklist-TACV-EUDCC.txt'
SRC_URL_TACV_2DDOC='https://portail.tacv.myservices-ingroupe.com/api/client/configuration/blacklist/tacv/2ddoc/ITERATOR'
BLACKLIST_FILE_TACV_2DDOC='blacklist-TACV-2D-DOC.txt'
### Code ###
function getTACList {
echo -n '' > "${2}"
i=0
while true
do
curl --retry 10 --output "${TMP_FILE}" "$(echo "${1}" | sed "s,ITERATOR,${i},g")"
if [ -n "$(grep '<title>404 Not Found</title>' "${TMP_FILE}")" ]
then
break
fi
mv "${TMP_FILE}" "${TMP_FILE}.gz"
gunzip "${TMP_FILE}.gz"
grep -oE '[a-f0-9]{64}' "${TMP_FILE}" >> "${2}"
i=$(($i + 1))
done
sort -o "${2}" -u "${2}"
}
function getTACVList {
echo -n '' > "${2}"
i=0
while true
do
curl --retry 10 --oauth2-bearer "${ACCESS_TOKEN}" "$(echo "${1}" | sed "s,ITERATOR,${i},g")" \
| jq .elements[].hash | grep -oE '[a-f0-9]{64}' | sort -u > "${TMP_FILE}"
if [ -z "$(cat "${TMP_FILE}")" ]
then
break
fi
cat "${TMP_FILE}" >> "${2}"
i=$(($i + 2000))
done
sort -o "${2}" -u "${2}"
}
getTACList "${SRC_URL_TAC_EUDCC}" "${BLACKLIST_FILE_TAC_EUDCC}"
getTACList "${SRC_URL_TAC_2DDOC}" "${BLACKLIST_FILE_TAC_2DDOC}"
getTACVList "${SRC_URL_TACV_EUDCC}" "${BLACKLIST_FILE_TACV_EUDCC}"
getTACVList "${SRC_URL_TACV_2DDOC}" "${BLACKLIST_FILE_TACV_2DDOC}"
date '+%Y/%m/%d %H:%M %Z' > "${DATE_FILE}"
rm "${TMP_FILE}"