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 webhooks.py to fix sha1 typo #41

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:2.7-alpine
FROM python:3.6.8-alpine
MAINTAINER "Matjaž Finžgar" <[email protected]>

WORKDIR /app
Expand Down
10 changes: 8 additions & 2 deletions webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import logging
from sys import stderr, hexversion
logging.basicConfig(stream=stderr)

import hmac
from hashlib import sha1
Expand All @@ -30,7 +29,9 @@
import requests
from ipaddress import ip_address, ip_network
from flask import Flask, request, abort
from flask import jsonify

logging.basicConfig(stream=stderr)

application = Flask(__name__)

Expand Down Expand Up @@ -82,7 +83,7 @@ def index():
abort(501)

# HMAC requires the key to be bytes, but data is string
mac = hmac.new(str(secret), msg=request.data, digestmod='sha1')
mac = hmac.new(str(secret), msg=request.data, digestmod=sha1)

# Python prior to 2.7.7 does not have hmac.compare_digest
if hexversion >= 0x020707F0:
Expand Down Expand Up @@ -202,5 +203,10 @@ def index():
return output


@application.route('/status', methods=['GET'])
def status():
return jsonify({'status': 'ok'})


if __name__ == '__main__':
application.run(debug=True, host='0.0.0.0')