Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions pydotorg/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from pathlib import Path

from csp.constants import NONCE, SELF, UNSAFE_INLINE
from decouple import config
from dj_database_url import parse as dj_database_url_parser
from django.contrib.messages import constants
Expand Down Expand Up @@ -311,16 +312,36 @@
# enforcing. Rollout tracked in #3041.
CONTENT_SECURITY_POLICY_REPORT_ONLY = {
"DIRECTIVES": {
"default-src": ["'self'"],
"script-src": ["'self'"],
"style-src": ["'self'"],
"img-src": ["'self'", "data:"],
"font-src": ["'self'"],
"connect-src": ["'self'"],
"frame-ancestors": ["'self'"],
"base-uri": ["'self'"],
"default-src": [SELF],
"script-src": [
SELF,
NONCE,
"https://analytics.python.org",
"https://media.ethicalads.io",
"https://ajax.googleapis.com",
],
"style-src": [
SELF,
# Modernizr injects <style> tags and requires
# using 'unsafe-inline'. If we remove Modernizr
# then we can remove this directive.
UNSAFE_INLINE,
"https://ajax.googleapis.com",
],
"img-src": [SELF, "data:", "https://media.ethicalads.io"],
"font-src": [SELF, "data:"],
"connect-src": [
SELF,
"https://console.python.org",
"https://analytics.python.org",
"https://server.ethicalads.io",
# Status Page, host included in 'static/js/script.js'
"https://2p66nmmycsj3.statuspage.io",
],
"frame-ancestors": [SELF],
"base-uri": [SELF],
"object-src": ["'none'"],
"form-action": ["'self'"],
"form-action": [SELF],
"report-uri": [_CSP_REPORT_URI],
# When we upgrade to Django 6, begin using
# 'report-to' and 'Reporting-Endpoints' header.
Expand Down
14 changes: 7 additions & 7 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

<meta charset="utf-8">

<link rel="prefetch" href="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
<link rel="prefetch" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js">
<link rel="prefetch" href="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
<link rel="prefetch" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js">

<meta name="application-name" content="{{ SITE_INFO.site_name }}">
<meta name="apple-mobile-web-app-title" content="{{ SITE_INFO.site_name }}">
Expand All @@ -37,7 +37,7 @@
<link rel="stylesheet" href="{{ STATIC_URL }}stylesheets/mq.css" media="not print, speech">
{% endcomment %}

<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">

{# Place icon files in the root if possible (let browsers look for them where they expect them to be) #}
<link rel="icon" type="image/x-icon" href="{{ STATIC_URL }}favicon.ico">
Expand Down Expand Up @@ -307,10 +307,10 @@
</div><!-- end #touchnav-wrapper -->

{% block javascript %}
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="{{ STATIC_URL }}js/libs/jquery-1.8.2.min.js"><\/script>')</script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script>window.jQuery || document.write('<script src="{{ STATIC_URL }}js/libs/jquery-ui-1.12.1.min.js"><\/script>')</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script nonce="{{ request.csp_nonce }}">window.jQuery || document.write('<script src="{{ STATIC_URL }}js/libs/jquery-1.8.2.min.js"><\/script>')</script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script nonce="{{ request.csp_nonce }}">window.jQuery || document.write('<script src="{{ STATIC_URL }}js/libs/jquery-ui-1.12.1.min.js"><\/script>')</script>

<script src="{{ STATIC_URL }}js/libs/masonry.pkgd.min.js"></script>
<script src="{{ STATIC_URL }}js/libs/html-includes.js"></script>
Expand Down