mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
parent
ad7fb51cfa
commit
2ee1166747
1557 changed files with 76832 additions and 47042 deletions
|
@ -1,4 +1,15 @@
|
|||
/* https://github.com/sindresorhus/filename-reserved-regex */
|
||||
/*
|
||||
* This file derives from https://github.com/sindresorhus/filename-reserved-regex
|
||||
* Licensed under the MIT License:
|
||||
*
|
||||
* Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
function filenameReservedRegex() {
|
||||
return /[<>:"/\\|?*\u0000-\u001F]/g; // eslint-disable-line no-control-regex
|
||||
|
@ -8,7 +19,18 @@ function windowsReservedNameRegex() {
|
|||
return /^(con|prn|aux|nul|com\d|lpt\d)$/i;
|
||||
}
|
||||
|
||||
/* https://github.com/sindresorhus/filenamify */
|
||||
/*
|
||||
* This file derives from https://github.com/sindresorhus/filenamify
|
||||
* Licensed under the MIT License:
|
||||
*
|
||||
* Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Doesn't make sense to have longer filenames
|
||||
const MAX_FILENAME_LENGTH = 100;
|
||||
|
|
31
server/utils/inputs.js
Normal file
31
server/utils/inputs.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
const {
|
||||
ID_REGEX,
|
||||
IDS_WITH_COMMA_REGEX,
|
||||
MAX_STRING_ID,
|
||||
isIdInRange,
|
||||
isIdsWithCommaInRange,
|
||||
} = require('./validators');
|
||||
|
||||
const idInput = {
|
||||
type: 'string',
|
||||
maxLength: MAX_STRING_ID.length,
|
||||
regex: ID_REGEX,
|
||||
custom: isIdInRange,
|
||||
};
|
||||
|
||||
const idsInput = {
|
||||
type: 'string',
|
||||
maxLength: MAX_STRING_ID.length * 100 + 99,
|
||||
regex: IDS_WITH_COMMA_REGEX,
|
||||
custom: isIdsWithCommaInRange,
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
idInput,
|
||||
idsInput,
|
||||
};
|
|
@ -1,3 +1,8 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
const winston = require('winston');
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
const POSITION_GAP = 65535;
|
||||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
const { POSITION_GAP } = require('../constants');
|
||||
|
||||
const addPosition = async (knex, tableName, parentFieldName) => {
|
||||
await knex.schema.table(tableName, (table) => {
|
||||
|
|
44
server/utils/normalize-values.js
Normal file
44
server/utils/normalize-values.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
const normalizeValues = (rules, values, record) => {
|
||||
if (record) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
values = {
|
||||
...record,
|
||||
...values,
|
||||
};
|
||||
}
|
||||
|
||||
return Object.entries(rules).reduce((result, [fieldName, { setTo, defaultTo }]) => {
|
||||
let value = values[fieldName];
|
||||
|
||||
if (!_.isUndefined(setTo)) {
|
||||
const setToValue = _.isFunction(setTo) ? setTo(values) : setTo;
|
||||
|
||||
if (!_.isUndefined(setToValue)) {
|
||||
value = setToValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_.isUndefined(defaultTo) && _.isNil(value)) {
|
||||
const defaultToValue = _.isFunction(defaultTo) ? defaultTo(values) : defaultTo;
|
||||
|
||||
if (!_.isUndefined(defaultToValue)) {
|
||||
value = defaultToValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_.isUndefined(value)) {
|
||||
if (!record || value !== record[fieldName]) {
|
||||
result[fieldName] = value; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}, {});
|
||||
};
|
||||
|
||||
module.exports = normalizeValues;
|
|
@ -1,3 +1,8 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/**
|
||||
* The IP address of the client that just made a request to this application, whether
|
||||
* or not the TRUST_PROXY env variable is true and if endpoint accessed through a proxy.
|
||||
|
@ -8,7 +13,7 @@ const getRemoteAddress = (request) => {
|
|||
let remoteAddress = request.ip;
|
||||
|
||||
// Assert if "X-Forwarded-For" header contains any addresses
|
||||
if (process.env.TRUST_PROXY && !_.isEmpty(request.ips)) {
|
||||
if (process.env.TRUST_PROXY === 'true' && !_.isEmpty(request.ips)) {
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
remoteAddress = request.ips[0];
|
||||
}
|
25
server/utils/send_notifications.py
Normal file
25
server/utils/send_notifications.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Copyright (c) 2024 PLANKA Software GmbH
|
||||
# Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
|
||||
import sys
|
||||
import json
|
||||
import apprise
|
||||
|
||||
|
||||
def send_notification(url, title, body, body_format):
|
||||
app = apprise.Apprise()
|
||||
app.add(url)
|
||||
app.notify(title=title, body=body, body_format=body_format)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
services = json.loads(sys.argv[1])
|
||||
title = sys.argv[2]
|
||||
body_by_format = json.loads(sys.argv[3])
|
||||
|
||||
for service in services:
|
||||
url = service['url']
|
||||
body_format = service['format']
|
||||
body = body_by_format[body_format]
|
||||
|
||||
send_notification(url, title, body, body_format)
|
72
server/utils/validators.js
Normal file
72
server/utils/validators.js
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
const validator = require('validator');
|
||||
const zxcvbn = require('zxcvbn');
|
||||
const moment = require('moment');
|
||||
|
||||
const MAX_STRING_ID = '9223372036854775807';
|
||||
|
||||
const ID_REGEX = /^[1-9][0-9]*$/;
|
||||
const IDS_WITH_COMMA_REGEX = /^[1-9][0-9]*(,[1-9][0-9]*)*$/;
|
||||
const USERNAME_REGEX = /^[a-zA-Z0-9]+((_|\.)?[a-zA-Z0-9])*$/;
|
||||
|
||||
const isUrl = (value) =>
|
||||
validator.isURL(value, {
|
||||
protocols: ['http', 'https'],
|
||||
require_protocol: true,
|
||||
});
|
||||
|
||||
const isIdInRange = (value) => value.length < MAX_STRING_ID.length || value <= MAX_STRING_ID;
|
||||
|
||||
const isIdsWithCommaInRange = (value) => _.every(value.split(','), isIdInRange);
|
||||
|
||||
const isId = (value) =>
|
||||
value.length <= MAX_STRING_ID.length && ID_REGEX.test(value) && isIdInRange(value);
|
||||
|
||||
const isIds = (values) => _.every(values, isId);
|
||||
|
||||
const isPassword = (value) => zxcvbn(value).score >= 2; // TODO: move to config
|
||||
|
||||
const isEmailOrUsername = (value) =>
|
||||
value.includes('@')
|
||||
? validator.isEmail(value)
|
||||
: value.length >= 3 && value.length <= 16 && USERNAME_REGEX.test(value);
|
||||
|
||||
const isDueDate = (value) => moment(value, moment.ISO_8601, true).isValid();
|
||||
|
||||
const isStopwatch = (value) => {
|
||||
if (!_.isPlainObject(value) || _.size(value) !== 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isNull(value.startedAt) && !moment(value.startedAt, moment.ISO_8601, true).isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isFinite(value.total) || value.total < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
MAX_STRING_ID,
|
||||
|
||||
ID_REGEX,
|
||||
IDS_WITH_COMMA_REGEX,
|
||||
USERNAME_REGEX,
|
||||
|
||||
isUrl,
|
||||
isIdInRange,
|
||||
isIdsWithCommaInRange,
|
||||
isId,
|
||||
isIds,
|
||||
isPassword,
|
||||
isEmailOrUsername,
|
||||
isDueDate,
|
||||
isStopwatch,
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue