summaryrefslogtreecommitdiff
path: root/src/validators
diff options
context:
space:
mode:
Diffstat (limited to 'src/validators')
-rwxr-xr-xsrc/validators/interface-name2
-rwxr-xr-xsrc/validators/ipv6-exclude7
-rwxr-xr-xsrc/validators/ipv6-range16
-rwxr-xr-xsrc/validators/ipv6-range-exclude7
-rwxr-xr-xsrc/validators/sysctl24
-rwxr-xr-xsrc/validators/vrf-name4
6 files changed, 57 insertions, 3 deletions
diff --git a/src/validators/interface-name b/src/validators/interface-name
index 5bac671b1..105815eee 100755
--- a/src/validators/interface-name
+++ b/src/validators/interface-name
@@ -20,7 +20,7 @@ import re
from sys import argv
from sys import exit
-pattern = '^(bond|br|dum|en|ersp|eth|gnv|lan|l2tp|l2tpeth|macsec|peth|ppp|pppoe|pptp|sstp|tun|vti|vtun|vxlan|wg|wlan|wlm)[0-9]+(.\d+)?|lo$'
+pattern = '^(bond|br|dum|en|ersp|eth|gnv|lan|l2tp|l2tpeth|macsec|peth|ppp|pppoe|pptp|sstp|tun|vti|vtun|vxlan|wg|wlan|wwan)[0-9]+(.\d+)?|lo$'
if __name__ == '__main__':
if len(argv) != 2:
diff --git a/src/validators/ipv6-exclude b/src/validators/ipv6-exclude
new file mode 100755
index 000000000..893eeab09
--- /dev/null
+++ b/src/validators/ipv6-exclude
@@ -0,0 +1,7 @@
+#!/bin/sh
+arg="$1"
+if [ "${arg:0:1}" != "!" ]; then
+ exit 1
+fi
+path=$(dirname "$0")
+${path}/ipv6 "${arg:1}"
diff --git a/src/validators/ipv6-range b/src/validators/ipv6-range
new file mode 100755
index 000000000..033b6461b
--- /dev/null
+++ b/src/validators/ipv6-range
@@ -0,0 +1,16 @@
+#!/usr/bin/python3
+
+import sys
+import re
+from vyos.template import is_ipv6
+
+if __name__ == '__main__':
+ if len(sys.argv)>1:
+ ipv6_range = sys.argv[1]
+ # Regex for ipv6-ipv6 https://regexr.com/
+ if re.search('([a-f0-9:]+:+)+[a-f0-9]+-([a-f0-9:]+:+)+[a-f0-9]+', ipv6_range):
+ for tmp in ipv6_range.split('-'):
+ if not is_ipv6(tmp):
+ sys.exit(1)
+
+ sys.exit(0)
diff --git a/src/validators/ipv6-range-exclude b/src/validators/ipv6-range-exclude
new file mode 100755
index 000000000..912b55ae3
--- /dev/null
+++ b/src/validators/ipv6-range-exclude
@@ -0,0 +1,7 @@
+#!/bin/sh
+arg="$1"
+if [ "${arg:0:1}" != "!" ]; then
+ exit 1
+fi
+path=$(dirname "$0")
+${path}/ipv6-range "${arg:1}"
diff --git a/src/validators/sysctl b/src/validators/sysctl
new file mode 100755
index 000000000..9b5bba3e1
--- /dev/null
+++ b/src/validators/sysctl
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 VyOS maintainers and contributors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# 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/>.
+
+declare -a array
+eval "array=($(/sbin/sysctl -N -a))"
+
+if [[ ! " ${array[@]} " =~ " $1 " ]]; then
+ # passed sysctl option is invalid
+ exit 1
+fi
+exit 0
diff --git a/src/validators/vrf-name b/src/validators/vrf-name
index 7b6313888..29167c635 100755
--- a/src/validators/vrf-name
+++ b/src/validators/vrf-name
@@ -33,8 +33,8 @@ if __name__ == '__main__':
if vrf == "lo":
exit(1)
- pattern = "^(?!(bond|br|dum|eth|lan|eno|ens|enp|enx|gnv|ipoe|l2tp|l2tpeth|" \
- "vtun|ppp|pppoe|peth|tun|vti|vxlan|wg|wlan|wlm)\d+(\.\d+(v.+)?)?$).*$"
+ pattern = r'^(?!(bond|br|dum|eth|lan|eno|ens|enp|enx|gnv|ipoe|l2tp|l2tpeth|\
+ vtun|ppp|pppoe|peth|tun|vti|vxlan|wg|wlan|wwan|\d)\d*(\.\d+)?(v.+)?).*$'
if not re.match(pattern, vrf):
exit(1)