Add more types to settings page (#11918)

* Add a executable type to settings page

This allow us to validate the value is a valid executable

* Add a directory type to settings page

This allow us to validate the value is a valid directory

* fixes
This commit is contained in:
Jellyfrog 2020-07-22 03:51:23 +02:00 committed by GitHub
parent 3c78e0ccc7
commit 86220eed9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 142 additions and 40 deletions

View File

@ -86,6 +86,10 @@ class DynamicConfigItem implements \ArrayAccess
return (bool)preg_match('/^#?[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/', $value);
} elseif (in_array($this->type, ['text', 'password'])) {
return !is_array($value);
} elseif ($this->type === 'executable') {
return is_file($value) && is_executable($value);
} elseif ($this->type === 'directory') {
return is_dir($value);
}
return false;

File diff suppressed because one or more lines are too long

View File

@ -1,14 +1,14 @@
{
"/js/app.js": "/js/app.js?id=4d14830ae8a6dfe54711",
"/js/app.js": "/js/app.js?id=eafcc78bac952df12bbc",
"/css/app.css": "/css/app.css?id=ffec4165a9c98d892a32",
"/js/manifest.js": "/js/manifest.js?id=3c768977c2574a34506e",
"/js/vendor.js": "/js/vendor.js?id=c0e0ebbfd027a8baefb4",
"/js/lang/de.js": "/js/lang/de.js?id=73ed23dde31af205f171",
"/js/lang/en.js": "/js/lang/en.js?id=e2297f39a1eabc180200",
"/js/lang/fr.js": "/js/lang/fr.js?id=91daac2f7383c820457b",
"/js/lang/it.js": "/js/lang/it.js?id=c202a58a7f5bca08801b",
"/js/lang/ru.js": "/js/lang/ru.js?id=aaab82593592e9368a08",
"/js/lang/uk.js": "/js/lang/uk.js?id=9b0b074259847e7aaff3",
"/js/lang/zh-CN.js": "/js/lang/zh-CN.js?id=f6d951b7d6b1f25810fc",
"/js/lang/zh-TW.js": "/js/lang/zh-TW.js?id=21cdd68dc06a428e7260"
"/js/lang/de.js": "/js/lang/de.js?id=b1a653a8eba34fe0c83d",
"/js/lang/en.js": "/js/lang/en.js?id=6a05a6687ebc32c73b5b",
"/js/lang/fr.js": "/js/lang/fr.js?id=f9aba2c115d3716739b5",
"/js/lang/it.js": "/js/lang/it.js?id=514765c5399ffaa111b9",
"/js/lang/ru.js": "/js/lang/ru.js?id=f376f9bbe31e66bae4fc",
"/js/lang/uk.js": "/js/lang/uk.js?id=483225c7042242ce65a7",
"/js/lang/zh-CN.js": "/js/lang/zh-CN.js?id=68da151165752f2e7983",
"/js/lang/zh-TW.js": "/js/lang/zh-TW.js?id=cd54708a7b044555884f"
}

View File

