Compare commits

..
14 Commits
Author SHA1 Message Date
Gina Häußge ab3ebf101f Merge branch 'staging/bugfix' 2022-10-18 10:42:21 +02:00
Gina Häußge 1875623f05 🔖 Prepare release of 1.8.6 2022-10-18 10:38:08 +02:00
Gina Häußge ac6240a3a3 🐛 Fix tornado download endpoint
Something broke during the initial fix for #4659.

Fixes #4659
2022-10-17 21:14:29 +02:00
Gina Häußge ae407492bc 🔖 staging/bugfix is now 1.8.6.dev 2022-10-17 17:16:48 +02:00
Gina Häußge de3a12999e Merge branch 'staging/bugfix' 2022-10-17 15:50:48 +02:00
Gina Häußge 395354212c 🔖 Preparing release of 1.8.5 2022-10-17 15:49:29 +02:00
Gina Häußge b38785a25a 🔒️ Make dependabot happy on e2e test dep 2022-10-12 15:12:56 +02:00
Gina Häußge f28a53f3e6 💚 Downgrade importlib-metadata in pre-commit
See https://stackoverflow.com/a/73932581
2022-10-12 13:45:36 +02:00
Gina Häußge d94e13e9dc 👷 Auto merge staging/bugfix & .../maintenance if possible 2022-10-12 13:02:10 +02:00
Gina Häußge eb9e144746 🐛 Explicitly declare storage for flask-limiter
Prevents warnings in latest versions.
2022-10-05 17:37:54 +02:00
Gina Häußge b4d0ed30ab 🐛 backup: fix file validation
Just going by name breaks backups
with arbitrary file names created
from CLI or the helper.

Instead of matching on the name, we
now check whether it's a zip and
contains a metadata.json.

Closes #4659
2022-10-05 17:03:14 +02:00
Gina Häußge 8e9c09a818 💚 Downgrade importlib-metadata in pre-commit
See https://stackoverflow.com/a/73932581
2022-10-05 15:10:59 +02:00
Gina Häußge 5091487719 🐛 Fix js getCookieSuffix for multi level paths
Also add Unit test coverage for getCookieSuffix and
getParsedBaseUrl.

Closes #4656
2022-10-05 13:21:07 +02:00
Gina Häußge 2f62feaaec 🔖 staging/bugfix is now 1.8.5.dev 2022-09-27 17:47:38 +02:00
12 changed files with 203 additions and 31 deletions

No files matched your search

