Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable X-XSS protection by default #28

Merged
merged 6 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Python 3.9
uses: actions/setup-python@v2
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11

- name: Install dependencies
run: |
Expand All @@ -38,13 +38,13 @@ jobs:

strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
6 changes: 1 addition & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ The default configuration:
`X-Frame-Options <https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options>`_
to ``SAMEORIGIN`` to avoid
`clickjacking <https://en.wikipedia.org/wiki/Clickjacking>`_.
- Sets `X-XSS-Protection
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection>`_
to enable a cross site scripting filter for IE and Safari (note Chrome has
removed this and Firefox never supported it).
- Sets `X-Content-Type-Options
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options>`_
to prevent content type sniffing.
Expand Down Expand Up @@ -130,7 +126,7 @@ Options
directly and only save them instead.

- ``x_content_type_options``, default ``True``, Protects against MIME sniffing vulnerabilities (`about Content Type Options <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options>`_).
- ``x_xss_protection``, default ``True``, Protects against cross-site scripting (XSS) attacks (`about XSS Protection <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection>`_).
- ``x_xss_protection``, default ``False``, Protects against cross-site scripting (XSS) attacks (`about XSS Protection <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection>`_).
Jonakemon marked this conversation as resolved.
Show resolved Hide resolved

For a full list of (security) headers, check out: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers.

Expand Down
2 changes: 1 addition & 1 deletion flask_talisman/talisman.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def init_app(
session_cookie_http_only=True,
session_cookie_samesite=DEFAULT_SESSION_COOKIE_SAMESITE,
x_content_type_options=True,
x_xss_protection=True):
x_xss_protection=False):
"""
Initialization.

Expand Down
9 changes: 8 additions & 1 deletion flask_talisman/talisman_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def testDefaults(self):
'X-Frame-Options': 'SAMEORIGIN',
'Strict-Transport-Security':
'max-age=31556926; includeSubDomains',
'X-XSS-Protection': '1; mode=block',
'X-Content-Type-Options': 'nosniff',
'Referrer-Policy': 'strict-origin-when-cross-origin'
}
Expand Down Expand Up @@ -85,6 +84,14 @@ def testForceSslOptionOptions(self):
response = self.client.get('/')
self.assertEqual(response.status_code, 200)

def testForceXSSProtectionOptions(self):
self.talisman.x_xss_protection = True

# HTTP request from Proxy
response = self.client.get('/')
self.assertIn('X-XSS-Protection', response.headers)
self.assertEqual(response.headers['X-XSS-Protection'], '1; mode=block')

def testHstsOptions(self):
self.talisman.force_ssl = False

Expand Down
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import nox


@nox.session(python='3.9')
@nox.session(python='3.11')
def lint(session):
session.install('docutils', 'pygments', 'flake8', 'flake8-import-order')
session.install('-e', '.')
Expand All @@ -12,7 +12,7 @@ def lint(session):
session.run('flake8', '--import-order-style=google', 'flask_talisman')


@nox.session(python=['3.4', '3.5', '3.6', '3.7', '3.8', '3.9'])
@nox.session(python=['3.7', '3.8', '3.9', '3.10', '3.11'])
def tests(session):
"""Run the test suite"""
session.install('flask', 'mock', 'pytest', 'pytest-cov')
Expand Down