GitHub PullRequestReviewCommentEvent at 2014-12-05 22:57:08
Repository: pylemma
Actor: r0mant
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/mailgun/pylemma/pulls/comments/21406731","id":21406731,"diff_hunk":"@@ -121,15 +122,20 @@ def authenticate_request(timestamp, nonce, request_body, signature,\n     Returns a boolean.\n     \"\"\"\n \n-    # if shared secret or nonce cache not loaded, don't authenticate anything\n+    # if shared secret is not loaded, don't authenticate anything\n     if not SHARED_SECRET:\n         if not key:\n+            lemma.metrics.emit_failure(metrics_prefix)","path":"lemma/httpsign.py","position":44,"original_position":43,"commit_id":"a4c4c2ac0565269494607db82a1703963a533578","original_commit_id":"6f7523bcf1b04f86f16dbf4234d7003a6f0b3b2a","user":{"login":"r0mant","id":339322,"avatar_url":"https://avatars.githubusercontent.com/u/339322?v=3","gravatar_id":"","url":"https://api.github.com/users/r0mant","html_url":"https://github.com/r0mant","followers_url":"https://api.github.com/users/r0mant/followers","following_url":"https://api.github.com/users/r0mant/following{/other_user}","gists_url":"https://api.github.com/users/r0mant/gists{/gist_id}","starred_url":"https://api.github.com/users/r0mant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r0mant/subscriptions","organizations_url":"https://api.github.com/users/r0mant/orgs","repos_url":"https://api.github.com/users/r0mant/repos","events_url":"https://api.github.com/users/r0mant/events{/privacy}","received_events_url":"https://api.github.com/users/r0mant/received_events","type":"User","site_admin":false},"body":"How about write a decorator that is aware that `False` or `AuthenticationException` means unsuccessful authentication and apply it on this function? That'd make the code much clearer.","created_at":"2014-12-05T22:57:08Z","updated_at":"2014-12-05T22:57:08Z","html_url":"https://github.com/mailgun/pylemma/pull/3#discussion_r21406731","pull_request_url":"https://api.github.com/repos/mailgun/pylemma/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/mailgun/pylemma/pulls/comments/21406731"},"html":{"href":"https://github.com/mailgun/pylemma/pull/3#discussion_r21406731"},"pull_request":{"href":"https://api.github.com/repos/mailgun/pylemma/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/mailgun/pylemma/pulls/3","id":25545115,"html_url":"https://github.com/mailgun/pylemma/pull/3","diff_url":"https://github.com/mailgun/pylemma/pull/3.diff","patch_url":"https://github.com/mailgun/pylemma/pull/3.patch","issue_url":"https://api.github.com/repos/mailgun/pylemma/issues/3","number":3,"state":"open","locked":false,"title":"Emit stats to statsd.","user":{"login":"russjones","id":5017502,"avatar_url":"https://avatars.githubusercontent.com/u/5017502?v=3","gravatar_id":"","url":"https://api.github.com/users/russjones","html_url":"https://github.com/russjones","followers_url":"https://api.github.com/users/russjones/followers","following_url":"https://api.github.com/users/russjones/following{/other_user}","gists_url":"https://api.github.com/users/russjones/gists{/gist_id}","starred_url":"https://api.github.com/users/russjones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/russjones/subscriptions","organizations_url":"https://api.github.com/users/russjones/orgs","repos_url":"https://api.github.com/users/russjones/repos","events_url":"https://api.github.com/users/russjones/events{/privacy}","received_events_url":"https://api.github.com/users/russjones/received_events","type":"User","site_admin":false},"body":"**Purpose**\r\n\r\nA good way to look for malicious activity is successful and unsuccessful authentication/encryption events. Currently we have no way of doing this. This commit starts emitting these metrics to statsd. This way we can display it on a dashbaord and if we see a spike of unsuccessful authentication or encryption events we know someone may be trying to attack our system or something is going wrong on our end.\r\n\r\n**Implementation**\r\n\r\n* Before doing anything else, call `lemma.metrics.initialize` with the hostname and port of the statsd server. Optionally a prefix can be given to prefix all metrics. By deafult this is `lemma.{hostname}`.\r\n* If you don't call `lemma.metrics.initialize` you can still call the `emit_success` and `emit_failure` methods, but nothing will happen. This is done to keep code clean, so instead of a `if` check every time you want to emit a metric, you can just try to emit the metric. It will be sent if you have the service configured. \r\n* Call `lemma.metrics.emit_success` or `lemma.metrics.emit_failure` whenever you wish to emit a  `Counter` metric. They are thread safe.\r\n* Currently, the above two methods are only called by `lemma.httpsign.authenticate_request` and `lemma.httpsign.open`.\r\n\r\n**Related Commits**\r\nhttps://github.com/mailgun/lemma/pull/2","created_at":"2014-12-05T02:09:17Z","updated_at":"2014-12-05T22:57:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"350df51c78a3fbd3ba6aafd122db171e4569caa2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mailgun/pylemma/pulls/3/commits","review_comments_url":"https://api.github.com/repos/mailgun/pylemma/pulls/3/comments","review_comment_url":"https://api.github.com/repos/mailgun/pylemma/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mailgun/pylemma/issues/3/comments","statuses_url":"https://api.github.com/repos/mailgun/pylemma/statuses/a4c4c2ac0565269494607db82a1703963a533578","head":{"label":"mailgun:rjones/stats","ref":"rjones/stats","sha":"a4c4c2ac0565269494607db82a1703963a533578","user":{"login":"mailgun","id":447686,"avatar_url":"https://avatars.githubusercontent.com/u/447686?v=3","gravatar_id":"","url":"https://api.github.com/users/mailgun","html_url":"https://github.com/mailgun","followers_url":"https://api.github.com/users/mailgun/followers","following_url":"https://api.github.com/users/mailgun/following{/other_user}","gists_url":"https://api.github.com/users/mailgun/gists{/gist_id}","starred_url":"https://api.github.com/users/mailgun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mailgun/subscriptions","organizations_url":"https://api.github.com/users/mailgun/orgs","repos_url":"https://api.github.com/users/mailgun/repos","events_url":"https://api.github.com/users/mailgun/events{/privacy}","received_events_url":"https://api.github.com/users/mailgun/received_events","type":"Organization","site_admin":false},"repo":{"id":24121715,"name":"pylemma","full_name":"mailgun/pylemma","owner":{"login":"mailgun","id":447686,"avatar_url":"https://avatars.githubusercontent.com/u/447686?v=3","gravatar_id":"","url":"https://api.github.com/users/mailgun","html_url":"https://github.com/mailgun","followers_url":"https://api.github.com/users/mailgun/followers","following_url":"https://api.github.com/users/mailgun/following{/other_user}","gists_url":"https://api.github.com/users/mailgun/gists{/gist_id}","starred_url":"https://api.github.com/users/mailgun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mailgun/subscriptions","organizations_url":"https://api.github.com/users/mailgun/orgs","repos_url":"https://api.github.com/users/mailgun/repos","events_url":"https://api.github.com/users/mailgun/events{/privacy}","received_events_url":"https://api.github.com/users/mailgun/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mailgun/pylemma","description":"Mailgun Cryptographic Tools","fork":false,"url":"https://api.github.com/repos/mailgun/pylemma","forks_url":"https://api.github.com/repos/mailgun/pylemma/forks","keys_url":"https://api.github.com/repos/mailgun/pylemma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mailgun/pylemma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mailgun/pylemma/teams","hooks_url":"https://api.github.com/repos/mailgun/pylemma/hooks","issue_events_url":"https://api.github.com/repos/mailgun/pylemma/issues/events{/number}","events_url":"https://api.github.com/repos/mailgun/pylemma/events","assignees_url":"https://api.github.com/repos/mailgun/pylemma/assignees{/user}","branches_url":"https://api.github.com/repos/mailgun/pylemma/branches{/branch}","tags_url":"https://api.github.com/repos/mailgun/pylemma/tags","blobs_url":"https://api.github.com/repos/mailgun/pylemma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mailgun/pylemma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mailgun/pylemma/git/refs{/sha}","trees_url":"https://api.github.com/repos/mailgun/pylemma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mailgun/pylemma/statuses/{sha}","languages_url":"https://api.github.com/repos/mailgun/pylemma/languages","stargazers_url":"https://api.github.com/repos/mailgun/pylemma/stargazers","contributors_url":"https://api.github.com/repos/mailgun/pylemma/contributors","subscribers_url":"https://api.github.com/repos/mailgun/pylemma/subscribers","subscription_url":"https://api.github.com/repos/mailgun/pylemma/subscription","commits_url":"https://api.github.com/repos/mailgun/pylemma/commits{/sha}","git_commits_url":"https://api.github.com/repos/mailgun/pylemma/git/commits{/sha}","comments_url":"https://api.github.com/repos/mailgun/pylemma/comments{/number}","issue_comment_url":"https://api.github.com/repos/mailgun/pylemma/issues/comments/{number}","contents_url":"https://api.github.com/repos/mailgun/pylemma/contents/{+path}","compare_url":"https://api.github.com/repos/mailgun/pylemma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mailgun/pylemma/merges","archive_url":"https://api.github.com/repos/mailgun/pylemma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mailgun/pylemma/downloads","issues_url":"https://api.github.com/repos/mailgun/pylemma/issues{/number}","pulls_url":"https://api.github.com/repos/mailgun/pylemma/pulls{/number}","milestones_url":"https://api.github.com/repos/mailgun/pylemma/milestones{/number}","notifications_url":"https://api.github.com/repos/mailgun/pylemma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mailgun/pylemma/labels{/name}","releases_url":"https://api.github.com/repos/mailgun/pylemma/releases{/id}","created_at":"2014-09-16T23:29:05Z","updated_at":"2014-09-16T23:42:53Z","pushed_at":"2014-12-05T22:56:35Z","git_url":"git://github.com/mailgun/pylemma.git","ssh_url":"git@github.com:mailgun/pylemma.git","clone_url":"https://github.com/mailgun/pylemma.git","svn_url":"https://github.com/mailgun/pylemma","homepage":null,"size":340,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"mailgun:master","ref":"master","sha":"aa1f569a40cb0ce40a4d1a50607067b28b3a85d0","user":{"login":"mailgun","id":447686,"avatar_url":"https://avatars.githubusercontent.com/u/447686?v=3","gravatar_id":"","url":"https://api.github.com/users/mailgun","html_url":"https://github.com/mailgun","followers_url":"https://api.github.com/users/mailgun/followers","following_url":"https://api.github.com/users/mailgun/following{/other_user}","gists_url":"https://api.github.com/users/mailgun/gists{/gist_id}","starred_url":"https://api.github.com/users/mailgun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mailgun/subscriptions","organizations_url":"https://api.github.com/users/mailgun/orgs","repos_url":"https://api.github.com/users/mailgun/repos","events_url":"https://api.github.com/users/mailgun/events{/privacy}","received_events_url":"https://api.github.com/users/mailgun/received_events","type":"Organization","site_admin":false},"repo":{"id":24121715,"name":"pylemma","full_name":"mailgun/pylemma","owner":{"login":"mailgun","id":447686,"avatar_url":"https://avatars.githubusercontent.com/u/447686?v=3","gravatar_id":"","url":"https://api.github.com/users/mailgun","html_url":"https://github.com/mailgun","followers_url":"https://api.github.com/users/mailgun/followers","following_url":"https://api.github.com/users/mailgun/following{/other_user}","gists_url":"https://api.github.com/users/mailgun/gists{/gist_id}","starred_url":"https://api.github.com/users/mailgun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mailgun/subscriptions","organizations_url":"https://api.github.com/users/mailgun/orgs","repos_url":"https://api.github.com/users/mailgun/repos","events_url":"https://api.github.com/users/mailgun/events{/privacy}","received_events_url":"https://api.github.com/users/mailgun/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mailgun/pylemma","description":"Mailgun Cryptographic Tools","fork":false,"url":"https://api.github.com/repos/mailgun/pylemma","forks_url":"https://api.github.com/repos/mailgun/pylemma/forks","keys_url":"https://api.github.com/repos/mailgun/pylemma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mailgun/pylemma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mailgun/pylemma/teams","hooks_url":"https://api.github.com/repos/mailgun/pylemma/hooks","issue_events_url":"https://api.github.com/repos/mailgun/pylemma/issues/events{/number}","events_url":"https://api.github.com/repos/mailgun/pylemma/events","assignees_url":"https://api.github.com/repos/mailgun/pylemma/assignees{/user}","branches_url":"https://api.github.com/repos/mailgun/pylemma/branches{/branch}","tags_url":"https://api.github.com/repos/mailgun/pylemma/tags","blobs_url":"https://api.github.com/repos/mailgun/pylemma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mailgun/pylemma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mailgun/pylemma/git/refs{/sha}","trees_url":"https://api.github.com/repos/mailgun/pylemma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mailgun/pylemma/statuses/{sha}","languages_url":"https://api.github.com/repos/mailgun/pylemma/languages","stargazers_url":"https://api.github.com/repos/mailgun/pylemma/stargazers","contributors_url":"https://api.github.com/repos/mailgun/pylemma/contributors","subscribers_url":"https://api.github.com/repos/mailgun/pylemma/subscribers","subscription_url":"https://api.github.com/repos/mailgun/pylemma/subscription","commits_url":"https://api.github.com/repos/mailgun/pylemma/commits{/sha}","git_commits_url":"https://api.github.com/repos/mailgun/pylemma/git/commits{/sha}","comments_url":"https://api.github.com/repos/mailgun/pylemma/comments{/number}","issue_comment_url":"https://api.github.com/repos/mailgun/pylemma/issues/comments/{number}","contents_url":"https://api.github.com/repos/mailgun/pylemma/contents/{+path}","compare_url":"https://api.github.com/repos/mailgun/pylemma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mailgun/pylemma/merges","archive_url":"https://api.github.com/repos/mailgun/pylemma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mailgun/pylemma/downloads","issues_url":"https://api.github.com/repos/mailgun/pylemma/issues{/number}","pulls_url":"https://api.github.com/repos/mailgun/pylemma/pulls{/number}","milestones_url":"https://api.github.com/repos/mailgun/pylemma/milestones{/number}","notifications_url":"https://api.github.com/repos/mailgun/pylemma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mailgun/pylemma/labels{/name}","releases_url":"https://api.github.com/repos/mailgun/pylemma/releases{/id}","created_at":"2014-09-16T23:29:05Z","updated_at":"2014-09-16T23:42:53Z","pushed_at":"2014-12-05T22:56:35Z","git_url":"git://github.com/mailgun/pylemma.git","ssh_url":"git@github.com:mailgun/pylemma.git","clone_url":"https://github.com/mailgun/pylemma.git","svn_url":"https://github.com/mailgun/pylemma","homepage":null,"size":340,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mailgun/pylemma/pulls/3"},"html":{"href":"https://github.com/mailgun/pylemma/pull/3"},"issue":{"href":"https://api.github.com/repos/mailgun/pylemma/issues/3"},"comments":{"href":"https://api.github.com/repos/mailgun/pylemma/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/mailgun/pylemma/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/mailgun/pylemma/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mailgun/pylemma/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/mailgun/pylemma/statuses/a4c4c2ac0565269494607db82a1703963a533578"}}}}