+15
View File
@@ -65,6 +65,20 @@ jobs:
run: |
pytest
test-js-unit:
name: 🧪 JavaScript unit tests
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: 🏗 Set up test dependencies
run: |
npm -g install node-qunit-puppeteer@2.1.0
- name: 🚀 Run helpers.js test suite
run: |
node-qunit-puppeteer tests/static/js/test-helpers.html
node-qunit-puppeteer tests/static/js/test-client-base.html
test-install:
name: 🧪 Installation tests
needs: build
@@ -146,6 +160,7 @@ jobs:
needs:
- pre-commit
- test-unit
- test-js-unit
- test-install
- test-e2e
runs-on: ubuntu-latest
+18
View File
@@ -23,6 +23,24 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🔀 Merge staging/bugfix into maintenance
uses: robotology/gh-action-nightly-merge@v1.3.3
with:
stable_branch: "staging/bugfix"
development_branch: "maintenance"
allow_ff: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🔀 Merge staging/maintenance into maintenance
uses: robotology/gh-action-nightly-merge@v1.3.3
with:
stable_branch: "staging/bugfix"
development_branch: "maintenance"
allow_ff: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🔀 Merge maintenance into devel
uses: robotology/gh-action-nightly-merge@v1.3.3
with:
+1
View File
@@ -55,6 +55,7 @@ repos:
- id: flake8
additional_dependencies:
- flake8-bugbear==22.1.11
- importlib-metadata<5.0
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
hooks:
+3 -3
View File
@@ -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.8.4 bugfix release
# staging/bugfix is the branch for preparation of the 1.8.6 bugfix release
# so are any bug/... branches
staging/bugfix 1.8.4 d0d226f3e0ad0a6436e4f32519bf38a82aa576ca pep440-dev
bug/.* 1.8.4 d0d226f3e0ad0a6436e4f32519bf38a82aa576ca pep440-dev
staging/bugfix 1.8.6 395354212c2bb65b37b303de171418f6475ca346 pep440-dev
bug/.* 1.8.6 395354212c2bb65b37b303de171418f6475ca346 pep440-dev
# staging/maintenance is currently the branch for preparation of 1.8.0rc6
# so is regressionfix/...
+2 -2
View File
@@ -19,6 +19,7 @@ thanks to everyone who contributed!
* Christian Wolf
* Christian Würthner
* Christoph Sigrist
* Codense Consulting Oy
* Creality3D
* DeltaMaker 3D Printers
* Dennis Breining
@@ -43,7 +44,6 @@ thanks to everyone who contributed!
* Makespace Madrid
* Mark Greenwald
* Mark Walker
* Matt Van Itallie
* Michael Aumock
* Mike Kershaw
* Mosaic Manufacturing
@@ -68,4 +68,4 @@ thanks to everyone who contributed!
* TJ Horner
* Ulrich Kempken
and 2188 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)!
and 2145 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)!
+20 -15
View File
@@ -381,18 +381,21 @@ class BackupPlugin(
)
from octoprint.util import is_hidden_path
plugin_folder = self.get_plugin_data_folder()
def path_check(path):
joined = os.path.join(plugin_folder, path)
return not is_hidden_path(joined) and self._valid_backup(joined)
return [
(
r"/download/(.*)",
LargeResponseHandler,
{
"path": self.get_plugin_data_folder(),
"path": plugin_folder,
"as_attachment": True,
"path_validation": path_validation_factory(
lambda path: not is_hidden_path(path)
and self._match_backup_filename(
os.path.basename(path), self._settings
),
path_check,
status_code=404,
),
"access_validation": access_validation_factory(
@@ -739,9 +742,7 @@ class BackupPlugin(
for entry in os.scandir(self.get_plugin_data_folder()):
if is_hidden_path(entry.path):
continue
if not entry.is_file():
continue
if not entry.name.endswith(".zip"):
if not self._valid_backup(entry.path):
continue
backups.append(
@@ -1373,13 +1374,6 @@ class BackupPlugin(
backup_prefix, time.strftime(BACKUP_DATE_TIME_FMT)
)
@classmethod
def _match_backup_filename(cls, path, settings):
import re
backup_prefix = cls._get_backup_prefix(settings)
return re.match(re.escape(backup_prefix) + r"-backup-\d{8}-\d{6}.zip", path)
@classmethod
def _get_backup_prefix(cls, settings):
if settings.global_get(["appearance", "name"]) == "":
@@ -1397,6 +1391,17 @@ class BackupPlugin(
not in valid_boolean_trues
)
@classmethod
def _valid_backup(cls, path):
if not path.endswith(".zip") or not zipfile.is_zipfile(path):
return False
try:
with zipfile.ZipFile(path) as z:
return "metadata.json" in z.namelist()
except Exception:
return False
def _send_client_message(self, message, payload=None):
if payload is None:
payload = {}
@@ -18,10 +18,10 @@ from octoprint.util.version import (
)
SENTRY_URL_SERVER = (
"https://289cde39ce7d410f82280cb5b0bb62e8@o118517.ingest.sentry.io/1373987"
"https://faa02914ec8f42139e12a36482cfdb60@o118517.ingest.sentry.io/1373987"
)
SENTRY_URL_COREUI = (
"https://af2c0c034c9044889b8cf06163ea00fc@o118517.ingest.sentry.io/1374096"
"https://be7a53389fb045b48d6c384bb8ee89eb@o118517.ingest.sentry.io/1374096"
)
SETTINGS_DEFAULTS = {
+1
View File
@@ -1472,6 +1472,7 @@ class Server:
app,
key_func=get_remote_address,
enabled=s.getBoolean(["devel", "enableRateLimiter"]),
storage_uri="memory://",
)
def _setup_i18n(self, app):
+4 -3
View File
@@ -107,13 +107,14 @@
return url;
};
OctoPrintClient.prototype.getParsedBaseUrl = function () {
OctoPrintClient.prototype.getParsedBaseUrl = function (location) {
if (!this.options.baseurl) return "";
try {
var url = new URL(this.options.baseurl);
} catch (e) {
var parsed = new URL(window.location);
location = location || window.location;
var parsed = new URL(location);
var path = this.options.baseurl;
if (!path || path[0] !== "/") {
path = "/" + (path ? path : "");
@@ -135,7 +136,7 @@
if (path.endsWith("/")) {
path = path.substring(0, path.length - 1);
}
return "_P" + port + "_R" + path.replace(/\//, "|");
return "_P" + port + "_R" + path.replace(/\//g, "|");
} else {
return "_P" + port;
}
+9 -6
View File
@@ -1237,9 +1237,12 @@
}
},
"node_modules/minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/ms": {
"version": "2.1.2",
@@ -2602,9 +2605,9 @@
}
},
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g=="
},
"ms": {
"version": "2.1.2",
+18
View File
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>src/octoprint/static/js/app/client/base.js Tests</title>
<link rel="stylesheet" href="lib/qunit-1.18.0.css" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="lib/qunit-1.18.0.js"></script>
<script src="lib/qunit-parameterize.js"></script>
<script src="../../../src/octoprint/static/js/lib/lodash.min.js"></script>
<script src="../../../src/octoprint/static/js/lib/sprintf.min.js"></script>
<script src="../../../src/octoprint/static/js/app/client/base.js"></script>
<script src="test-client-base.js"></script>
</body>
</html>
+110
View File
@@ -0,0 +1,110 @@
_.mixin({sprintf: sprintf, vsprintf: vsprintf});
QUnit.module("getParsedBaseUrl");
QUnit.cases(
(function () {
return [
{
title: "fully qualified baseurl",
baseurl: "https://example.com",
location: undefined,
expected: "https://example.com/"
},
{
title: "fully qualified baseurl with http",
baseurl: "http://example.com",
location: undefined,
expected: "http://example.com/"
},
{
title: "fully qualified baseurl with custom port",
baseurl: "https://example.com:5000",
location: undefined,
expected: "https://example.com:5000/"
},
{
title: "website root",
baseurl: "/",
location: "https://example.com",
expected: "https://example.com/"
},
{
title: "website root with custom port",
baseurl: "/",
location: "https://example.com:5000",
expected: "https://example.com:5000/"
},
{
title: "single level prefix",
baseurl: "/octoprint/",
location: "https://example.com",
expected: "https://example.com/octoprint/"
},
{
title: "multi level prefix",
baseurl: "/path/to/octoprint/",
location: "https://example.com",
expected: "https://example.com/path/to/octoprint/"
},
{
title: "multi level prefix with http and custom port",
baseurl: "/path/to/octoprint/",
location: "http://example.com:5000",
expected: "http://example.com:5000/path/to/octoprint/"
},
{
title: "multi level prefix with https, custom port, no trailing slash",
baseurl: "/path/to/octoprint",
location: "https://example.com:5001",
expected: "https://example.com:5001/path/to/octoprint"
}
];
})()
).test("getParsedBaseUrl", function (params, assert) {
OctoPrint.options.baseurl = params.baseurl;
assert.equal(
OctoPrint.getParsedBaseUrl(params.location).toString(),
params.expected,
"Expected: " + String(params.expected)
);
});
QUnit.module("getCookieSuffix");
QUnit.cases(
(function () {
return [
{
title: "http with default port",
baseurl: "http://example.com",
expected: "_P80"
},
{
title: "https with default port",
baseurl: "https://example.com",
expected: "_P443"
},
{
title: "custom port",
baseurl: "http://example.com:5000",
expected: "_P5000"
},
{
title: "single level prefix",
baseurl: "https://example.com/octoprint/",
expected: "_P443_R|octoprint"
},
{
title: "multi level prefix",
baseurl: "https://example.com/path/to/octoprint",
expected: "_P443_R|path|to|octoprint"
}
];
})()
).test("getCookieSuffix", function (params, assert) {
OctoPrint.options.baseurl = params.baseurl;
assert.equal(
OctoPrint.getCookieSuffix(),
params.expected,
"Expected: " + String(params.expected)
);
});