summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2023-12-13 09:53:28 +0200
committerGitHub <noreply@github.com>2023-12-13 09:53:28 +0200
commit6b18f0d0bd6d688b84d54aec8f5a46687c7317f6 (patch)
tree794f872c659a7901ea020f23e5cfed4c01d6951c
parentae077c87acdc680454ec4a849063a7572861f4bd (diff)
parentbaf065ff555e3e548ca0d19b6b5bbf8f97297a9e (diff)
downloadvyos-1x-6b18f0d0bd6d688b84d54aec8f5a46687c7317f6.tar.gz
vyos-1x-6b18f0d0bd6d688b84d54aec8f5a46687c7317f6.zip
Merge pull request #2625 from vyos/mergify/bp/sagitta/pr-2618
validator: T5816: large community validator should only allos character set and basic format (backport #2618)
-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)