@ -1272,7 +1272,7 @@
},
"dot": {
"default": "/usr/bin/dot",
"type": "text"
"type": "executable"
},
"email_auto_tls": {
"default": true,
@ -1317,7 +1317,7 @@
"group": "alerting",
"section": "email",
"order": 5,
"type": "text",
"type": "executable",
"when": {
"setting": "email_backend",
"operator": "equals",
@ -1542,12 +1542,12 @@
"group": "external",
"section": "binaries",
"order": 0,
"type": "text"
"type": "executable"
},
"fping6": {
"default": "fping6",
"group": "external",
"section": "binaries",
"section": "executable",
"order": 1,
"type": "text"
},
@ -3326,7 +3326,7 @@
}
},
"html_dir": {
"type": "text"
"type": "directory"
},
"http_proxy": {
"group": "system",
@ -3484,7 +3484,7 @@
"order": 8
},
"install_dir": {
"type": "text"
"type": "directory"
},
"int_core": {
"default": true,
@ -3532,7 +3532,7 @@
"group": "external",
"section": "binaries",
"order": 3,
"type": "text"
"type": "executable"
},
"irc_alert": {
"default": false,
@ -3644,7 +3644,7 @@
"type": "color"
},
"log_dir": {
"type": "text"
"type": "directory"
},
"log_file": {
"type": "text"
@ -3669,7 +3669,7 @@
"type": "text"
},
"mib_dir": {
"type": "text"
"type": "directory"
},
"mono_font": {
"default": "DejaVuSansMono",
@ -3680,7 +3680,7 @@
"group": "external",
"section": "binaries",
"order": 4,
"type": "text"
"type": "executable"
},
"mydomain": {
"type": "text",
@ -3695,7 +3695,7 @@
},
"nagios_plugins": {
"default": "/usr/lib/nagios/plugins",
"type": "text"
"type": "directory"
},
"network_map_items": {
"default": [
@ -3760,7 +3760,7 @@
"group": "external",
"section": "binaries",
"order": 8,
"type": "text"
"type": "executable"
},
"nfsen_enable": {
"default": false,
@ -3886,7 +3886,7 @@
"group": "external",
"section": "binaries",
"order": 5,
"type": "text"
"type": "executable"
},
"notifications.LibreNMS": {
"default": "http://www.librenms.org/notifications.rss",
@ -4079,10 +4079,10 @@
"group": "external",
"section": "binaries",
"order": 6,
"type": "text"
"type": "executable"
},
"plugin_dir": {
"type": "text"
"type": "directory"
},
"poller_modules.unix-agent": {
"order": 420,
@ -4540,7 +4540,7 @@
"group": "poller",
"section": "rrdtool",
"order": 6,
"type": "text"
"type": "directory"
},
"rrd_purge": {
"group": "system",
@ -4587,7 +4587,7 @@
"group": "external",
"section": "binaries",
"order": -1,
"type": "text"
"type": "executable"
},
"rrdtool_tune": {
"default": false,
@ -4771,7 +4771,7 @@
"group": "external",
"section": "binaries",
"order": 7,
"type": "text"
"type": "executable"
},
"shorthost_target_length": {
"group": "webui",
@ -4970,28 +4970,28 @@
"group": "external",
"section": "binaries",
"order": 8,
"type": "text"
"type": "executable"
},
"snmpget": {
"default": "/usr/bin/snmpget",
"group": "external",
"section": "binaries",
"order": 9,
"type": "text"
"type": "executable"
},
"snmpgetnext": {
"default": "snmpgetnext",
"group": "external",
"section": "binaries",
"order": 10,
"type": "text"
"type": "executable"
},
"snmptranslate": {
"default": "/usr/bin/snmptranslate",
"group": "external",
"section": "binaries",
"order": 11,
"type": "text"
"type": "executable"
},
"snmptraps.eventlog": {
"default": "unhandled",
@ -5006,7 +5006,7 @@
"group": "external",
"section": "binaries",
"order": 12,
"type": "text"
"type": "executable"
},
"sso.create_users": {
"default": true,
@ -5052,7 +5052,7 @@
"type": "integer"
},
"temp_dir": {
"type": "text"
"type": "directory"
},
"title_image": {
"group": "webui",
@ -5073,14 +5073,14 @@
"group": "external",
"section": "binaries",
"order": 13,
"type": "text"
"type": "executable"
},
"traceroute6": {
"default": "traceroute6",
"group": "external",
"section": "binaries",
"order": 14,
"type": "text"
"type": "executable"
},
"transit_descr": {
"default": ["transit"],
@ -5158,7 +5158,7 @@
"group": "external",
"section": "binaries",
"order": 15,
"type": "text"
"type": "executable"
},
"warn.ifdown": {
"default": true,
@ -5258,7 +5258,7 @@
"group": "external",
"section": "binaries",
"order": 16,
"type": "text"
"type": "executable"
},
"xirrus_disable_stations": {
"default": false,
@ -5276,7 +5276,7 @@
"group": "external",
"section": "smokeping",
"order": 1,
"type": "text"
"type": "directory"
},
"smokeping.url": {
"group": "external",

View File

@ -87,7 +87,9 @@
"dashboard-select",
"snmp3auth",
"ldap-groups",
"ad-groups"
"ad-groups",
"executable",
"directory"
]
}
},

View File

@ -0,0 +1,47 @@
<!--
- SettingDirectory.vue
-
- Description-
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- @package LibreNMS
- @link http://librenms.org
- @copyright 2019 Tony Murray
- @author Tony Murray <murraytony@gmail.com>
-->
<template>
<input type="text" class="form-control"
:name="name"
:value="value"
@input="$emit('input', $event.target.value)"
:pattern="pattern"
:required="required"
:disabled="disabled"
>
</template>
<script>
import BaseSetting from "./BaseSetting";
export default {
name: "SettingDirectory",
mixins: [BaseSetting]
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,47 @@
<!--
- SettingExecutable.vue
-
- Description-
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- @package LibreNMS
- @link http://librenms.org
- @copyright 2019 Tony Murray
- @author Tony Murray <murraytony@gmail.com>
-->
<template>
<input type="text" class="form-control"
:name="name"
:value="value"
@input="$emit('input', $event.target.value)"
:pattern="pattern"
:required="required"
:disabled="disabled"
>
</template>
<script>
import BaseSetting from "./BaseSetting";
export default {
name: "SettingExecutable",
mixins: [BaseSetting]
}
</script>
<style scoped>
</style>

View File

@ -1366,5 +1366,7 @@ return [
'select' => ':value is not an allowed value',
'text' => ':value is not allowed',
'array' => 'Invalid format',
'executable' => ':value is not a valid executable',
'directory' => ':value is not a valid directory',
]
];