summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-12-13 07:52:34 +0100
committerGitHub <noreply@github.com>2023-12-13 07:52:34 +0100
commit5dda9e0968cd6b727030d7723805df656bcc5b10 (patch)
tree8287d7e478732550a9f588f27a2f1d258ad16a51 /src
parenta2b9477a3484999ca5d1acd65fbb19af4a5c1162 (diff)
parent5acc655c316216122ba975f30df7b76f161cbf02 (diff)
downloadvyos-1x-5dda9e0968cd6b727030d7723805df656bcc5b10.tar.gz
vyos-1x-5dda9e0968cd6b727030d7723805df656bcc5b10.zip
Merge pull request #2618 from Trae32566/T5816
validator: T5816: large community validator should only allos character set and basic format
Diffstat (limited to 'src')
-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)