Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update-ngxblocker email routine doesn't support gmail username aliases user+alias@gmail.com #157

Closed
centminmod opened this issue Apr 3, 2018 · 3 comments · Fixed by #158
Labels

Comments

@centminmod
Copy link

When i use an email with an alias i.e. user+alias@gmail.com, the update-ngxblocker script removes the + sign so that email is sent to useralias@gmail.com instead of user+alias@gmail.com

/usr/local/sbin/update-ngxblocker -c /usr/local/nginx/conf/ultimate-badbot-blocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -e user+alias@gmail.com

LOCAL Version: 3.2018.04.1080
Updated: Mon Apr  2 15:35:14 SAST 2018

REMOTE Version: 3.2018.04.1082
Updated: Tue Apr  3 09:40:52 SAST 2018

Update Available => 3.2018.04.1082

Downloading: globalblacklist.conf ...[OK]

Checking url: https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/include_filelist.txt

Nothing to update for directory: /usr/local/nginx/conf/ultimate-badbot-blocker
Nothing to update for directory: /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d
Nothing to update for directory: /usr/local/sbin
Setting mode: 700 => /usr/local/sbin/install-ngxblocker
Setting mode: 700 => /usr/local/sbin/setup-ngxblocker
Setting mode: 700 => /usr/local/sbin/update-ngxblocker
Updating bots.d path: /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d => /usr/local/nginx/conf/ultimate-badbot-blocker/globalblacklist.conf

Reloading NGINX configuration...[OK]
Emailing report to: useralias@gmail.com
@mitchellkrogza
Copy link
Owner

Thanks @centminmod for reporting this, I'm sure Stuart @itoffshore can sort this out in the next update

itoffshore added a commit to itoffshore/nginx-ultimate-bad-bot-blocker that referenced this issue Apr 3, 2018
* sanitizing + breaks google aliases

  fixes mitchellkrogza#157
@centminmod
Copy link
Author

centminmod commented Apr 4, 2018

@itoffshore @mitchellkrogza seems the bug is still happening for me looks like updater didn't update update-ngxblocker it's missing the fix outlined at https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/pull/158/files

manually run update twice

1st run

/usr/local/sbin/update-ngxblocker -c /usr/local/nginx/conf/ultimate-badbot-blocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -e username+badbot@gmail.com

LOCAL Version: 3.2018.04.1084
Updated: Tue Apr  3 20:43:25 SAST 2018

REMOTE Version: 3.2018.04.1086
Updated: Wed Apr  4 00:41:11 SAST 2018

Update Available => 3.2018.04.1086

Downloading: globalblacklist.conf ...[OK]

Checking url: https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/include_filelist.txt

Nothing to update for directory: /usr/local/nginx/conf/ultimate-badbot-blocker
Nothing to update for directory: /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d
Nothing to update for directory: /usr/local/sbin
Setting mode: 700 => /usr/local/sbin/install-ngxblocker
Setting mode: 700 => /usr/local/sbin/setup-ngxblocker
Setting mode: 700 => /usr/local/sbin/update-ngxblocker
Updating bots.d path: /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d => /usr/local/nginx/conf/ultimate-badbot-blocker/globalblacklist.conf

Reloading NGINX configuration...[OK]
Emailing report to: usernamebadbot@gmail.com

2nd run

/usr/local/sbin/update-ngxblocker -c /usr/local/nginx/conf/ultimate-badbot-blocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -e username+badbot@gmail.com

LOCAL Version: 3.2018.04.1086
Updated: Wed Apr  4 00:41:11 SAST 2018

REMOTE Version: 3.2018.04.1086
Updated: Wed Apr  4 00:41:11 SAST 2018

Latest Blacklist Already Installed: 3.2018.04.1086

Emailing report to: usernamebadbot@gmail.com

debug run - looks like updater didn't update update-ngxblocker it's missing the fix outlined at https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/pull/158/files

