Compare commits

...
18 Commits
Author SHA1 Message Date
Gina Häußge 87f4a4e8c9 🔖 Preparing release of 1.8.2 2022-08-09 13:54:24 +02:00
Gina Häußge 91ef0c0d99 📌 Pin Flask to 2.1
Flask 2.2 requires werkzeug 2.2 which we can't
upgrade to due to flask-login, and the current
version pins might be causing issues in the
field.

TODO for 1.9.0: upgrade werkzeug & flask if
possible with flask-login.
2022-08-09 13:03:42 +02:00
Gina Häußge dabdd40806 🔒️ Fix another open redirect issue
The redirect parameter to the login dialog now gets restricted to local URLs (as detected by unset scheme & netloc) that match a short list of allowed endpoints routes.
2022-08-04 10:33:31 +02:00
Gina Häußge 4a9b18582d Merge branch 'master' into staging/bugfix 2022-08-02 12:27:20 +02:00
Christian Clauss 5753ee3cfa ✏ Highlight branch names in PR template (#4573) 2022-08-01 11:41:55 +02:00
Christian Clauss c18a5046d5 ✏️ timelapse.rst: Fix typos (#4569) 2022-07-12 18:48:39 +01:00
Gina Häußge 2e1ec42c5b 👷‍♂️ Needs to run against pull_request_target 2022-06-23 10:50:06 +02:00
Gina Häußge 6bddada8c2 👷‍♂️ Add task labeling 2022-06-21 10:12:53 +02:00
Gina Häußge 008292ce60 Use org wide secret 2022-06-20 15:56:07 +02:00
Gina Häußge 01f24e6cea 👷‍♂️ Add issues/PRs to backlog automatically 2022-06-20 15:49:00 +02:00
Gina Häußge 53b9b61857 👷 Only trigger release jobs on main repo 2022-05-30 14:51:54 +02:00
Gina Häußge e2349b4565 👷 Ignore errors on Discord hook & e2e
e2e are too flaky, discord hook might be unconfigured in a fork.
2022-05-30 14:45:16 +02:00
Gina Häußge 422e3d2b66 🔖 staging/bugfix is now 1.8.2.dev 2022-05-24 12:25:17 +02:00
Gina Häußge 260a1aef11 🔖 Preparing release of 1.8.1 2022-05-24 10:55:31 +02:00
Gina Häußge 866c9a20d7 🐛 Fix a redirect loop on login
If guest/anonymous users where configured with read-only rights,
the login dialog would enter a redirect loop due to require_login_with
not recognizing anonymous use with permissions as valid.

Fixes #4516
2022-05-24 10:26:57 +02:00
Gina Häußge 77904a71b4 🔒️ Fix an XSS issue in the user/group delete confirmation
Requires admin rights to exploit in any way.
With OctoPrint 1.8.0 all cookies with credentials
are http-only and thus not targetable (to my
knowledge) by this.

CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N, Severity Low
2022-05-19 13:08:16 +02:00
Gina Häußge 89fbcfd214 🐛 Gracefully handle errors scanning /dev
Solves an issue with Octo4a on some Android devices.
2022-05-19 09:38:00 +02:00
Gina Häußge 26aac1701f 🔖 staging/bugfix is 1.8.1.dev 2022-05-19 09:25:03 +02:00
15 changed files with 131 additions and 48 deletions

No files matched your search

+10 -10
View File
@@ -1,10 +1,10 @@
<!-- <!--
Thank you for your interest into contributing to OctoPrint, it's Thank you for your interest in contributing to OctoPrint, it's
highly appreciated! highly appreciated!
Please make sure you have read the "guidelines for contributing" as Please make sure you have read the "guidelines for contributing" as
linked just above this form, there's a section on Pull Requests in there linked just above this form, there's a section on Pull Requests in there
as well that contains important information. as well which contains important information.
As a summary, please make sure you have ticked all points on this As a summary, please make sure you have ticked all points on this
checklist: checklist:
@@ -16,25 +16,25 @@ checklist:
made sure your changes don't interfere with current development by made sure your changes don't interfere with current development by
talking it through with the maintainers, e.g. through a talking it through with the maintainers, e.g. through a
Brainstorming ticket Brainstorming ticket
* [ ] Your PR targets OctoPrint's devel branch if it's a completely * [ ] Your PR targets OctoPrint's `devel` branch if it's a completely
new feature, or maintenance if it's a bug fix or improvement of new feature, or `maintenance` if it's a bug fix or improvement of
existing functionality for the current stable version (no PRs existing functionality for the current stable version (no PRs
against master or anything else please) against `master` or anything else please)
* [ ] Your PR was opened from a custom branch on your repository * [ ] Your PR was opened from a custom branch on your repository
(no PRs from your version of master, maintenance or devel please), (no PRs from your version of `master`, `maintenance`, or `devel`
e.g. dev/my_new_feature or fix/my_bugfix please), e.g. `dev/my_new_feature` or `fix/my_bugfix`
* [ ] Your PR only contains relevant changes: no unrelated files, * [ ] Your PR only contains relevant changes: no unrelated files,
no dead code, ideally only one commit - rebase and squash your PR no dead code, ideally only one commit - rebase and squash your PR
if necessary! if necessary!
* [ ] Your changes follow the existing coding style * [ ] Your changes follow the existing coding style
* [ ] If your changes include style sheets: You have modified the * [ ] If your changes include style sheets: You have modified the
.less source files, not the .css files (those are generated with `.less` source files, not the `.css` files (those are generated
lessc) with `lessc`)
* [ ] You have tested your changes (please state how!) - ideally you * [ ] You have tested your changes (please state how!) - ideally you
have added unit tests have added unit tests
* [ ] You have run the existing unit tests against your changes and * [ ] You have run the existing unit tests against your changes and
nothing broke nothing broke
* [ ] You have added yourself to the AUTHORS.md file :) * [ ] You have added yourself to the `AUTHORS.md` file :)
<!-- <!--
Describe your PR further using the template provided below. The more Describe your PR further using the template provided below. The more
+20
View File
@@ -0,0 +1,20 @@
name: Add issues/PRs to backlog automatically
on:
issues:
types:
- opened
- transferred
pull_request_target:
types:
- opened
jobs:
add-to-project:
name: Add issue or PR to OctoPrint Backlog project
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@main
with:
project-url: https://github.com/orgs/OctoPrint/projects/6
github-token: ${{ secrets.BACKLOG_PROJECT_ACCESS }}
+4 -3
View File
@@ -96,6 +96,7 @@ jobs:
name: 🧪 E2E tests name: 🧪 E2E tests
needs: build needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
continue-on-error: true
steps: steps:
- name: ⬇ Checkout code - name: ⬇ Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
@@ -141,7 +142,7 @@ jobs:
publish-on-testpypi: publish-on-testpypi:
name: 📦 Publish on TestPyPI name: 📦 Publish on TestPyPI
if: github.event_name == 'release' if: github.event_name == 'release' && github.repository == 'OctoPrint/OctoPrint'
needs: needs:
- pre-commit - pre-commit
- test-unit - test-unit
@@ -163,7 +164,7 @@ jobs:
publish-on-pypi: publish-on-pypi:
name: 📦 Publish tagged releases to PyPI name: 📦 Publish tagged releases to PyPI
if: github.event_name == 'release' if: github.event_name == 'release' && github.repository == 'OctoPrint/OctoPrint'
needs: publish-on-testpypi needs: publish-on-testpypi
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -179,7 +180,7 @@ jobs:
notify-custopizer-build: notify-custopizer-build:
name: 📧 Notify OctoPi-UpToDate name: 📧 Notify OctoPi-UpToDate
if: github.event_name == 'release' if: github.event_name == 'release' && github.repository == 'OctoPrint/OctoPrint'
needs: publish-on-pypi needs: publish-on-pypi
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
+6 -1
View File
@@ -28,6 +28,11 @@ jobs:
labels = labels.filter(label => label !== 'triage'); labels = labels.filter(label => label !== 'triage');
setLabels = true; setLabels = true;
} }
if (context.payload.issue.title.match(/\[task\]/i)) {
labels.push('task');
labels = labels.filter(label => label !== 'triage');
setLabels = true;
}
if (labels.length === 0) { if (labels.length === 0) {
labels.push('triage'); labels.push('triage');
@@ -37,7 +42,7 @@ jobs:
} }
case 'closed': { case 'closed': {
if (labels.includes('bug') || labels.includes('request') || labels.includes('improvement')) { if (labels.includes('bug') || labels.includes('request') || labels.includes('improvement') || labels.includes('task')) {
labels.push('done'); labels.push('done');
setLabels = true; setLabels = true;
} }
+4
View File
@@ -31,12 +31,14 @@ jobs:
run: | run: |
pip install . pip install .
- name: 📧 Discord success notification - name: 📧 Discord success notification
continue-on-error: true
env: env:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }} DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
uses: Ilshidur/action-discord@master uses: Ilshidur/action-discord@master
with: with:
args: "☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ matrix.branch }}` was successful" args: "☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ matrix.branch }}` was successful"
- name: 📧 Discord failure notification - name: 📧 Discord failure notification
continue-on-error: true
if: failure() if: failure()
env: env:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }} DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
@@ -65,12 +67,14 @@ jobs:
run: | run: |
pip install https://github.com/OctoPrint/OctoPrint/archive/${{ steps.latest.outputs.release }}.zip pip install https://github.com/OctoPrint/OctoPrint/archive/${{ steps.latest.outputs.release }}.zip
- name: 📧 Discord success notification - name: 📧 Discord success notification
continue-on-error: true
env: env:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }} DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
uses: Ilshidur/action-discord@master uses: Ilshidur/action-discord@master
with: with:
args: "☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ steps.latest.outputs.release }}` was successful" args: "☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ steps.latest.outputs.release }}` was successful"
- name: 📧 Discord failure notification - name: 📧 Discord failure notification
continue-on-error: true
if: failure() if: failure()
env: env:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }} DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
+3 -3
View File
@@ -24,10 +24,10 @@ maintenance 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev
fix/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev fix/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev
improve/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev improve/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev
# staging/bugfix is the branch for preparation of the 1.7.4 bugfix release # staging/bugfix is the branch for preparation of the 1.8.1 bugfix release
# so are any bug/... branches # so are any bug/... branches
staging/bugfix 1.7.4 59cbfadf8922d85b9df40f8d0173e8c21724c3b8 pep440-dev staging/bugfix 1.8.2 260a1aef11432c421246019e25b6b744abbaed60 pep440-dev
bug/.* 1.7.4 59cbfadf8922d85b9df40f8d0173e8c21724c3b8 pep440-dev bug/.* 1.8.2 260a1aef11432c421246019e25b6b744abbaed60 pep440-dev
# staging/maintenance is currently the branch for preparation of 1.8.0rc6 # staging/maintenance is currently the branch for preparation of 1.8.0rc6
# so is regressionfix/... # so is regressionfix/...
+5 -13
View File
@@ -10,37 +10,29 @@ thanks to everyone who contributed!
* 3DPrinterOS * 3DPrinterOS
* Al Mucci * Al Mucci
* Arnljot Arntsen * Arnljot Arntsen
* Artillery 3D
* Ash King * Ash King
* BigTreeTech * BigTreeTech
* Boris Hussein * Boris Hussein
* Brad Jackson * Brad Jackson
* BuildBee
* Calvin Vette * Calvin Vette
* Christian Petropolis * Christian Petropolis
* Christian Wolf * Christian Wolf
* Christian Würthner * Christian Würthner
* Christoph Sigrist * Christoph Sigrist
* Craig Parker
* Creality3D * Creality3D
* David Bounds
* DeltaMaker 3D Printers * DeltaMaker 3D Printers
* Dennis Breining * Dennis Breining
* Douglas Floyd * Douglas Floyd
* Dr. Frank Wester * Dr. Frank Wester
* Eric Betts
* Ernesto Martinez * Ernesto Martinez
* Franziska Kunsmann * Franziska Kunsmann
* George Robles
* Greg Holloway * Greg Holloway
* Hog Duske * Hog Duske
* Itay Shem-tov
* James Mackay * James Mackay
* Jeff Green * Jeff Green
* Jeff Moe * Jeff Moe
* jeffiel * jeffiel
* Jeremy Cole * Jeremy Cole
* Joshua Wills
* Julian Melo * Julian Melo
* Justin Kaufman * Justin Kaufman
* Kaile Riser * Kaile Riser
@@ -52,13 +44,15 @@ thanks to everyone who contributed!
* Lefteris Lertas * Lefteris Lertas
* LulzBot * LulzBot
* Makespace Madrid * Makespace Madrid
* Mark Greenwald
* Mark Walker * Mark Walker
* Matt Van Itallie * Matt Van Itallie
* Michael Aumock * Michael Aumock
* Mike Kershaw * Mike Kershaw
* Miles Flavel
* Mosaic Manufacturing * Mosaic Manufacturing
* Norman Jaffe * Norman Jaffe
* Obico
* Ory Weaver
* Peopoly * Peopoly
* Pete Barnwell * Pete Barnwell
* Raise3D * Raise3D
@@ -68,17 +62,15 @@ thanks to everyone who contributed!
* Richard Michaud * Richard Michaud
* Richard Stocks * Richard Stocks
* Robert Gusek * Robert Gusek
* Ronald Griehsler
* Sean Jensen-Grey * Sean Jensen-Grey
* Sebastien Andrivet * Sebastien Andrivet
* SimplyPrint
* Stefan Krister * Stefan Krister
* Steve Dougherty * Steve Dougherty
* Steve Thompson * Steve Thompson
* TH3D
* The Spaghetti Detective
* TJ Horner * TJ Horner
* Trent Shumay * Trent Shumay
* Ulrich Kempken * Ulrich Kempken
* Yehuda Katz * Yehuda Katz
and 2279 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)! and 2209 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)!
+2 -2
View File
@@ -76,7 +76,7 @@ Change current timelapse config
.. http:post:: /api/timelapse .. http:post:: /api/timelapse
Save a new :ref:`timelapse configuration <sec-api-timelapse-datamodel-config>` to use for the next print. Set the optional ``save`` flag in the Save a new :ref:`timelapse configuration <sec-api-timelapse-datamodel-config>` to use for the next print. Set the optional ``save`` flag in the
configuration to ``true`` in order to make the new configuration persist accross restarts. configuration to ``true`` in order to make the new configuration persist across restarts.
The configuration is expected as the request body. The configuration is expected as the request body.
@@ -220,7 +220,7 @@ Timelapse configuration
* - ``save`` * - ``save``
- 1 - 1
- bool - bool
- Optional flag to be included when when saving a configuration to make the configuration persist accross restarts - Optional flag to be included when when saving a configuration to make the configuration persist across restarts
Further fields are timelapse type specific, see below for details. Further fields are timelapse type specific, see below for details.
+1 -1
View File
@@ -43,7 +43,7 @@ core_deps = [
"Flask-Assets>=2.0,<3", "Flask-Assets>=2.0,<3",
"Flask-Babel>=2.0,<3", "Flask-Babel>=2.0,<3",
"Flask-Login>=0.5,<0.6", # flask-login doesn't use semver & breaks stuff on minor version increases "Flask-Login>=0.5,<0.6", # flask-login doesn't use semver & breaks stuff on minor version increases
"flask>=2,<3", "flask>=2.1,<2.2", # flask 2.2 requires werkzeug 2.2+
"frozendict>=2.0,<3", "frozendict>=2.0,<3",
"future>=0.18.2,<1", # not really needed anymore, but leaving in for py2/3 compat plugins "future>=0.18.2,<1", # not really needed anymore, but leaving in for py2/3 compat plugins
"markdown>=3.2.2,<4", "markdown>=3.2.2,<4",
@@ -18,10 +18,10 @@ from octoprint.util.version import (
) )
SENTRY_URL_SERVER = ( SENTRY_URL_SERVER = (
"https://0d173c8b74b945e1bdc73443e543ddee@o118517.ingest.sentry.io/1373987" "https://32fedab787cf4ef0abb9f4fb9060f7c5@o118517.ingest.sentry.io/1373987"
) )
SENTRY_URL_COREUI = ( SENTRY_URL_COREUI = (
"https://f38a3d0ad2694f7f8672b1a2485c3820@o118517.ingest.sentry.io/1374096" "https://09c57ca82d4047b5a37bb0655ce14187@o118517.ingest.sentry.io/1374096"
) )
SETTINGS_DEFAULTS = { SETTINGS_DEFAULTS = {
+20 -3
View File
@@ -378,9 +378,6 @@ def require_login_with(permissions=None, user_id=None):
): ):
requires_login = False requires_login = False
if current_user.is_anonymous:
requires_login = True
if permissions is not None and not has_permissions(*permissions): if permissions is not None and not has_permissions(*permissions):
requires_login = True requires_login = True
login_kwargs["permissions"] = ",".join([x.key for x in permissions]) login_kwargs["permissions"] = ",".join([x.key for x in permissions])
@@ -424,3 +421,23 @@ def require_login(*permissions):
) )
return None return None
def validate_local_redirect(url, allowed_paths):
"""Validates the given local redirect URL against the given allowed paths.
An `url` is valid for a local redirect if it has neither scheme nor netloc defined,
and its path is one of the given allowed paths.
Args:
url (str): URL to validate
allowed_paths (List[str]): List of allowed paths, only paths contained
will be considered valid.
Returns:
bool: Whether the `url` passed validation or not.
"""
from urllib.parse import urlparse
parsed = urlparse(url)
return parsed.scheme == "" and parsed.netloc == "" and parsed.path in allowed_paths
+7 -4
View File
@@ -8,7 +8,6 @@ import logging
import os import os
import re import re
from collections import defaultdict from collections import defaultdict
from urllib.parse import urlparse
from flask import ( from flask import (
Response, Response,
@@ -39,7 +38,11 @@ from octoprint.server import ( # noqa: F401
preemptiveCache, preemptiveCache,
userManager, userManager,
) )
from octoprint.server.util import has_permissions, require_login_with from octoprint.server.util import (
has_permissions,
require_login_with,
validate_local_redirect,
)
from octoprint.settings import settings from octoprint.settings import settings
from octoprint.util import sv, to_bytes, to_unicode from octoprint.util import sv, to_bytes, to_unicode
from octoprint.util.version import get_python_version_string from octoprint.util.version import get_python_version_string
@@ -173,9 +176,9 @@ def login():
default_redirect_url = request.script_root + url_for("index") default_redirect_url = request.script_root + url_for("index")
redirect_url = request.args.get("redirect", default_redirect_url) redirect_url = request.args.get("redirect", default_redirect_url)
allowed_paths = [url_for("index"), url_for("recovery")]
parsed = urlparse(redirect_url) # check if redirect url is valid if not validate_local_redirect(redirect_url, allowed_paths):
if parsed.scheme != "" or parsed.netloc != "":
_logger.warning( _logger.warning(
f"Got an invalid redirect URL with the login attempt, misconfiguration or attack attempt: {redirect_url}" f"Got an invalid redirect URL with the login attempt, misconfiguration or attack attempt: {redirect_url}"
) )
@@ -324,7 +324,7 @@ $(function () {
title: gettext("Are you sure?"), title: gettext("Are you sure?"),
message: _.sprintf( message: _.sprintf(
gettext('You are about to delete the user "%(name)s".'), gettext('You are about to delete the user "%(name)s".'),
{name: user.name} {name: _.escape(user.name)}
), ),
proceed: gettext("Delete"), proceed: gettext("Delete"),
onproceed: function () { onproceed: function () {
@@ -656,7 +656,7 @@ $(function () {
title: gettext("Are you sure?"), title: gettext("Are you sure?"),
message: _.sprintf( message: _.sprintf(
gettext('You are about to delete the group "%(name)s".'), gettext('You are about to delete the group "%(name)s".'),
{name: group.name} {name: _.escape(group.name)}
), ),
proceed: gettext("Delete"), proceed: gettext("Delete"),
onproceed: function () { onproceed: function () {
+9 -4
View File
@@ -198,10 +198,15 @@ def serialList():
else: else:
candidates = [] candidates = []
with os.scandir("/dev") as it: try:
for entry in it: with os.scandir("/dev") as it:
if regex_serial_devices.match(entry.name): for entry in it:
candidates.append(entry.path) if regex_serial_devices.match(entry.name):
candidates.append(entry.path)
except Exception:
logging.getLogger(__name__).exception(
"Could not scan /dev for serial ports on the system"
)
# additional ports # additional ports
additionalPorts = settings().get(["serial", "additionalPorts"]) additionalPorts = settings().get(["serial", "additionalPorts"])
+36
View File
@@ -0,0 +1,36 @@
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
import pytest
@pytest.mark.parametrize(
"url,paths,expected",
[
# various default UI URLs
("/", ["/", "/recovery/"], True),
("/?", ["/", "/recovery/"], True),
("/?l10n=de", ["/", "/recovery/"], True),
("/?l10n=de&", ["/", "/recovery/"], True),
("/octoprint/", ["/octoprint/", "/octoprint/recovery/"], True),
# various recovery URLs
("/recovery/", ["/", "/recovery/"], True),
("/recovery/?", ["/", "/recovery/"], True),
("/recovery/?l10n=de", ["/", "/recovery/"], True),
("/octoprint/recovery/?l10n=de", ["/octoprint/", "/octoprint/recovery/"], True),
# various external URLs
("http://example.com", ["/", "/recovery/"], False),
("https://example.com", ["/", "/recovery/"], False),
("//example.com", ["/", "/recovery/"], False),
("/\\/\\example.com", ["/", "/recovery/"], False),
(" /\\/\\example.com", ["/", "/recovery/"], False),
("\\/\\/example.com", ["/", "/recovery/"], False),
(" \\/\\/example.com", ["/", "/recovery/"], False),
# other stuff
("javascript:alert(document.cookie)", ["/", "/recovery/"], False),
],
)
def test_validate_local_redirect(url, paths, expected):
from octoprint.server.util import validate_local_redirect
assert validate_local_redirect(url, paths) == expected