chevah / github-hooks-server

Handling of GitHub hooks for Chevah project
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

[Fix #25] Test and fix using serverless #26

Closed danuker closed 2 years ago

danuker commented 2 years ago

I made sure the issue_comment hook works. But there is still the pull_request_review hook, so please request changes from GitHub (GH won't let me review my own code).

What is removed: there is no security right now, seems like the request does not have the client IP. So, the IP allow-list is not enforced. We could use the GitHub webhook secret for this. Should it be done in this PR?

Also, I have not touched the tests. Should I update them in this PR?

The token currently deployed on Azure is from @chevah-robot token. It was deployed via config.ini in the latest uploaded artifact. Tell me if you would prefer to use environment variables which only appear here and not in the filesystem.

reviewers: @adiroiban @ioanacristinamarinescu

danuker commented 2 years ago

This is a pull request comment.

danuker commented 2 years ago

another comment

danuker commented 2 years ago

needs-review

danuker commented 2 years ago

needs-changes

danuker commented 2 years ago

changes-approved

danuker commented 2 years ago

changes-needed

danuker commented 2 years ago

needs-changes

danuker commented 2 years ago

needs-review

danuker commented 2 years ago

needs-review

danuker commented 2 years ago

needs-review

danuker commented 2 years ago

Testing with deployed endpoint

changes-approved

danuker commented 2 years ago

All right, the hook is now deployed to Azure.

needs-review

adiroiban commented 2 years ago

just testing

needs-changes

adiroiban commented 2 years ago

needs-review

adiroiban commented 2 years ago

just testing needs-review

danuker commented 2 years ago

Looks like the used token does not have enough permissions, for the sftpplus.com repository:

Traceback (most recent call last):
  File "/home/site/wwwroot/chevah/github_hooks_server/server.py", line 72, in hook
    response = handle_event(event)
  File "/home/site/wwwroot/chevah/github_hooks_server/server.py", line 131, in handle_event
    return handler.dispatch(event)
  File "/home/site/wwwroot/chevah/github_hooks_server/handler.py", line 47, in dispatch
    return handler(event)
  File "/home/site/wwwroot/chevah/github_hooks_server/handler.py", line 85, in pull_request_review
    self._setApproveChanges(
  File "/home/site/wwwroot/chevah/github_hooks_server/handler.py", line 163, in _setApproveChanges
    issue.edit(assignees=[author_name])
  File "/home/site/wwwroot/.python_packages/lib/site-packages/github3/decorators.py", line 24, in auth_wrapper
    return func(self, *args, **kwargs)
  File "/home/site/wwwroot/.python_packages/lib/site-packages/github3/issues/issue.py", line 236, in edit
    json = self._json(self._patch(self._api, data=dumps(data)), 200)
  File "/home/site/wwwroot/.python_packages/lib/site-packages/github3/models.py", line 153, in _json
    raise exceptions.error_for(response)
github3.exceptions.ForbiddenError: 403 Must have admin rights to Repository.

And this is why it could not update the user in this PR.

adiroiban commented 2 years ago

Looks like the used token does not have enough permissions, for the sftpplus.com repository:

can you enable default python output via the logging system so that we can see these errors in azure?

danuker commented 2 years ago

can you enable default python output via the logging system so that we can see these errors in azure?

I can see the log of this error already. You can see it by running the following query here:

traces
| order by timestamp
| where timestamp > datetime(12/17/2021, 12:40:06.847 AM)
| where timestamp < datetime(12/17/2021, 12:40:06.849 AM)
| project timestamp, message, severityLevel

I don't think it's worth redirecting stdout and stderr; it might pointlessly increase the amount of logs.