bash -x /usr/local/sbin/update-ngxblocker -c /usr/local/nginx/conf/ultimate-badbot-blocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -e username+badbot@gmail.com
+ EMAIL=me@myemail.com
+ SEND_EMAIL=N
+ SEND_EMAIL_UPDATE=N
+ CONF_DIR=/etc/nginx/conf.d
+ BOTS_DIR=/etc/nginx/bots.d
+ INSTALLER=/usr/local/sbin/install-ngxblocker
+ BOLDGREEN='\033[1m\033[32m'
+ BOLDMAGENTA='\033[1m\033[35m'
+ BOLDRED='\033[1m\033[31m'
+ BOLDYELLOW='\033[1m\033[33m'
+ BOLDWHITE='\033[1m\033[37m'
+ RESET='\033[0m'
++ mktemp
+ EMAIL_REPORT=/tmp/tmp.buYPaJdFPS
+ main -c /usr/local/nginx/conf/ultimate-badbot-blocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -e username+badbot@gmail.com
+ local REPO=https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master
+ local file=globalblacklist.conf remote_dir=conf.d url= output= update= status= tmp= retval=
+ tee /tmp/tmp.buYPaJdFPS
++ service_cmd
++ local x= svc= 'svc_list=service systemctl rc-service'
++ for x in '$svc_list'
+++ which service
++ svc=/usr/sbin/service
++ '[' -n /usr/sbin/service ']'
++ case "$x" in
++ svc='/usr/sbin/service nginx reload'
++ break
++ echo /usr/sbin/service nginx reload
+ local 'reload_service=/usr/sbin/service nginx reload'
++ id -u
+ '[' 0 '!=' 0 ']'
+ get_options -c /usr/local/nginx/conf/ultimate-badbot-blocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -e username+badbot@gmail.com
+ local arg= opts=
+ getopts :c:b:i:r:e:m:novqh opts -c /usr/local/nginx/conf/ultimate-badbot-blocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -e username+badbot@gmail.com
+ '[' -n /usr/local/nginx/conf/ultimate-badbot-blocker ']'
+ case "$opts" in
++ sanitize_path /usr/local/nginx/conf/ultimate-badbot-blocker
++ echo /usr/local/nginx/conf/ultimate-badbot-blocker
++ tr -cd '[:alnum:] [=@=] [=.=] [=-=] [=/=] [=_=]'
++ tr -s @.-/_
++ awk '{print tolower($0)}'
+ arg=/usr/local/nginx/conf/ultimate-badbot-blocker
+ case "$opts" in
+ CONF_DIR=/usr/local/nginx/conf/ultimate-badbot-blocker
+ check_args c path /usr/local/nginx/conf/ultimate-badbot-blocker
+ local option=c type=path arg=/usr/local/nginx/conf/ultimate-badbot-blocker
+ local 'msg=ERROR: option '\''-c'\'' argument '\''/usr/local/nginx/conf/ultimate-badbot-blocker'\'' requires:'
+ case "$type" in
+ echo /usr/local/nginx/conf/ultimate-badbot-blocker
+ grep '^/'
+ getopts :c:b:i:r:e:m:novqh opts -c /usr/local/nginx/conf/ultimate-badbot-blocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -e username+badbot@gmail.com
+ '[' -n /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d ']'
+ case "$opts" in
++ sanitize_path /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d
++ echo /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d
++ tr -cd '[:alnum:] [=@=] [=.=] [=-=] [=/=] [=_=]'
++ tr -s @.-/_
++ awk '{print tolower($0)}'
+ arg=/usr/local/nginx/conf/ultimate-badbot-blocker/bots.d
+ case "$opts" in
+ BOTS_DIR=/usr/local/nginx/conf/ultimate-badbot-blocker/bots.d
+ check_args b path /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d
+ local option=b type=path arg=/usr/local/nginx/conf/ultimate-badbot-blocker/bots.d
+ local 'msg=ERROR: option '\''-b'\'' argument '\''/usr/local/nginx/conf/ultimate-badbot-blocker/bots.d'\'' requires:'
+ case "$type" in
+ echo /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d
+ grep '^/'
+ getopts :c:b:i:r:e:m:novqh opts -c /usr/local/nginx/conf/ultimate-badbot-blocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -e username+badbot@gmail.com
+ '[' -n username+badbot@gmail.com ']'
+ case "$opts" in
++ sanitize_email username+badbot@gmail.com
++ echo username+badbot@gmail.com
++ tr -cd '[:alnum:] [=@=] [=.=] [=-=] [=_=]'
++ tr -s @-_.
++ awk '{print tolower($0)}'
+ arg=usernamebadbot@gmail.com
+ case "$opts" in
+ EMAIL=usernamebadbot@gmail.com
+ SEND_EMAIL=Y
+ check_args e email usernamebadbot@gmail.com
+ local option=e type=email arg=usernamebadbot@gmail.com
+ local 'msg=ERROR: option '\''-e'\'' argument '\''usernamebadbot@gmail.com'\'' requires:'
+ case "$type" in
+ echo usernamebadbot@gmail.com
+ grep -E '^[-_.[:alnum:]]+@[-_.[:alnum:]]+'
+ getopts :c:b:i:r:e:m:novqh opts -c /usr/local/nginx/conf/ultimate-badbot-blocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -e username+badbot@gmail.com
+ INSTALL_INC='/usr/local/sbin/install-ngxblocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -c /usr/local/nginx/conf/ultimate-badbot-blocker -x'
+ check_depends
+ '[' '!' -x /usr/bin/curl ']'
+ '[' '!' -x /usr/local/sbin/install-ngxblocker ']'
+ check_dirs /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d /usr/local/nginx/conf/ultimate-badbot-blocker
+ local x= 'dirs=/usr/local/nginx/conf/ultimate-badbot-blocker/bots.d /usr/local/nginx/conf/ultimate-badbot-blocker'
+ for x in '$dirs'
+ '[' '!' -d /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d ']'
+ for x in '$dirs'
+ '[' '!' -d /usr/local/nginx/conf/ultimate-badbot-blocker ']'
+ url=https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/conf.d/globalblacklist.conf
+ output=/usr/local/nginx/conf/ultimate-badbot-blocker/globalblacklist.conf
+ check_version
+ local remote_ver= remote_date= version= date= file=/usr/local/nginx/conf/ultimate-badbot-blocker/globalblacklist.conf
++ mktemp
+ local tmp=/tmp/tmp.7ETIImzyfu url=https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/conf.d/globalblacklist.conf range=145-345
+ '[' -f /usr/local/nginx/conf/ultimate-badbot-blocker/globalblacklist.conf ']'
++ grep Version: /usr/local/nginx/conf/ultimate-badbot-blocker/globalblacklist.conf
++ sed 's|^.*: V||g'
+ version=3.2018.04.1086
++ grep Updated: /usr/local/nginx/conf/ultimate-badbot-blocker/globalblacklist.conf
++ sed 's|^.*: ||g'
+ date='Wed Apr  4 00:41:11 SAST 2018'
+ print_message '\nLOCAL Version: \033[1m\033[37m3.2018.04.1086\033[0m\n'
+ local 'msg=\nLOCAL Version: \033[1m\033[37m3.2018.04.1086\033[0m\n'
+ '[' '' '!=' N ']'
+ printf '\nLOCAL Version: \033[1m\033[37m3.2018.04.1086\033[0m\n'
+ print_message 'Updated: Wed Apr  4 00:41:11 SAST 2018\n\n'
+ local 'msg=Updated: Wed Apr  4 00:41:11 SAST 2018\n\n'
+ '[' '' '!=' N ']'
+ printf 'Updated: Wed Apr  4 00:41:11 SAST 2018\n\n'
+ curl -s --limit-rate 5k -r 145-345 --location https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/conf.d/globalblacklist.conf -o /tmp/tmp.7ETIImzyfu

