From 26aac1701fecaf955c125f936f1dcbf91ff2a110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 19 May 2022 09:25:03 +0200 Subject: [PATCH 1/8] =?UTF-8?q?=F0=9F=94=96=20staging/bugfix=20is=201.8.1.?= =?UTF-8?q?dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .versioneer-lookup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.versioneer-lookup b/.versioneer-lookup index d1d2e65bc..88c994cb2 100644 --- a/.versioneer-lookup +++ b/.versioneer-lookup @@ -24,10 +24,10 @@ maintenance 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev fix/.* 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 -staging/bugfix 1.7.4 59cbfadf8922d85b9df40f8d0173e8c21724c3b8 pep440-dev -bug/.* 1.7.4 59cbfadf8922d85b9df40f8d0173e8c21724c3b8 pep440-dev +staging/bugfix 1.8.1 d2a9aacedacf2b582faca462d6e915f88676a3d5 pep440-dev +bug/.* 1.8.1 d2a9aacedacf2b582faca462d6e915f88676a3d5 pep440-dev # staging/maintenance is currently the branch for preparation of 1.8.0rc6 # so is regressionfix/... From 89fbcfd2143f3e98d79d71d4aab7eec164b2ac6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 19 May 2022 09:38:00 +0200 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=90=9B=20Gracefully=20handle=20errors?= =?UTF-8?q?=20scanning=20/dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Solves an issue with Octo4a on some Android devices. --- src/octoprint/util/comm.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index d06b9529b..8af766756 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -198,10 +198,15 @@ def serialList(): else: candidates = [] - with os.scandir("/dev") as it: - for entry in it: - if regex_serial_devices.match(entry.name): - candidates.append(entry.path) + try: + with os.scandir("/dev") as it: + for entry in it: + 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 additionalPorts = settings().get(["serial", "additionalPorts"]) From 77904a71b45e6d017cf4c7e5eb8b8d973693c146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 19 May 2022 13:08:16 +0200 Subject: [PATCH 3/8] =?UTF-8?q?=F0=9F=94=92=EF=B8=8F=20Fix=20an=20XSS=20is?= =?UTF-8?q?sue=20in=20the=20user/group=20delete=20confirmation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/octoprint/static/js/app/viewmodels/access.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/access.js b/src/octoprint/static/js/app/viewmodels/access.js index 27c18d944..0c9c84209 100644 --- a/src/octoprint/static/js/app/viewmodels/access.js +++ b/src/octoprint/static/js/app/viewmodels/access.js @@ -324,7 +324,7 @@ $(function () { title: gettext("Are you sure?"), message: _.sprintf( gettext('You are about to delete the user "%(name)s".'), - {name: user.name} + {name: _.escape(user.name)} ), proceed: gettext("Delete"), onproceed: function () { @@ -656,7 +656,7 @@ $(function () { title: gettext("Are you sure?"), message: _.sprintf( gettext('You are about to delete the group "%(name)s".'), - {name: group.name} + {name: _.escape(group.name)} ), proceed: gettext("Delete"), onproceed: function () { From 866c9a20d73396bbac6f57186f3d8aacaad9386a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 24 May 2022 10:26:57 +0200 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=90=9B=20Fix=20a=20redirect=20loop=20?= =?UTF-8?q?on=20login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/octoprint/server/util/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/octoprint/server/util/__init__.py b/src/octoprint/server/util/__init__.py index e52036a49..3137115d5 100644 --- a/src/octoprint/server/util/__init__.py +++ b/src/octoprint/server/util/__init__.py @@ -378,9 +378,6 @@ def require_login_with(permissions=None, user_id=None): ): requires_login = False - if current_user.is_anonymous: - requires_login = True - if permissions is not None and not has_permissions(*permissions): requires_login = True login_kwargs["permissions"] = ",".join([x.key for x in permissions]) From d56e8302c7a4e783a7a2d25029af820c645e33a1 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 24 May 2022 10:27:54 +0200 Subject: [PATCH 5/8] Update black to 22.3.0 (#4510) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f2172728..086a9c616 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.1.0 + rev: 22.3.0 hooks: - id: black args: ["--config", "black.toml"] From 6709f9ca3c0fef9aaaca9d767ed5748633ceb4d0 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 24 May 2022 10:28:42 +0200 Subject: [PATCH 6/8] Migrate black configuration to pyproject.toml (#4511) --- .pre-commit-config.yaml | 1 - docs/development/environment.rst | 4 ---- black.toml => pyproject.toml | 0 3 files changed, 5 deletions(-) rename black.toml => pyproject.toml (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 086a9c616..53a20b5a6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,7 +46,6 @@ repos: rev: 22.3.0 hooks: - id: black - args: ["--config", "black.toml"] additional_dependencies: - click==8.0.4 - repo: https://gitlab.com/pycqa/flake8 diff --git a/docs/development/environment.rst b/docs/development/environment.rst index 1176f4df3..f8c27daef 100644 --- a/docs/development/environment.rst +++ b/docs/development/environment.rst @@ -329,10 +329,6 @@ Visual Studio Code (vscode) { "python.defaultInterpreterPath": "venv/bin/python", "python.formatting.provider": "black", - "python.formatting.blackArgs": [ - "--config", - "black.toml" - ], "editor.formatOnSave": true, "python.sortImports.args": [ "--profile=black", diff --git a/black.toml b/pyproject.toml similarity index 100% rename from black.toml rename to pyproject.toml From 9a8dde165004ae38f032a4d35397cf8b2b916b71 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 24 May 2022 10:32:53 +0200 Subject: [PATCH 7/8] Use lazy logging in octoprint. (#4512) --- src/octoprint/__init__.py | 56 +++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/octoprint/__init__.py b/src/octoprint/__init__.py index 83aab34ab..290ff257a 100644 --- a/src/octoprint/__init__.py +++ b/src/octoprint/__init__.py @@ -497,8 +497,8 @@ def init_settings_plugin_config_migration_and_cleanup(plugin_manager): ) except Exception: logging.getLogger(__name__).exception( - "Error while trying to migrate settings for " - "plugin {}, ignoring it".format(implementation._identifier), + "Error while trying to migrate settings for " "plugin %s, ignoring it", + implementation._identifier, extra={"plugin": implementation._identifier}, ) @@ -526,13 +526,16 @@ def init_custom_events(plugin_manager): event, prefix=f"plugin_{name}_" ) logger.debug( - 'Registered event {} of plugin {} as Events.{} = "{}"'.format( - event, name, constant, value - ) + 'Registered event %s of plugin %s as Events. %s = "%s"', + event, + name, + constant, + value, ) except Exception: logger.exception( - f"Error while retrieving custom event list from plugin {name}", + "Error while retrieving custom event list from plugin %s", + name, extra={"plugin": name}, ) @@ -661,7 +664,7 @@ def init_pluginsystem( disabled_from_overlays[name] = (disabled_plugins, order) settings_overlays[name] = overlay - logger.debug(f"Found settings overlay on plugin {name}") + logger.debug("Found settings overlay on plugin %s", name) def handle_plugins_loaded( startup=False, initialize_implementations=True, force_reload=None @@ -686,24 +689,22 @@ def init_pluginsystem( if addon in already_processed: logger.info( - "Plugin {} wants to disable plugin {}, but that was already processed".format( - name, addon - ) + "Plugin %s wants to disable plugin %s, but that was already processed", + name, + addon, ) if addon not in already_processed and addon not in disabled_list: disabled_list.append(addon) logger.info( - "Disabling plugin {} as defined by plugin {}".format( - addon, name - ) + "Disabling plugin %s as defined by plugin %s", addon, name ) already_processed.append(name) def handle_plugin_enabled(name, plugin): if name in settings_overlays: settings.add_overlay(settings_overlays[name]) - logger.info(f"Added settings overlay from plugin {name}") + logger.info("Added settings overlay from plugin %s", name) pm.on_plugin_loaded = handle_plugin_loaded pm.on_plugins_loaded = handle_plugins_loaded @@ -756,22 +757,22 @@ def get_plugin_blacklist(settings, connectivity_checker=None): if "pluginversions" in entry: logger.debug( - "Blacklisted plugin: {}, versions: {}".format( - entry["plugin"], ", ".join(entry["pluginversions"]) - ) + "Blacklisted plugin: %s, versions: %s", + entry["plugin"], + ", ".join(entry["pluginversions"]), ) for version in entry["pluginversions"]: result.append((entry["plugin"], version)) elif "versions" in entry: logger.debug( - "Blacklisted plugin: {}, versions: {}".format( - entry["plugin"], ", ".join(entry["versions"]) - ) + "Blacklisted plugin: %s, versions: %s", + entry["plugin"], + ", ".join(entry["versions"]), ) for version in entry["versions"]: result.append((entry["plugin"], f"=={version}")) else: - logger.debug("Blacklisted plugin: {}".format(entry["plugin"])) + logger.debug("Blacklisted plugin: %s", entry["plugin"]) result.append(entry["plugin"]) return result @@ -808,9 +809,9 @@ def get_plugin_blacklist(settings, connectivity_checker=None): ) except Exception as e: logger.info( - "Unable to fetch plugin blacklist from {}, proceeding without it: {}".format( - url, e - ) + "Unable to fetch plugin blacklist from %s, proceeding without it: %s", + url, + e, ) return result @@ -832,10 +833,9 @@ def get_plugin_blacklist(settings, connectivity_checker=None): if blacklist: logger.info( - "Blacklist processing done, " - "adding {} blacklisted plugin versions: {}".format( - len(blacklist), format_blacklist(blacklist) - ) + "Blacklist processing done, adding %s blacklisted plugin versions: %s", + len(blacklist), + format_blacklist(blacklist), ) else: logger.info("Blacklist processing done") From 260a1aef11432c421246019e25b6b744abbaed60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 24 May 2022 10:55:31 +0200 Subject: [PATCH 8/8] =?UTF-8?q?=F0=9F=94=96=20Preparing=20release=20of=201?= =?UTF-8?q?.8.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/plugins/errortracking/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/octoprint/plugins/errortracking/__init__.py b/src/octoprint/plugins/errortracking/__init__.py index 65b1a597d..67ffa2a23 100644 --- a/src/octoprint/plugins/errortracking/__init__.py +++ b/src/octoprint/plugins/errortracking/__init__.py @@ -18,10 +18,10 @@ from octoprint.util.version import ( ) SENTRY_URL_SERVER = ( - "https://0d173c8b74b945e1bdc73443e543ddee@o118517.ingest.sentry.io/1373987" + "https://f4265899b96044f3a31e6414c315a0d1@o118517.ingest.sentry.io/1373987" ) SENTRY_URL_COREUI = ( - "https://f38a3d0ad2694f7f8672b1a2485c3820@o118517.ingest.sentry.io/1374096" + "https://2f33808cb0cb4027afd005c35eebfeb4@o118517.ingest.sentry.io/1374096" ) SETTINGS_DEFAULTS = {