summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrae Santiago <tsantiago@us.ibm.com>2023-12-12 05:26:21 -0600
committerChristian Breunig <christian@breunig.cc>2023-12-13 07:50:58 +0100
commit5acc655c316216122ba975f30df7b76f161cbf02 (patch)
treecc486f663e298836ea395d9c1999ef363041836c
parentf82f1ca1bc55fe75aa6495fe89dbe597055742b5 (diff)
downloadvyos-1x-5acc655c316216122ba975f30df7b76f161cbf02.tar.gz
vyos-1x-5acc655c316216122ba975f30df7b76f161cbf02.zip
validator: T5816: large community validator should only allos character set and basic format
-rwxr-xr-xsrc/validators/bgp-large-community-list8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/validators/bgp-large-community-list b/src/validators/bgp-large-community-list
index 80112dfdc..9ba5b27eb 100755
--- a/src/validators/bgp-large-community-list
+++ b/src/validators/bgp-large-community-list
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2021 VyOS maintainers and contributors
+# Copyright (C) 2021-2023 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
@@ -17,9 +17,8 @@
import re
import sys
-from vyos.template import is_ipv4
-
pattern = '(.*):(.*):(.*)'
+allowedChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '+', '*', '?', '^', '$', '(', ')', '[', ']', '{', '}', '|', '\\', ':', '-' }
if __name__ == '__main__':
if len(sys.argv) != 2:
@@ -29,8 +28,7 @@ if __name__ == '__main__':
if not len(value) == 3:
sys.exit(1)
- if not (re.match(pattern, sys.argv[1]) and
- (is_ipv4(value[0]) or value[0].isdigit()) and (value[1].isdigit() or value[1] == '*')):
+ if not (re.match(pattern, sys.argv[1]) and set(sys.argv[1]).issubset(allowedChars)):
sys.exit(1)
sys.exit(0)