Skip to content

Commit 76004f1

Browse files
author
Mike Taylor
authored
Merge pull request #1559 from karlcow/845/1
Fixes #845 - restrict comments and constrain the closing of issue
2 parents 15d227e + 43e1b1f commit 76004f1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

webcompat/api/endpoints.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ def edit_issue(number):
5050
edit issues.
5151
'''
5252
path = 'repos/{0}/{1}'.format(ISSUES_PATH, number)
53-
edit = proxy_request('patch', path, data=request.data)
54-
return (edit.content, edit.status_code, {'content-type': JSON_MIME})
53+
# we can only change the state of the issue: close or open
54+
states_list = ['{"state": "closed"}', '{"state": "open"}']
55+
if request.data in states_list:
56+
edit = proxy_request('patch', path, data=request.data)
57+
return (edit.content, edit.status_code, {'content-type': JSON_MIME})
58+
else:
59+
abort(403)
5560

5661

5762
@api.route('/issues')
@@ -205,7 +210,7 @@ def proxy_comments(number):
205210
Either as an authed user, or as one of our proxy bots.
206211
'''
207212
params = request.args.copy()
208-
if request.method == 'POST':
213+
if request.method == 'POST' and g.user:
209214
path = 'repos/{0}/{1}/comments'.format(ISSUES_PATH, number)
210215
return api_request('post', path, params=params,
211216
data=get_comment_data(request.data))

0 commit comments

Comments
 (0)