summaryrefslogtreecommitdiff
path: root/src/helpers/strip-private.py
diff options
context:
space:
mode:
authorerkin <e.altunbas@vyos.io>2021-09-17 12:03:15 +0300
committererkin <e.altunbas@vyos.io>2021-09-17 12:03:15 +0300
commitc1e0a1148c867c1202a0f69ac83f77e14272effd (patch)
treef5082bd185804d6e0429a8b69e317a9f0734d60f /src/helpers/strip-private.py
parente626407f4c246941eb2ca1b167a4b594b7bf6461 (diff)
downloadvyos-1x-c1e0a1148c867c1202a0f69ac83f77e14272effd.tar.gz
vyos-1x-c1e0a1148c867c1202a0f69ac83f77e14272effd.zip
T3823: Stop strip-private regexp from swallowing quotes
Diffstat (limited to 'src/helpers/strip-private.py')
-rwxr-xr-xsrc/helpers/strip-private.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/helpers/strip-private.py b/src/helpers/strip-private.py
index c165d2cba..c74a379aa 100755
--- a/src/helpers/strip-private.py
+++ b/src/helpers/strip-private.py
@@ -47,7 +47,7 @@ ipv4_re = re.compile(r'(\d{1,3}\.){2}(\d{1,3}\.\d{1,3})')
ipv4_subst = r'xxx.xxx.\2'
# Censor all but the first two fields.
-ipv6_re = re.compile(r'([0-9a-fA-F]{1,4}\:){2}(\S+)')
+ipv6_re = re.compile(r'([0-9a-fA-F]{1,4}\:){2}([0-9a-fA-F:]+)')
ipv6_subst = r'xxxx:xxxx:\2'
def ip_match(match: re.Match, subst: str) -> str:
@@ -96,12 +96,12 @@ if __name__ == "__main__":
args = parser.parse_args()
# Strict mode is the default and the absence of loose mode implies presence of strict mode.
if not args.loose:
- for arg in [args.mac, args.domain, args.hostname, args.username, args.dhcp, args.asn, args.snmp, args.lldp]:
- arg = True
+ args.mac = args.domain = args.hostname = args.username = args.dhcp = args.asn = args.snmp = args.lldp = True
if not args.public_address and not args.keep_address:
args.address = True
elif not args.address and not args.public_address:
args.keep_address = True
+
# (condition, precompiled regexp, substitution string)
stripping_rules = [
# Strip passwords
@@ -120,7 +120,7 @@ if __name__ == "__main__":
(True, re.compile(r'private-key \S+'), 'private-key xxxxxx'),
# Strip MAC addresses
- (args.mac, re.compile(r'([0-9a-fA-F]{2}\:){5}([0-9a-fA-F]{2}((\:{0,1})){3})'), r'XX:XX:XX:XX:XX:\2'),
+ (args.mac, re.compile(r'([0-9a-fA-F]{2}\:){5}([0-9a-fA-F]{2}((\:{0,1})){3})'), r'xx:xx:xx:xx:xx:\2'),
# Strip host-name, domain-name, and domain-search
(args.hostname, re.compile(r'(host-name|domain-name|domain-search) \S+'), r'\1 xxxxxx'),