LOCAL Version: 3.2018.04.1086
Updated: Wed Apr  4 00:41:11 SAST 2018

++ grep Version: /tmp/tmp.7ETIImzyfu
++ sed 's|^.*: V||g'
+ remote_ver=3.2018.04.1086
++ grep Updated: /tmp/tmp.7ETIImzyfu
++ sed 's|^.*: ||g'
+ remote_date='Wed Apr  4 00:41:11 SAST 2018'
+ print_message 'REMOTE Version: \033[1m\033[37m3.2018.04.1086\033[0m\n'
+ local 'msg=REMOTE Version: \033[1m\033[37m3.2018.04.1086\033[0m\n'
+ '[' '' '!=' N ']'
+ printf 'REMOTE Version: \033[1m\033[37m3.2018.04.1086\033[0m\n'
REMOTE Version: 3.2018.04.1086
+ print_message 'Updated: Wed Apr  4 00:41:11 SAST 2018\n'
+ local 'msg=Updated: Wed Apr  4 00:41:11 SAST 2018\n'
+ '[' '' '!=' N ']'
+ printf 'Updated: Wed Apr  4 00:41:11 SAST 2018\n'
Updated: Wed Apr  4 00:41:11 SAST 2018
+ rm -f /tmp/tmp.7ETIImzyfu
+ '[' 3.2018.04.1086 '!=' 3.2018.04.1086 ']'
+ print_message '\nLatest Blacklist Already Installed: \033[1m\033[32m3.2018.04.1086\033[0m\n\n'
+ local 'msg=\nLatest Blacklist Already Installed: \033[1m\033[32m3.2018.04.1086\033[0m\n\n'
+ '[' '' '!=' N ']'
+ printf '\nLatest Blacklist Already Installed: \033[1m\033[32m3.2018.04.1086\033[0m\n\n'
+ update=0

