Skip to content

Commit 2de5778

Browse files
Perform whitelist lookup only when required.
1 parent 06e5c92 commit 2de5778

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

webhooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ def index():
4444
path = normpath(abspath(dirname(__file__)))
4545
hooks = join(path, 'hooks')
4646

47-
whitelist = requests.get('https://api.github.com/meta').json()['hooks']
48-
4947
# Only POST is implemented
5048
if request.method != 'POST':
5149
abort(501)
@@ -59,6 +57,8 @@ def index():
5957
src_ip = ip_address(
6058
u'{}'.format(request.remote_addr) # Fix stupid ipaddress issue
6159
)
60+
whitelist = requests.get('https://api.github.com/meta').json()['hooks']
61+
6262
for valid_ip in whitelist:
6363
if src_ip in ip_network(valid_ip):
6464
break

0 commit comments

Comments
 (0)