aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workflowengine/src/components/Values/file.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/workflowengine/src/components/Values/file.js')
-rw-r--r--apps/workflowengine/src/components/Values/file.js56
1 files changed, 46 insertions, 10 deletions
diff --git a/apps/workflowengine/src/components/Values/file.js b/apps/workflowengine/src/components/Values/file.js
index fa6851cc5c2..2d8ca936391 100644
--- a/apps/workflowengine/src/components/Values/file.js
+++ b/apps/workflowengine/src/components/Values/file.js
@@ -20,16 +20,13 @@
*
*/
-import './../../legacy/filenameplugin'
import './../../legacy/filesystemtagsplugin'
-import './../../legacy/requestremoteaddressplugin'
import './../../legacy/requesttimeplugin'
import './../../legacy/requesturlplugin'
import './../../legacy/requestuseragentplugin'
import './../../legacy/usergroupmembershipplugin'
import FileMimeType from './FileMimeType';
-import SizeValue from './SizeValue';
const FileChecks = Object.values(OCA.WorkflowEngine.Plugins).map((plugin) => {
if (plugin.component) {
@@ -47,6 +44,26 @@ const validateRegex = function(string) {
return result !== null
}
+const validateIPv4 = function(string) {
+ var regexRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(3[0-2]|[1-2][0-9]|[1-9])$/
+ var result = regexRegex.exec(string)
+ return result !== null
+}
+
+const validateIPv6 = function(string) {
+ var regexRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9])$/
+ var result = regexRegex.exec(string)
+ return result !== null
+}
+
+const stringValidator = (check) => {
+ if (check.operator === 'matches' || check.operator === '!matches') {
+ return validateRegex(check.value)
+ }
+ return true
+}
+
+
FileChecks.push({
class: 'OCA\\WorkflowEngine\\Check\\FileName',
name: t('workflowengine', 'File name'),
@@ -62,12 +79,7 @@ FileChecks.push({
}
return 'filename.txt'
},
- validate: (check) => {
- if (check.operator === 'matches' || check.operator === '!matches') {
- return validateRegex(check.value)
- }
- return true
- }
+ validate: stringValidator
})
FileChecks.push({
@@ -91,7 +103,31 @@ FileChecks.push({
{ operator: '!less', name: t('workflowengine', 'greater or equals') },
{ operator: 'greater', name: t('workflowengine', 'greater') }
],
- component: SizeValue
+ placeholder: (check) => '5 MB',
+ validate: (check) => check.value.match(/^[0-9]+[ ]?[kmgt]?b$/i) !== null
+})
+
+FileChecks.push({
+ class: 'OCA\\WorkflowEngine\\Check\\RequestRemoteAddress',
+ name: t('workflowengine', 'Request remote address'),
+ operators: [
+ { operator: 'matchesIPv4', name: t('workflowengine', 'matches IPv4') },
+ { operator: '!matchesIPv4', name: t('workflowengine', 'does not match IPv4') },
+ { operator: 'matchesIPv6', name: t('workflowengine', 'matches IPv6') },
+ { operator: '!matchesIPv6', name: t('workflowengine', 'does not match IPv6') }
+ ],
+ placeholder: (check) => {
+ if (check.operator === 'matchesIPv6' || check.operator === '!matchesIPv6') {
+ return '::1/128';
+ }
+ return '127.0.0.1/32'
+ },
+ validate: (check) => {
+ if (check.operator === 'matchesIPv6' || check.operator === '!matchesIPv6') {
+ return validateIPv6(check.value)
+ }
+ return validateIPv4(check.value)
+ }
})
export default FileChecks