From e7c39460edfb3e960e8054b1d7eda80a2d666e92 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 21 Jun 2019 15:26:08 +0200 Subject: [PATCH] ipaddr: Handle ipaddress index in network correctly (#57896) This commit prevents integer indices from being parsed as ip nets Fixes #57895 Signed-off-by: Tobias Schramm --- changelogs/fragments/57896-fix-ipaddr-cidr-index-handling.yml | 2 ++ lib/ansible/plugins/filter/ipaddr.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/57896-fix-ipaddr-cidr-index-handling.yml diff --git a/changelogs/fragments/57896-fix-ipaddr-cidr-index-handling.yml b/changelogs/fragments/57896-fix-ipaddr-cidr-index-handling.yml new file mode 100644 index 00000000000..7593504466c --- /dev/null +++ b/changelogs/fragments/57896-fix-ipaddr-cidr-index-handling.yml @@ -0,0 +1,2 @@ +bugfixes: + - 'ipaddr: prevent integer indices from being parsed as ip nets' diff --git a/lib/ansible/plugins/filter/ipaddr.py b/lib/ansible/plugins/filter/ipaddr.py index d2d1c74b907..f2961b825e9 100644 --- a/lib/ansible/plugins/filter/ipaddr.py +++ b/lib/ansible/plugins/filter/ipaddr.py @@ -630,7 +630,7 @@ def ipaddr(value, query='', version=False, alias='ipaddr'): # address/network is inside that specific subnet try: # ?? 6to4 and link-local were True here before. Should they still? - if query and (query not in query_func_map or query == 'cidr_lookup') and ipaddr(query, 'network'): + if query and (query not in query_func_map or query == 'cidr_lookup') and not str(query).isdigit() and ipaddr(query, 'network'): iplist = netaddr.IPSet([netaddr.IPNetwork(query)]) query = 'cidr_lookup' except Exception: