summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrae Santiago <tsantiago@us.ibm.com>2023-12-12 05:26:21 -0600
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2023-12-13 06:53:34 +0000
commitbaf065ff555e3e548ca0d19b6b5bbf8f97297a9e (patch)
tree0c0f0fd9a7594f6d5aff5008d3d9bd2f6421cc4b
parentbc460276da84c14b4cb541f28f87fb8a96867611 (diff)
downloadvyos-1x-baf065ff555e3e548ca0d19b6b5bbf8f97297a9e.tar.gz
vyos-1x-baf065ff555e3e548ca0d19b6b5bbf8f97297a9e.zip
validator: T5816: large community validator should only allos character set and basic format
(cherry picked from commit 5acc655c316216122ba975f30df7b76f161cbf02)
-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)