{"action":"created","comment":{"url":"https://api.github.com/repos/srcclr/security-headers/pulls/comments/38670467","id":38670467,"diff_hunk":"@@ -0,0 +1,34 @@\n+module Headlines\n+  class GenerateResults\n+    include Interactor\n+\n+    HTTP_RATINGS = [(-100..-1), (0..4), (5..9), (10..100)]\n+    CSP_RATINGS = [(-100..-6), (-5..-1), (0..4), (5..100)]\n+\n+    def call\n+      context.params = context.headers.map(&:params)\n+      context.scan_results = scan_results\n+      context.http_score = HTTP_RATINGS.index { |r| r.include?(http_score) }\n+      context.csp_score = CSP_RATINGS.index { |r| r.include?(csp_score) }\n+      context.score = overall_score\n+    end\n+\n+    private\n+\n+    def scan_results\n+      Hash[context.headers.map { |header| [header.name, header.score] }]\n+    end\n+\n+    def http_score\n+      context.scan_results.slice(*SECURITY_HEADERS).values.sum\n+    end\n+\n+    def csp_score\n+      context.scan_results[\"content-security-policy\"] || -15","path":"app/interactors/headlines/generate_results.rb","position":27,"original_position":27,"commit_id":"dcb7718adce35ad836e9b695803fbb5ef39708f9","original_commit_id":"dcb7718adce35ad836e9b695803fbb5ef39708f9","user":{"login":"CalebFenton","id":1356658,"avatar_url":"https://avatars.githubusercontent.com/u/1356658?v=3","gravatar_id":"","url":"https://api.github.com/users/CalebFenton","html_url":"https://github.com/CalebFenton","followers_url":"https://api.github.com/users/CalebFenton/followers","following_url":"https://api.github.com/users/CalebFenton/following{/other_user}","gists_url":"https://api.github.com/users/CalebFenton/gists{/gist_id}","starred_url":"https://api.github.com/users/CalebFenton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CalebFenton/subscriptions","organizations_url":"https://api.github.com/users/CalebFenton/orgs","repos_url":"https://api.github.com/users/CalebFenton/repos","events_url":"https://api.github.com/users/CalebFenton/events{/privacy}","received_events_url":"https://api.github.com/users/CalebFenton/received_events","type":"User","site_admin":false},"body":"Any way this could reference Headlines's CSP_RULES[:no_csp_header] instead of using magic number? It's preferable to have this defined in just one place.","created_at":"2015-09-03T17:14:50Z","updated_at":"2015-09-03T17:14:50Z","html_url":"https://github.com/srcclr/security-headers/pull/4#discussion_r38670467","pull_request_url":"https://api.github.com/repos/srcclr/security-headers/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/srcclr/security-headers/pulls/comments/38670467"},"html":{"href":"https://github.com/srcclr/security-headers/pull/4#discussion_r38670467"},"pull_request":{"href":"https://api.github.com/repos/srcclr/security-headers/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/srcclr/security-headers/pulls/4","id":44087504,"html_url":"https://github.com/srcclr/security-headers/pull/4","diff_url":"https://github.com/srcclr/security-headers/pull/4.diff","patch_url":"https://github.com/srcclr/security-headers/pull/4.patch","issue_url":"https://api.github.com/repos/srcclr/security-headers/issues/4","number":4,"state":"open","locked":false,"title":"Security headers update","user":{"login":"VladimirMikhailov","id":466382,"avatar_url":"https://avatars.githubusercontent.com/u/466382?v=3","gravatar_id":"","url":"https://api.github.com/users/VladimirMikhailov","html_url":"https://github.com/VladimirMikhailov","followers_url":"https://api.github.com/users/VladimirMikhailov/followers","following_url":"https://api.github.com/users/VladimirMikhailov/following{/other_user}","gists_url":"https://api.github.com/users/VladimirMikhailov/gists{/gist_id}","starred_url":"https://api.github.com/users/VladimirMikhailov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladimirMikhailov/subscriptions","organizations_url":"https://api.github.com/users/VladimirMikhailov/orgs","repos_url":"https://api.github.com/users/VladimirMikhailov/repos","events_url":"https://api.github.com/users/VladimirMikhailov/events{/privacy}","received_events_url":"https://api.github.com/users/VladimirMikhailov/received_events","type":"User","site_admin":false},"body":"Changelog:\r\n-----\r\n- Rebuild logic for CSP scoring\r\n- Add revised domain tests summary page\r\n- Make HEAD request on GET timeout\r\n- Use A,B,C,D grading\r\n- Downgrade rails for security headers to 4.1.13","created_at":"2015-09-03T09:50:27Z","updated_at":"2015-09-03T17:14:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6a385aa30e6f5f2daab1a58d2d0da1390c33844b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/srcclr/security-headers/pulls/4/commits","review_comments_url":"https://api.github.com/repos/srcclr/security-headers/pulls/4/comments","review_comment_url":"https://api.github.com/repos/srcclr/security-headers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/srcclr/security-headers/issues/4/comments","statuses_url":"https://api.github.com/repos/srcclr/security-headers/statuses/dcb7718adce35ad836e9b695803fbb5ef39708f9","head":{"label":"fs:master","ref":"master","sha":"dcb7718adce35ad836e9b695803fbb5ef39708f9","user":{"login":"fs","id":15136,"avatar_url":"https://avatars.githubusercontent.com/u/15136?v=3","gravatar_id":"","url":"https://api.github.com/users/fs","html_url":"https://github.com/fs","followers_url":"https://api.github.com/users/fs/followers","following_url":"https://api.github.com/users/fs/following{/other_user}","gists_url":"https://api.github.com/users/fs/gists{/gist_id}","starred_url":"https://api.github.com/users/fs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fs/subscriptions","organizations_url":"https://api.github.com/users/fs/orgs","repos_url":"https://api.github.com/users/fs/repos","events_url":"https://api.github.com/users/fs/events{/privacy}","received_events_url":"https://api.github.com/users/fs/received_events","type":"Organization","site_admin":false},"repo":{"id":40703153,"name":"security-headers","full_name":"fs/security-headers","owner":{"login":"fs","id":15136,"avatar_url":"https://avatars.githubusercontent.com/u/15136?v=3","gravatar_id":"","url":"https://api.github.com/users/fs","html_url":"https://github.com/fs","followers_url":"https://api.github.com/users/fs/followers","following_url":"https://api.github.com/users/fs/following{/other_user}","gists_url":"https://api.github.com/users/fs/gists{/gist_id}","starred_url":"https://api.github.com/users/fs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fs/subscriptions","organizations_url":"https://api.github.com/users/fs/orgs","repos_url":"https://api.github.com/users/fs/repos","events_url":"https://api.github.com/users/fs/events{/privacy}","received_events_url":"https://api.github.com/users/fs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fs/security-headers","description":"Security Headers Server Test","fork":true,"url":"https://api.github.com/repos/fs/security-headers","forks_url":"https://api.github.com/repos/fs/security-headers/forks","keys_url":"https://api.github.com/repos/fs/security-headers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fs/security-headers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fs/security-headers/teams","hooks_url":"https://api.github.com/repos/fs/security-headers/hooks","issue_events_url":"https://api.github.com/repos/fs/security-headers/issues/events{/number}","events_url":"https://api.github.com/repos/fs/security-headers/events","assignees_url":"https://api.github.com/repos/fs/security-headers/assignees{/user}","branches_url":"https://api.github.com/repos/fs/security-headers/branches{/branch}","tags_url":"https://api.github.com/repos/fs/security-headers/tags","blobs_url":"https://api.github.com/repos/fs/security-headers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fs/security-headers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fs/security-headers/git/refs{/sha}","trees_url":"https://api.github.com/repos/fs/security-headers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fs/security-headers/statuses/{sha}","languages_url":"https://api.github.com/repos/fs/security-headers/languages","stargazers_url":"https://api.github.com/repos/fs/security-headers/stargazers","contributors_url":"https://api.github.com/repos/fs/security-headers/contributors","subscribers_url":"https://api.github.com/repos/fs/security-headers/subscribers","subscription_url":"https://api.github.com/repos/fs/security-headers/subscription","commits_url":"https://api.github.com/repos/fs/security-headers/commits{/sha}","git_commits_url":"https://api.github.com/repos/fs/security-headers/git/commits{/sha}","comments_url":"https://api.github.com/repos/fs/security-headers/comments{/number}","issue_comment_url":"https://api.github.com/repos/fs/security-headers/issues/comments{/number}","contents_url":"https://api.github.com/repos/fs/security-headers/contents/{+path}","compare_url":"https://api.github.com/repos/fs/security-headers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fs/security-headers/merges","archive_url":"https://api.github.com/repos/fs/security-headers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fs/security-headers/downloads","issues_url":"https://api.github.com/repos/fs/security-headers/issues{/number}","pulls_url":"https://api.github.com/repos/fs/security-headers/pulls{/number}","milestones_url":"https://api.github.com/repos/fs/security-headers/milestones{/number}","notifications_url":"https://api.github.com/repos/fs/security-headers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fs/security-headers/labels{/name}","releases_url":"https://api.github.com/repos/fs/security-headers/releases{/id}","created_at":"2015-08-14T08:02:06Z","updated_at":"2015-08-14T09:03:39Z","pushed_at":"2015-09-03T17:06:41Z","git_url":"git://github.com/fs/security-headers.git","ssh_url":"git@github.com:fs/security-headers.git","clone_url":"https://github.com/fs/security-headers.git","svn_url":"https://github.com/fs/security-headers","homepage":"","size":4344,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"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":"srcclr:master","ref":"master","sha":"ee91292c00c203c0588c42eb1407360507252880","user":{"login":"srcclr","id":11744926,"avatar_url":"https://avatars.githubusercontent.com/u/11744926?v=3","gravatar_id":"","url":"https://api.github.com/users/srcclr","html_url":"https://github.com/srcclr","followers_url":"https://api.github.com/users/srcclr/followers","following_url":"https://api.github.com/users/srcclr/following{/other_user}","gists_url":"https://api.github.com/users/srcclr/gists{/gist_id}","starred_url":"https://api.github.com/users/srcclr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srcclr/subscriptions","organizations_url":"https://api.github.com/users/srcclr/orgs","repos_url":"https://api.github.com/users/srcclr/repos","events_url":"https://api.github.com/users/srcclr/events{/privacy}","received_events_url":"https://api.github.com/users/srcclr/received_events","type":"Organization","site_admin":false},"repo":{"id":40664301,"name":"security-headers","full_name":"srcclr/security-headers","owner":{"login":"srcclr","id":11744926,"avatar_url":"https://avatars.githubusercontent.com/u/11744926?v=3","gravatar_id":"","url":"https://api.github.com/users/srcclr","html_url":"https://github.com/srcclr","followers_url":"https://api.github.com/users/srcclr/followers","following_url":"https://api.github.com/users/srcclr/following{/other_user}","gists_url":"https://api.github.com/users/srcclr/gists{/gist_id}","starred_url":"https://api.github.com/users/srcclr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srcclr/subscriptions","organizations_url":"https://api.github.com/users/srcclr/orgs","repos_url":"https://api.github.com/users/srcclr/repos","events_url":"https://api.github.com/users/srcclr/events{/privacy}","received_events_url":"https://api.github.com/users/srcclr/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/srcclr/security-headers","description":"Security Headers","fork":false,"url":"https://api.github.com/repos/srcclr/security-headers","forks_url":"https://api.github.com/repos/srcclr/security-headers/forks","keys_url":"https://api.github.com/repos/srcclr/security-headers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/srcclr/security-headers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/srcclr/security-headers/teams","hooks_url":"https://api.github.com/repos/srcclr/security-headers/hooks","issue_events_url":"https://api.github.com/repos/srcclr/security-headers/issues/events{/number}","events_url":"https://api.github.com/repos/srcclr/security-headers/events","assignees_url":"https://api.github.com/repos/srcclr/security-headers/assignees{/user}","branches_url":"https://api.github.com/repos/srcclr/security-headers/branches{/branch}","tags_url":"https://api.github.com/repos/srcclr/security-headers/tags","blobs_url":"https://api.github.com/repos/srcclr/security-headers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/srcclr/security-headers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/srcclr/security-headers/git/refs{/sha}","trees_url":"https://api.github.com/repos/srcclr/security-headers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/srcclr/security-headers/statuses/{sha}","languages_url":"https://api.github.com/repos/srcclr/security-headers/languages","stargazers_url":"https://api.github.com/repos/srcclr/security-headers/stargazers","contributors_url":"https://api.github.com/repos/srcclr/security-headers/contributors","subscribers_url":"https://api.github.com/repos/srcclr/security-headers/subscribers","subscription_url":"https://api.github.com/repos/srcclr/security-headers/subscription","commits_url":"https://api.github.com/repos/srcclr/security-headers/commits{/sha}","git_commits_url":"https://api.github.com/repos/srcclr/security-headers/git/commits{/sha}","comments_url":"https://api.github.com/repos/srcclr/security-headers/comments{/number}","issue_comment_url":"https://api.github.com/repos/srcclr/security-headers/issues/comments{/number}","contents_url":"https://api.github.com/repos/srcclr/security-headers/contents/{+path}","compare_url":"https://api.github.com/repos/srcclr/security-headers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/srcclr/security-headers/merges","archive_url":"https://api.github.com/repos/srcclr/security-headers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/srcclr/security-headers/downloads","issues_url":"https://api.github.com/repos/srcclr/security-headers/issues{/number}","pulls_url":"https://api.github.com/repos/srcclr/security-headers/pulls{/number}","milestones_url":"https://api.github.com/repos/srcclr/security-headers/milestones{/number}","notifications_url":"https://api.github.com/repos/srcclr/security-headers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/srcclr/security-headers/labels{/name}","releases_url":"https://api.github.com/repos/srcclr/security-headers/releases{/id}","created_at":"2015-08-13T14:50:02Z","updated_at":"2015-08-22T11:48:27Z","pushed_at":"2015-09-03T13:00:39Z","git_url":"git://github.com/srcclr/security-headers.git","ssh_url":"git@github.com:srcclr/security-headers.git","clone_url":"https://github.com/srcclr/security-headers.git","svn_url":"https://github.com/srcclr/security-headers","homepage":"","size":4290,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/srcclr/security-headers/pulls/4"},"html":{"href":"https://github.com/srcclr/security-headers/pull/4"},"issue":{"href":"https://api.github.com/repos/srcclr/security-headers/issues/4"},"comments":{"href":"https://api.github.com/repos/srcclr/security-headers/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/srcclr/security-headers/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/srcclr/security-headers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/srcclr/security-headers/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/srcclr/security-headers/statuses/dcb7718adce35ad836e9b695803fbb5ef39708f9"}}}}