summaryrefslogtreecommitdiff
path: root/src/validators
diff options
context:
space:
mode:
authorsarthurdev <965089+sarthurdev@users.noreply.github.com>2022-01-13 12:58:37 +0100
committersarthurdev <965089+sarthurdev@users.noreply.github.com>2022-01-14 14:04:39 +0100
commitdf5a862beb84145dfc8434efde7d7fee783199cf (patch)
tree5a6f09bc9c035a5c4dacc5714536af3340a0059d /src/validators
parenta132ba993e786994a3b129c72fb0024931339619 (diff)
downloadvyos-1x-df5a862beb84145dfc8434efde7d7fee783199cf.tar.gz
vyos-1x-df5a862beb84145dfc8434efde7d7fee783199cf.zip
firewall: T4178: Use lowercase for TCP flags and add an validator
Diffstat (limited to 'src/validators')
-rwxr-xr-xsrc/validators/tcp-flag19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/validators/tcp-flag b/src/validators/tcp-flag
new file mode 100755
index 000000000..86ebec189
--- /dev/null
+++ b/src/validators/tcp-flag
@@ -0,0 +1,19 @@
+#!/usr/bin/python3
+
+import sys
+import re
+
+if __name__ == '__main__':
+ if len(sys.argv)>1:
+ flags = sys.argv[1].split(",")
+
+ for flag in flags:
+ if flag and flag[0] == '!':
+ flag = flag[1:]
+ if flag.lower() not in ['syn', 'ack', 'rst', 'fin', 'urg', 'psh']:
+ print(f'Error: {flag} is not a valid TCP flag')
+ sys.exit(1)
+ else:
+ sys.exit(2)
+
+ sys.exit(0)