Skip to content

Commit 45fda0d

Browse files
fvanderbiestcarlos-jenkins
authored andcommitted
proxy-safe request IP
1 parent c4dc450 commit 45fda0d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

webhooks.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ def index():
5656
# Allow Github IPs only
5757
if config.get('github_ips_only', True):
5858
src_ip = ip_address(
59-
u'{}'.format(request.remote_addr) # Fix stupid ipaddress issue
59+
u'{}'.format(request.access_route[0]) # Fix stupid ipaddress issue
6060
)
6161
whitelist = requests.get('https://api.github.com/meta').json()['hooks']
6262

6363
for valid_ip in whitelist:
6464
if src_ip in ip_network(valid_ip):
6565
break
6666
else:
67+
logging.error('IP {} not allowed'.format(
68+
src_ip
69+
))
6770
abort(403)
6871

6972
# Enforce secret

0 commit comments

Comments
 (0)