Latest Blacklist Already Installed: 3.2018.04.1086

+ '[' 0 = 1 ']'
+ update_paths /usr/local/nginx/conf/ultimate-badbot-blocker/globalblacklist.conf
+ local blacklist=/usr/local/nginx/conf/ultimate-badbot-blocker/globalblacklist.conf include_paths= dir= x=
+ grep /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d /usr/local/nginx/conf/ultimate-badbot-blocker/globalblacklist.conf
+ '[' N = Y ']'
+ case "$SEND_EMAIL" in
+ send_email
+ check_mail_depends
+ '[' '!' -f /usr/bin/mail ']'
+ print_message 'Emailing report to: \033[1m\033[37musernamebadbot@gmail.com\033[0m\n\n'
+ local 'msg=Emailing report to: \033[1m\033[37musernamebadbot@gmail.com\033[0m\n\n'
+ '[' '' '!=' N ']'
+ printf 'Emailing report to: \033[1m\033[37musernamebadbot@gmail.com\033[0m\n\n'
+ sed -i 's/\x1b\[[0-9;]*m//g' /tmp/tmp.buYPaJdFPS
Emailing report to: usernamebadbot@gmail.com

+ cat /tmp/tmp.buYPaJdFPS
+ mail -s 'Nginx Bad Bot Blocker Updated' usernamebadbot@gmail.com
+ rm -f /tmp/tmp.buYPaJdFPS
+ exit 0

are we meant to manually update it https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/blob/master/update-ngxblocker#L23-L26 ?

# Save this file as /usr/local/sbin/update-ngxblocker
# cd /usr/local/sbin
# sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/update-ngxblocker -O update-ngxblocker
# Make it Executable chmod 700 /usr/local/sbin/update-ngxblocker

i..e

wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/update-ngxblocker -O /usr/local/sbin/update-ngxblocker && chmod 700 /usr/local/sbin/update-ngxblocker

if i manually update then looks like your updated check works

/usr/local/sbin/update-ngxblocker -c /usr/local/nginx/conf/ultimate-badbot-blocker -b /usr/local/nginx/conf/ultimate-badbot-blocker/bots.d -e username+badbot@gmail.com
ERROR: option '-e' argument 'username+badbot@gmail.com' requires: email@domain.com

itoffshore added a commit to itoffshore/nginx-ultimate-bad-bot-blocker that referenced this issue Apr 4, 2018
@itoffshore
Copy link
Collaborator

I also needed to alter check_args() to finish fixing aliases

I've also got some improvements to come on how the scripts are updated & how mail is sent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants