{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/comments/44133052","id":44133052,"diff_hunk":"@@ -0,0 +1,62 @@\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/**\n+ * Route to report CSP Violations to metrics\n+ */\n+\n+var DEFAULT_RATE_LIMIT = 90;\n+\n+module.exports = function (options) {\n+  options = options || {};\n+\n+  /**\n+   * Rate limit 'rateLimitPercentage' % of messages.\n+   * @param rateLimitPercentage\n+   * @returns {boolean}\n+   */\n+  function isRateLimited(rateLimitPercentage) {\n+    var RATE_LIMIT = rateLimitPercentage;\n+    // rate limit can be 0\n+    if (typeof rateLimitPercentage === 'undefined') {\n+      RATE_LIMIT = DEFAULT_RATE_LIMIT;\n+    }\n+    var min = 0;\n+    var max = 100;\n+\n+    var rand = min + Math.floor(Math.random() * (max - min + 1));","path":"server/lib/routes/post-csp.js","position":28,"original_position":28,"commit_id":"647d0274384b3e10746514ad811482cb5d1b68cb","original_commit_id":"647d0274384b3e10746514ad811482cb5d1b68cb","user":{"login":"shane-tomlinson","id":848085,"avatar_url":"https://avatars.githubusercontent.com/u/848085?v=3","gravatar_id":"","url":"https://api.github.com/users/shane-tomlinson","html_url":"https://github.com/shane-tomlinson","followers_url":"https://api.github.com/users/shane-tomlinson/followers","following_url":"https://api.github.com/users/shane-tomlinson/following{/other_user}","gists_url":"https://api.github.com/users/shane-tomlinson/gists{/gist_id}","starred_url":"https://api.github.com/users/shane-tomlinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shane-tomlinson/subscriptions","organizations_url":"https://api.github.com/users/shane-tomlinson/orgs","repos_url":"https://api.github.com/users/shane-tomlinson/repos","events_url":"https://api.github.com/users/shane-tomlinson/events{/privacy}","received_events_url":"https://api.github.com/users/shane-tomlinson/received_events","type":"User","site_admin":false},"body":"Ahha, I see this code comes from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random to include both endpoints. Could this be made into its own function (probably preferable) or simplified since both min and max are hard coded:\r\n\r\n```js\r\nvar rand = Math.floor(Math.random() * (100 + 1));\r\n```\r\n\r\n","created_at":"2015-11-06T12:51:48Z","updated_at":"2015-11-06T12:51:48Z","html_url":"https://github.com/mozilla/fxa-content-server/pull/3179#discussion_r44133052","pull_request_url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3179","_links":{"self":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/comments/44133052"},"html":{"href":"https://github.com/mozilla/fxa-content-server/pull/3179#discussion_r44133052"},"pull_request":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3179"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3179","id":47843702,"html_url":"https://github.com/mozilla/fxa-content-server/pull/3179","diff_url":"https://github.com/mozilla/fxa-content-server/pull/3179.diff","patch_url":"https://github.com/mozilla/fxa-content-server/pull/3179.patch","issue_url":"https://api.github.com/repos/mozilla/fxa-content-server/issues/3179","number":3179,"state":"open","locked":false,"title":"feat(csp): enable report only CSP in prodiction","user":{"login":"vladikoff","id":128755,"avatar_url":"https://avatars.githubusercontent.com/u/128755?v=3","gravatar_id":"","url":"https://api.github.com/users/vladikoff","html_url":"https://github.com/vladikoff","followers_url":"https://api.github.com/users/vladikoff/followers","following_url":"https://api.github.com/users/vladikoff/following{/other_user}","gists_url":"https://api.github.com/users/vladikoff/gists{/gist_id}","starred_url":"https://api.github.com/users/vladikoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladikoff/subscriptions","organizations_url":"https://api.github.com/users/vladikoff/orgs","repos_url":"https://api.github.com/users/vladikoff/repos","events_url":"https://api.github.com/users/vladikoff/events{/privacy}","received_events_url":"https://api.github.com/users/vladikoff/received_events","type":"User","site_admin":false},"body":"Fixes #1426","created_at":"2015-10-15T21:23:31Z","updated_at":"2015-11-06T12:51:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa0e314008e795965e7e4f7edb459d6dbc37fb9e","assignee":{"login":"shane-tomlinson","id":848085,"avatar_url":"https://avatars.githubusercontent.com/u/848085?v=3","gravatar_id":"","url":"https://api.github.com/users/shane-tomlinson","html_url":"https://github.com/shane-tomlinson","followers_url":"https://api.github.com/users/shane-tomlinson/followers","following_url":"https://api.github.com/users/shane-tomlinson/following{/other_user}","gists_url":"https://api.github.com/users/shane-tomlinson/gists{/gist_id}","starred_url":"https://api.github.com/users/shane-tomlinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shane-tomlinson/subscriptions","organizations_url":"https://api.github.com/users/shane-tomlinson/orgs","repos_url":"https://api.github.com/users/shane-tomlinson/repos","events_url":"https://api.github.com/users/shane-tomlinson/events{/privacy}","received_events_url":"https://api.github.com/users/shane-tomlinson/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3179/commits","review_comments_url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3179/comments","review_comment_url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/fxa-content-server/issues/3179/comments","statuses_url":"https://api.github.com/repos/mozilla/fxa-content-server/statuses/647d0274384b3e10746514ad811482cb5d1b68cb","head":{"label":"vladikoff:i1426","ref":"i1426","sha":"647d0274384b3e10746514ad811482cb5d1b68cb","user":{"login":"vladikoff","id":128755,"avatar_url":"https://avatars.githubusercontent.com/u/128755?v=3","gravatar_id":"","url":"https://api.github.com/users/vladikoff","html_url":"https://github.com/vladikoff","followers_url":"https://api.github.com/users/vladikoff/followers","following_url":"https://api.github.com/users/vladikoff/following{/other_user}","gists_url":"https://api.github.com/users/vladikoff/gists{/gist_id}","starred_url":"https://api.github.com/users/vladikoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladikoff/subscriptions","organizations_url":"https://api.github.com/users/vladikoff/orgs","repos_url":"https://api.github.com/users/vladikoff/repos","events_url":"https://api.github.com/users/vladikoff/events{/privacy}","received_events_url":"https://api.github.com/users/vladikoff/received_events","type":"User","site_admin":false},"repo":{"id":15786683,"name":"fxa-content-server","full_name":"vladikoff/fxa-content-server","owner":{"login":"vladikoff","id":128755,"avatar_url":"https://avatars.githubusercontent.com/u/128755?v=3","gravatar_id":"","url":"https://api.github.com/users/vladikoff","html_url":"https://github.com/vladikoff","followers_url":"https://api.github.com/users/vladikoff/followers","following_url":"https://api.github.com/users/vladikoff/following{/other_user}","gists_url":"https://api.github.com/users/vladikoff/gists{/gist_id}","starred_url":"https://api.github.com/users/vladikoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladikoff/subscriptions","organizations_url":"https://api.github.com/users/vladikoff/orgs","repos_url":"https://api.github.com/users/vladikoff/repos","events_url":"https://api.github.com/users/vladikoff/events{/privacy}","received_events_url":"https://api.github.com/users/vladikoff/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vladikoff/fxa-content-server","description":"Firefox Accounts","fork":true,"url":"https://api.github.com/repos/vladikoff/fxa-content-server","forks_url":"https://api.github.com/repos/vladikoff/fxa-content-server/forks","keys_url":"https://api.github.com/repos/vladikoff/fxa-content-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vladikoff/fxa-content-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vladikoff/fxa-content-server/teams","hooks_url":"https://api.github.com/repos/vladikoff/fxa-content-server/hooks","issue_events_url":"https://api.github.com/repos/vladikoff/fxa-content-server/issues/events{/number}","events_url":"https://api.github.com/repos/vladikoff/fxa-content-server/events","assignees_url":"https://api.github.com/repos/vladikoff/fxa-content-server/assignees{/user}","branches_url":"https://api.github.com/repos/vladikoff/fxa-content-server/branches{/branch}","tags_url":"https://api.github.com/repos/vladikoff/fxa-content-server/tags","blobs_url":"https://api.github.com/repos/vladikoff/fxa-content-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vladikoff/fxa-content-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vladikoff/fxa-content-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/vladikoff/fxa-content-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vladikoff/fxa-content-server/statuses/{sha}","languages_url":"https://api.github.com/repos/vladikoff/fxa-content-server/languages","stargazers_url":"https://api.github.com/repos/vladikoff/fxa-content-server/stargazers","contributors_url":"https://api.github.com/repos/vladikoff/fxa-content-server/contributors","subscribers_url":"https://api.github.com/repos/vladikoff/fxa-content-server/subscribers","subscription_url":"https://api.github.com/repos/vladikoff/fxa-content-server/subscription","commits_url":"https://api.github.com/repos/vladikoff/fxa-content-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/vladikoff/fxa-content-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/vladikoff/fxa-content-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/vladikoff/fxa-content-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/vladikoff/fxa-content-server/contents/{+path}","compare_url":"https://api.github.com/repos/vladikoff/fxa-content-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vladikoff/fxa-content-server/merges","archive_url":"https://api.github.com/repos/vladikoff/fxa-content-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vladikoff/fxa-content-server/downloads","issues_url":"https://api.github.com/repos/vladikoff/fxa-content-server/issues{/number}","pulls_url":"https://api.github.com/repos/vladikoff/fxa-content-server/pulls{/number}","milestones_url":"https://api.github.com/repos/vladikoff/fxa-content-server/milestones{/number}","notifications_url":"https://api.github.com/repos/vladikoff/fxa-content-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vladikoff/fxa-content-server/labels{/name}","releases_url":"https://api.github.com/repos/vladikoff/fxa-content-server/releases{/id}","created_at":"2014-01-10T02:53:37Z","updated_at":"2015-04-02T19:22:44Z","pushed_at":"2015-11-04T22:12:19Z","git_url":"git://github.com/vladikoff/fxa-content-server.git","ssh_url":"git@github.com:vladikoff/fxa-content-server.git","clone_url":"https://github.com/vladikoff/fxa-content-server.git","svn_url":"https://github.com/vladikoff/fxa-content-server","homepage":"","size":12922,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"a5ef0c04e4797367fcb8de847e678923da79afd6","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":11778024,"name":"fxa-content-server","full_name":"mozilla/fxa-content-server","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/fxa-content-server","description":"Firefox Accounts Content Server","fork":false,"url":"https://api.github.com/repos/mozilla/fxa-content-server","forks_url":"https://api.github.com/repos/mozilla/fxa-content-server/forks","keys_url":"https://api.github.com/repos/mozilla/fxa-content-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/fxa-content-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/fxa-content-server/teams","hooks_url":"https://api.github.com/repos/mozilla/fxa-content-server/hooks","issue_events_url":"https://api.github.com/repos/mozilla/fxa-content-server/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/fxa-content-server/events","assignees_url":"https://api.github.com/repos/mozilla/fxa-content-server/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/fxa-content-server/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/fxa-content-server/tags","blobs_url":"https://api.github.com/repos/mozilla/fxa-content-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/fxa-content-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/fxa-content-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/fxa-content-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/fxa-content-server/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/fxa-content-server/languages","stargazers_url":"https://api.github.com/repos/mozilla/fxa-content-server/stargazers","contributors_url":"https://api.github.com/repos/mozilla/fxa-content-server/contributors","subscribers_url":"https://api.github.com/repos/mozilla/fxa-content-server/subscribers","subscription_url":"https://api.github.com/repos/mozilla/fxa-content-server/subscription","commits_url":"https://api.github.com/repos/mozilla/fxa-content-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/fxa-content-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/fxa-content-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/fxa-content-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/fxa-content-server/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/fxa-content-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/fxa-content-server/merges","archive_url":"https://api.github.com/repos/mozilla/fxa-content-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/fxa-content-server/downloads","issues_url":"https://api.github.com/repos/mozilla/fxa-content-server/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/fxa-content-server/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/fxa-content-server/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/fxa-content-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/fxa-content-server/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/fxa-content-server/releases{/id}","created_at":"2013-07-30T23:35:35Z","updated_at":"2015-11-05T02:41:06Z","pushed_at":"2015-11-06T11:55:00Z","git_url":"git://github.com/mozilla/fxa-content-server.git","ssh_url":"git@github.com:mozilla/fxa-content-server.git","clone_url":"https://github.com/mozilla/fxa-content-server.git","svn_url":"https://github.com/mozilla/fxa-content-server","homepage":"","size":31397,"stargazers_count":80,"watchers_count":80,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":50,"mirror_url":null,"open_issues_count":148,"forks":50,"open_issues":148,"watchers":80,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3179"},"html":{"href":"https://github.com/mozilla/fxa-content-server/pull/3179"},"issue":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/issues/3179"},"comments":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/issues/3179/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3179/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/pulls/3179/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/fxa-content-server/statuses/647d0274384b3e10746514ad811482cb5d1b68cb"}}}}