From f359509ba0c6bca7cb1e3623d7995d4e8829cb77 Mon Sep 17 00:00:00 2001 From: baldo Date: Thu, 1 Sep 2022 14:03:41 +0200 Subject: [PATCH 1/2] Fix: Avoid coordinates picked from map not validating. --- server/shared/validation/constraints.ts | 2 +- shared/validation/constraints.js | 124 ++++++++++++------------ 2 files changed, 62 insertions(+), 64 deletions(-) diff --git a/server/shared/validation/constraints.ts b/server/shared/validation/constraints.ts index 9f24588..c35d7a3 100644 --- a/server/shared/validation/constraints.ts +++ b/server/shared/validation/constraints.ts @@ -41,7 +41,7 @@ const CONSTRAINTS = { }, coords: { type: "string", - regex: /^(-?[0-9]{1,3}(\.[0-9]{1,15})? -?[0-9]{1,3}(\.[0-9]{1,15})?)$/, + regex: /^(-?[0-9]{1,3}(\.[0-9]{1,20})? -?[0-9]{1,3}(\.[0-9]{1,20})?)$/, optional: true, }, monitoring: { diff --git a/shared/validation/constraints.js b/shared/validation/constraints.js index dc6fbd7..b078bb7 100644 --- a/shared/validation/constraints.js +++ b/shared/validation/constraints.js @@ -1,142 +1,140 @@ -'use strict'; +"use strict"; // ATTENTION: Those constraints are no longer the same file as for the server. // Make sure changes are also reflected in /server/validation/constraints.ts. (function () { - var constraints = { - id:{ - type: 'string', + const constraints = { + id: { + type: "string", regex: /^[1-9][0-9]*$/, - optional: false + optional: false, }, - token:{ - type: 'string', + token: { + type: "string", regex: /^[0-9a-f]{16}$/i, - optional: false + optional: false, }, node: { hostname: { - type: 'string', + type: "string", regex: /^[-a-z0-9_]{1,32}$/i, - optional: false + optional: false, }, key: { - type: 'string', + type: "string", regex: /^([a-f0-9]{64})$/i, - optional: true + optional: true, }, email: { - type: 'string', + type: "string", regex: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i, - optional: false + optional: false, }, nickname: { - type: 'string', + type: "string", regex: /^[-a-z0-9_ äöüß]{1,64}$/i, - optional: false + optional: false, }, mac: { - type: 'string', + type: "string", regex: /^([a-f0-9]{12}|([a-f0-9]{2}:){5}[a-f0-9]{2}|([a-f0-9]{2}-){5}[a-f0-9]{2})$/i, - optional: false + optional: false, }, coords: { - type: 'string', - regex: /^(-?[0-9]{1,3}(\.[0-9]{1,15})? -?[0-9]{1,3}(\.[0-9]{1,15})?)$/, - optional: true + type: "string", + regex: /^(-?[0-9]{1,3}(\.[0-9]{1,20})? -?[0-9]{1,3}(\.[0-9]{1,20})?)$/, + optional: true, }, monitoring: { - type: 'boolean', - optional: false - } + type: "boolean", + optional: false, + }, }, nodeFilters: { hasKey: { - type: 'boolean', - optional: true + type: "boolean", + optional: true, }, hasCoords: { - type: 'boolean', - optional: true + type: "boolean", + optional: true, }, onlineState: { - type: 'string', + type: "string", regex: /^(ONLINE|OFFLINE)$/, - optional: true + optional: true, }, monitoringState: { - type: 'string', + type: "string", regex: /^(disabled|active|pending)$/, - optional: true + optional: true, }, site: { - type: 'string', + type: "string", regex: /^[a-z0-9_-]{1,32}$/, - optional: true + optional: true, }, domain: { - type: 'string', + type: "string", regex: /^[a-z0-9_-]{1,32}$/, - optional: true - } + optional: true, + }, }, rest: { list: { _page: { - type: 'number', + type: "number", min: 1, optional: true, - default: 1 + default: 1, }, _perPage: { - type: 'number', + type: "number", min: 1, max: 50, optional: true, - default: 20 + default: 20, }, _sortDir: { - type: 'enum', - allowed: ['ASC', 'DESC'], + type: "enum", + allowed: ["ASC", "DESC"], optional: true, - default: 'ASC' + default: "ASC", }, _sortField: { - type: 'string', + type: "string", regex: /^[a-zA-Z0-9_]{1,32}$/, - optional: true + optional: true, }, q: { - type: 'string', + type: "string", regex: /^[äöüß a-z0-9!#$%&@:.'*+/=?^_`{|}~-]{1,64}$/i, - optional: true - } - } - } - } + optional: true, + }, + }, + }, + }; - var _angular = null + let _angular = null; try { - _angular = angular - } - catch (error) { + _angular = angular; + } catch (error) { // ReferenceError, as angular is not defined. } - var _module = null + let _module = null; try { - _module = module - } - catch (error) { + _module = module; + } catch (error) { // ReferenceError, as module is not defined. } if (_angular) { - angular.module('ffffng').constant('Constraints', constraints) + angular.module("ffffng").constant("Constraints", constraints); } if (_module) { - module.exports = constraints + module.exports = constraints; } -})() +})(); From 4836e256ddd7e1712b4d10a0efe5062c6703694a Mon Sep 17 00:00:00 2001 From: baldo Date: Thu, 1 Sep 2022 14:54:40 +0200 Subject: [PATCH 2/2] Update server dependencies. --- package.json | 4 ++-- yarn.lock | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 63cc815..2f60061 100644 --- a/package.json +++ b/package.json @@ -67,13 +67,13 @@ "@types/compression": "^1.7.2", "@types/deep-extend": "^0.4.32", "@types/express": "^4.17.13", - "@types/glob": "^7.2.0", + "@types/glob": "^8.0.0", "@types/graceful-fs": "^4.1.5", "@types/html-to-text": "^8.1.1", "@types/jest": "^29.0.0", "@types/lodash": "^4.14.184", "@types/node": "^18.7.14", - "@types/node-cron": "^3.0.2", + "@types/node-cron": "^3.0.3", "@types/nodemailer": "^6.4.5", "@types/request": "^2.48.8", "@vue/eslint-config-prettier": "^7.0.0", diff --git a/yarn.lock b/yarn.lock index e02664a..a7f61ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -915,10 +915,10 @@ dependencies: "@types/node" "*" -"@types/glob@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" - integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA== +"@types/glob@^8.0.0": + version "8.0.0" + resolved "https://registry.yarnpkg.com/@types/glob/-/glob-8.0.0.tgz#321607e9cbaec54f687a0792b2d1d370739455d2" + integrity sha512-l6NQsDDyQUVeoTynNpC9uRvCUint/gSUXQA2euwmTuWGvPY5LSDUu6tkCtJB2SvGQlJQzLaKqcGZP4//7EDveA== dependencies: "@types/minimatch" "*" "@types/node" "*" @@ -994,10 +994,10 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== -"@types/node-cron@^3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@types/node-cron/-/node-cron-3.0.2.tgz#1a95877680f828817e395789ac2bf8d72a5df6af" - integrity sha512-SK/4GYWiWvGLPl/yv+Tm5oLYbzMx1V3y7CsNTvOb3vF8O9oXH11U6/zckISHnBl4YH8MvXHFIUXbYoBONSdmzw== +"@types/node-cron@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@types/node-cron/-/node-cron-3.0.3.tgz#6d7a7bebecb20d83c850421d4d3178a7555be538" + integrity sha512-FPzux/llEiCe5mPn3TvLEORcF2pRXvH5cugtJCJf+UrkwQ7pYfb4wn9J/sxJ8QkT/sw9BjWSi9uur5Vh1OuAZQ== "@types/node@*": version "17.0.34"