Skip to content

Commit

Permalink
Remove 'clean' session and update get_external_nameservers function
Browse files Browse the repository at this point in the history
The 'clean' section from rpm/gixy.spec file has been removed because it is no longer needed. Moreover, an important update has been made to the get_external_nameservers function under gixy/directives/directive.py to handle different types of IP addresses when getting a list of external nameservers used by the resolver directive. This enhances the function's capabilities in handling different IP address situations. Additionally, bumped the project version in gixy/__init__.py.
  • Loading branch information
dvershinin committed Jan 7, 2024
1 parent fcf4dce commit 667c676
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/en/plugins/resolver_external.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# [resolver_external] Using external DNS nameservers
2 changes: 1 addition & 1 deletion gixy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from gixy.core import severity

version = '0.1.22'
version = '0.1.23'
30 changes: 28 additions & 2 deletions gixy/directives/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,35 @@ def __init__(self, name, args):
self.addresses = addresses

def get_external_nameservers(self):
"""Get a list of external nameservers used by the resolver directive"""
external_nameservers = []
for addr in self.addresses:
ip = addr.rsplit(':', 1)[0]
if ip not in ['127.0.0.1', '[::1]']:
external_nameservers.append(ip)

# Check for IPv4 addresses
if '.' in ip:
# Exclude loopback addresses (127.0.0.0/8)
if ip.startswith('127.'):
continue
# Exclude private addresses (10.x.x.x, 172.16.x.x - 172.31.x.x, 192.168.x.x)
if ip.startswith('10.') or ip.startswith('192.168.'):
continue
if ip.startswith('172.'):
second_octet = int(ip.split('.')[1])
if 16 <= second_octet <= 31:
continue

# Check for IPv6 addresses
elif ':' in ip:
# Exclude loopback address ([::1])
if ip == '::1':

This comment has been minimized.

Copy link
@LeviPesin

LeviPesin Jan 13, 2024

Shouldn't this be wrapped in brackets?

This comment has been minimized.

Copy link
@dvershinin

dvershinin Jan 14, 2024

Author Owner

Fixed in the new release v0.1.24

continue
# Exclude link-local addresses (fe80::/10)
if ip.startswith('fe80:'):
continue
# Exclude unique local addresses (fc00::/7)
if ip.startswith('fc') or ip.startswith('fd'):
continue

external_nameservers.append(ip)
return external_nameservers
5 changes: 1 addition & 4 deletions rpm/gixy.spec
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ Provides: %{name} = %{verion}-%{release}
########################################################################################

%description
Gixy is a tool to analyze Nginx configuration. The main goal of Gixy is to prevent
Gixy is a tool to analyze Nginx configuration. The main goal of Gixy is to prevent
misconfiguration and automate flaw detection.

########################################################################################

%prep
%setup -qn %{name}-%{version}

%clean
rm -rf %{buildroot}

%build
python setup.py build
Expand Down Expand Up @@ -75,4 +73,3 @@ python setup.py install --prefix=%{_prefix} \

* Sat Apr 29 2017 Yandex Team <opensource@yandex-team.ru> - 0.1.1-0
- Initial build

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
resolver 10.0.0.1;

0 comments on commit 667c676

Please sign in to comment.