gixy
gixy copied to clipboard
Crashes on empty conf.d directory
I have the default Ubuntu nginx.conf that contains the line include /etc/nginx/conf.d/*.conf;
For me that directory happens to be empty and this causes gixy to crash.
I would either expect it ignore the empty directory or have an additional analysis rule that will flag that as an error or warning.
Here's the stack trace
[nginx_parser] WARNING File not found: /etc/nginx/conf.d/*.conf
Traceback (most recent call last):
File "/usr/local/bin/gixy", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/gixy/cli/main.py", line 153, in main
yoda.audit(path)
File "/usr/local/lib/python2.7/dist-packages/gixy/core/manager.py", line 24, in audit
self._audit_recursive(self.root.children)
File "/usr/local/lib/python2.7/dist-packages/gixy/core/manager.py", line 39, in _audit_recursive
self._audit_recursive(directive.children)
File "/usr/local/lib/python2.7/dist-packages/gixy/core/manager.py", line 39, in _audit_recursive
self._audit_recursive(directive.children)
File "/usr/local/lib/python2.7/dist-packages/gixy/core/manager.py", line 39, in _audit_recursive
self._audit_recursive(directive.children)
File "/usr/local/lib/python2.7/dist-packages/gixy/core/manager.py", line 39, in _audit_recursive
self._audit_recursive(directive.children)
File "/usr/local/lib/python2.7/dist-packages/gixy/core/manager.py", line 34, in _audit_recursive
self._update_variables(directive)
File "/usr/local/lib/python2.7/dist-packages/gixy/core/manager.py", line 49, in _update_variables
for var in directive.variables:
File "/usr/local/lib/python2.7/dist-packages/cached_property.py", line 26, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/usr/local/lib/python2.7/dist-packages/gixy/directives/block.py", line 119, in variables
for name, group in regexp.groups.items():
File "/usr/local/lib/python2.7/dist-packages/cached_property.py", line 26, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/usr/local/lib/python2.7/dist-packages/gixy/core/regexp.py", line 1004, in groups
for name, parsed in extract_groups(self.parsed).items():
File "/usr/local/lib/python2.7/dist-packages/gixy/core/regexp.py", line 1025, in parsed
self._parsed = sre_parse.parse(FIX_NAMED_GROUPS_RE.sub('(?P<\\1>', self.source))
File "/usr/local/lib/python2.7/dist-packages/gixy/core/sre_parse/sre_parse.py", line 707, in parse
p = _parse_sub(source, pattern, 0)
File "/usr/local/lib/python2.7/dist-packages/gixy/core/sre_parse/sre_parse.py", line 311, in _parse_sub
itemsappend(_parse(source, state))
File "/usr/local/lib/python2.7/dist-packages/gixy/core/sre_parse/sre_parse.py", line 666, in _parse
p = _parse_sub(source, state)
File "/usr/local/lib/python2.7/dist-packages/gixy/core/sre_parse/sre_parse.py", line 311, in _parse_sub
itemsappend(_parse(source, state))
File "/usr/local/lib/python2.7/dist-packages/gixy/core/sre_parse/sre_parse.py", line 688, in _parse
code = _escape(source, this, state)
File "/usr/local/lib/python2.7/dist-packages/gixy/core/sre_parse/sre_parse.py", line 301, in _escape
raise error("bogus escape: %s" % repr(escape))
gixy.core.sre_parse.sre_constants.error: bogus escape: '\\x'
Gixy v0.1.3 Python 2.7.13
Hi! Thanks for your issue:)
Gixy ignores empty directory or not existing files.
The crashe happens by another reason, it can't parse one of your regular expression :(
Did you uses \x
in one of regex for if
or location
directives?
P.S. I'll make a normal error message in case of regex parsing error a bit later.
Turns out someone accidentally turned \.xml
into \xml
in one of the redirect rules.
Good catch by gixy, nginx -t
didn't flinch at all!