{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/django-csp/pulls/comments/86027557","pull_request_review_id":6707413,"id":86027557,"diff_hunk":"@@ -53,9 +61,20 @@ def build_policy(config=None, update=None, replace=None):\n                 csp[k] += tuple(v)\n \n     report_uri = csp.pop('report-uri', None)\n+    upgrade_insecure_requests = csp.pop('upgrade-insecure-requests', None)\n+    block_all_mixed_content = csp.pop('block-all-mixed-content', None)\n+\n     policy = ['%s %s' % (kk, ' '.join(vv)) for kk, vv in\n               csp.items() if vv is not None]\n+\n     if report_uri:\n         report_uri = map(force_text, report_uri)\n         policy.append('report-uri %s' % ' '.join(report_uri))\n+\n+    if upgrade_insecure_requests:\n+        policy.append('upgrade-insecure-requests ')\n+\n+    if block_all_mixed_content:\n+        policy.append('block-all-mixed-content ')","path":"csp/utils.py","position":33,"original_position":33,"commit_id":"503a6bebcc9acc7f2b0383c50e1e39f86d6d4927","original_commit_id":"503a6bebcc9acc7f2b0383c50e1e39f86d6d4927","user":{"login":"mythmon","id":305049,"avatar_url":"https://avatars.githubusercontent.com/u/305049?v=3","gravatar_id":"","url":"https://api.github.com/users/mythmon","html_url":"https://github.com/mythmon","followers_url":"https://api.github.com/users/mythmon/followers","following_url":"https://api.github.com/users/mythmon/following{/other_user}","gists_url":"https://api.github.com/users/mythmon/gists{/gist_id}","starred_url":"https://api.github.com/users/mythmon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mythmon/subscriptions","organizations_url":"https://api.github.com/users/mythmon/orgs","repos_url":"https://api.github.com/users/mythmon/repos","events_url":"https://api.github.com/users/mythmon/events{/privacy}","received_events_url":"https://api.github.com/users/mythmon/received_events","type":"User","site_admin":false},"body":"Instead of special casing `upgrade-insecure-requests` and `block-all-mixed-content`, what do you think about changing the policy iterator above (`policy = ['%s %s' ...`) to make items with a value of `True` work like these items need to? Something like\r\n\r\n```python\r\npolicy_parts = []\r\n\r\nfor key, value in csp.items():\r\n    if value is True:\r\n        policy_parts.append(key)\r\n    elif value is False:\r\n        pass\r\n    else:\r\n        policy.append('%s %s' % (key, ' '.join(value))\r\n```\r\n\r\nAdditionally, I don't think that a space is needed at the end here, if we decide to keep it.","created_at":"2016-11-01T21:18:58Z","updated_at":"2016-11-01T21:22:10Z","html_url":"https://github.com/mozilla/django-csp/pull/74#discussion_r86027557","pull_request_url":"https://api.github.com/repos/mozilla/django-csp/pulls/74","_links":{"self":{"href":"https://api.github.com/repos/mozilla/django-csp/pulls/comments/86027557"},"html":{"href":"https://github.com/mozilla/django-csp/pull/74#discussion_r86027557"},"pull_request":{"href":"https://api.github.com/repos/mozilla/django-csp/pulls/74"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/django-csp/pulls/74","id":91797092,"html_url":"https://github.com/mozilla/django-csp/pull/74","diff_url":"https://github.com/mozilla/django-csp/pull/74.diff","patch_url":"https://github.com/mozilla/django-csp/pull/74.patch","issue_url":"https://api.github.com/repos/mozilla/django-csp/issues/74","number":74,"state":"open","locked":false,"title":"Add missing directives","user":{"login":"g-k","id":226605,"avatar_url":"https://avatars.githubusercontent.com/u/226605?v=3","gravatar_id":"","url":"https://api.github.com/users/g-k","html_url":"https://github.com/g-k","followers_url":"https://api.github.com/users/g-k/followers","following_url":"https://api.github.com/users/g-k/following{/other_user}","gists_url":"https://api.github.com/users/g-k/gists{/gist_id}","starred_url":"https://api.github.com/users/g-k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/g-k/subscriptions","organizations_url":"https://api.github.com/users/g-k/orgs","repos_url":"https://api.github.com/users/g-k/repos","events_url":"https://api.github.com/users/g-k/events{/privacy}","received_events_url":"https://api.github.com/users/g-k/received_events","type":"User","site_admin":false},"body":"Adds the following CSP directives:\r\n\r\n* manifest-src https://github.com/mozilla/django-csp/issues/60\r\n* worker-src\r\n* plugin-types https://github.com/mozilla/django-csp/issues/59\r\n* require-sri-for\r\n* upgrade-insecure-requests https://github.com/mozilla/django-csp/issues/58\r\n* block-all-mixed-content\r\n\r\nIs this package tracking CSP drafts, shipped CSP directives, or both?\r\n\r\nrequire-sri-for, upgrade-insecure-requests, block-all-mixed-content, and the CSP 3 headers are still in draft.  There is a tiny overhead to including them, but we gain forward compatibility assuming they stay in the specs.\r\n\r\nOn the other hand, referrer-policy https://github.com/mozilla/django-csp/issues/57 and reflected-xss were removed from CSP, but adding them could still benefit users at the cost of some historical baggage.","created_at":"2016-11-01T14:51:21Z","updated_at":"2016-11-01T21:22:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b467b6e51edb75c7d1d8a788a85563996303235f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/django-csp/pulls/74/commits","review_comments_url":"https://api.github.com/repos/mozilla/django-csp/pulls/74/comments","review_comment_url":"https://api.github.com/repos/mozilla/django-csp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/django-csp/issues/74/comments","statuses_url":"https://api.github.com/repos/mozilla/django-csp/statuses/503a6bebcc9acc7f2b0383c50e1e39f86d6d4927","head":{"label":"g-k:add-missing-directives","ref":"add-missing-directives","sha":"503a6bebcc9acc7f2b0383c50e1e39f86d6d4927","user":{"login":"g-k","id":226605,"avatar_url":"https://avatars.githubusercontent.com/u/226605?v=3","gravatar_id":"","url":"https://api.github.com/users/g-k","html_url":"https://github.com/g-k","followers_url":"https://api.github.com/users/g-k/followers","following_url":"https://api.github.com/users/g-k/following{/other_user}","gists_url":"https://api.github.com/users/g-k/gists{/gist_id}","starred_url":"https://api.github.com/users/g-k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/g-k/subscriptions","organizations_url":"https://api.github.com/users/g-k/orgs","repos_url":"https://api.github.com/users/g-k/repos","events_url":"https://api.github.com/users/g-k/events{/privacy}","received_events_url":"https://api.github.com/users/g-k/received_events","type":"User","site_admin":false},"repo":{"id":72468626,"name":"django-csp","full_name":"g-k/django-csp","owner":{"login":"g-k","id":226605,"avatar_url":"https://avatars.githubusercontent.com/u/226605?v=3","gravatar_id":"","url":"https://api.github.com/users/g-k","html_url":"https://github.com/g-k","followers_url":"https://api.github.com/users/g-k/followers","following_url":"https://api.github.com/users/g-k/following{/other_user}","gists_url":"https://api.github.com/users/g-k/gists{/gist_id}","starred_url":"https://api.github.com/users/g-k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/g-k/subscriptions","organizations_url":"https://api.github.com/users/g-k/orgs","repos_url":"https://api.github.com/users/g-k/repos","events_url":"https://api.github.com/users/g-k/events{/privacy}","received_events_url":"https://api.github.com/users/g-k/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/g-k/django-csp","description":"Content Security Policy for Django.","fork":true,"url":"https://api.github.com/repos/g-k/django-csp","forks_url":"https://api.github.com/repos/g-k/django-csp/forks","keys_url":"https://api.github.com/repos/g-k/django-csp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/g-k/django-csp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/g-k/django-csp/teams","hooks_url":"https://api.github.com/repos/g-k/django-csp/hooks","issue_events_url":"https://api.github.com/repos/g-k/django-csp/issues/events{/number}","events_url":"https://api.github.com/repos/g-k/django-csp/events","assignees_url":"https://api.github.com/repos/g-k/django-csp/assignees{/user}","branches_url":"https://api.github.com/repos/g-k/django-csp/branches{/branch}","tags_url":"https://api.github.com/repos/g-k/django-csp/tags","blobs_url":"https://api.github.com/repos/g-k/django-csp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/g-k/django-csp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/g-k/django-csp/git/refs{/sha}","trees_url":"https://api.github.com/repos/g-k/django-csp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/g-k/django-csp/statuses/{sha}","languages_url":"https://api.github.com/repos/g-k/django-csp/languages","stargazers_url":"https://api.github.com/repos/g-k/django-csp/stargazers","contributors_url":"https://api.github.com/repos/g-k/django-csp/contributors","subscribers_url":"https://api.github.com/repos/g-k/django-csp/subscribers","subscription_url":"https://api.github.com/repos/g-k/django-csp/subscription","commits_url":"https://api.github.com/repos/g-k/django-csp/commits{/sha}","git_commits_url":"https://api.github.com/repos/g-k/django-csp/git/commits{/sha}","comments_url":"https://api.github.com/repos/g-k/django-csp/comments{/number}","issue_comment_url":"https://api.github.com/repos/g-k/django-csp/issues/comments{/number}","contents_url":"https://api.github.com/repos/g-k/django-csp/contents/{+path}","compare_url":"https://api.github.com/repos/g-k/django-csp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/g-k/django-csp/merges","archive_url":"https://api.github.com/repos/g-k/django-csp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/g-k/django-csp/downloads","issues_url":"https://api.github.com/repos/g-k/django-csp/issues{/number}","pulls_url":"https://api.github.com/repos/g-k/django-csp/pulls{/number}","milestones_url":"https://api.github.com/repos/g-k/django-csp/milestones{/number}","notifications_url":"https://api.github.com/repos/g-k/django-csp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/g-k/django-csp/labels{/name}","releases_url":"https://api.github.com/repos/g-k/django-csp/releases{/id}","deployments_url":"https://api.github.com/repos/g-k/django-csp/deployments","created_at":"2016-10-31T18:59:37Z","updated_at":"2016-10-31T18:59:39Z","pushed_at":"2016-11-01T14:36:19Z","git_url":"git://github.com/g-k/django-csp.git","ssh_url":"git@github.com:g-k/django-csp.git","clone_url":"https://github.com/g-k/django-csp.git","svn_url":"https://github.com/g-k/django-csp","homepage":"http://django-csp.readthedocs.org/","size":113,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"de1e45c3668a1fe37f6c89887d5aabeb9251e5f8","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":775086,"name":"django-csp","full_name":"mozilla/django-csp","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/django-csp","description":"Content Security Policy for Django.","fork":false,"url":"https://api.github.com/repos/mozilla/django-csp","forks_url":"https://api.github.com/repos/mozilla/django-csp/forks","keys_url":"https://api.github.com/repos/mozilla/django-csp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/django-csp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/django-csp/teams","hooks_url":"https://api.github.com/repos/mozilla/django-csp/hooks","issue_events_url":"https://api.github.com/repos/mozilla/django-csp/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/django-csp/events","assignees_url":"https://api.github.com/repos/mozilla/django-csp/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/django-csp/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/django-csp/tags","blobs_url":"https://api.github.com/repos/mozilla/django-csp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/django-csp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/django-csp/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/django-csp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/django-csp/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/django-csp/languages","stargazers_url":"https://api.github.com/repos/mozilla/django-csp/stargazers","contributors_url":"https://api.github.com/repos/mozilla/django-csp/contributors","subscribers_url":"https://api.github.com/repos/mozilla/django-csp/subscribers","subscription_url":"https://api.github.com/repos/mozilla/django-csp/subscription","commits_url":"https://api.github.com/repos/mozilla/django-csp/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/django-csp/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/django-csp/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/django-csp/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/django-csp/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/django-csp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/django-csp/merges","archive_url":"https://api.github.com/repos/mozilla/django-csp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/django-csp/downloads","issues_url":"https://api.github.com/repos/mozilla/django-csp/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/django-csp/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/django-csp/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/django-csp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/django-csp/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/django-csp/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/django-csp/deployments","created_at":"2010-07-14T18:00:59Z","updated_at":"2016-10-26T17:51:42Z","pushed_at":"2016-11-01T14:51:21Z","git_url":"git://github.com/mozilla/django-csp.git","ssh_url":"git@github.com:mozilla/django-csp.git","clone_url":"https://github.com/mozilla/django-csp.git","svn_url":"https://github.com/mozilla/django-csp","homepage":"http://django-csp.readthedocs.org/","size":118,"stargazers_count":94,"watchers_count":94,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":14,"forks":35,"open_issues":14,"watchers":94,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/django-csp/pulls/74"},"html":{"href":"https://github.com/mozilla/django-csp/pull/74"},"issue":{"href":"https://api.github.com/repos/mozilla/django-csp/issues/74"},"comments":{"href":"https://api.github.com/repos/mozilla/django-csp/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/django-csp/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/django-csp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/django-csp/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/django-csp/statuses/503a6bebcc9acc7f2b0383c50e1e39f86d6d4927"}}}}
{"actor":{"display_login":"mythmon"}}