yandex / gixy

Nginx configuration static analyzer
Other
8.28k stars 394 forks source link

nginx parser fail #73

Open Josue-T opened 6 years ago

Josue-T commented 6 years ago

Hello,

I have sometime this error while I lunch gixy. I think it's not really in relation with the file because it is parsed many time and it's only on the 18 time that it fail.

# gixy -d
[main]  DEBUG   logging initialized
[manager]       DEBUG   Audit config file: /etc/nginx/nginx.conf
[nginx_parser]  DEBUG   Parse file: /etc/nginx/mime.types
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/yunohost_admin.conf
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/yunohost_admin.conf.inc
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/yunohost_api.conf.inc
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/global.conf
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/domain2.tld.conf
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/yunohost_admin.conf.inc
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/yunohost_api.conf.inc

....

[nginx_parser]  DEBUG   Parse file: /etc/nginx/fastcgi_params
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/yunohost_panel.conf.inc
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/domain1.tld.d/monitorix.conf
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/yunohost_panel.conf.inc
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/yunohost_admin.conf.inc
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/yunohost_api.conf.inc
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/domain3.tld.conf
[nginx_parser]  DEBUG   Parse file: /etc/nginx/conf.d/domain3.tld.d/movim.conf
[nginx_parser]  DEBUG   Parse file: /etc/nginx/fastcgi_params
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 169, in main
    yoda.audit(path, fdata, is_stdin=False)
  File "/usr/local/lib/python2.7/dist-packages/gixy/core/manager.py", line 24, in audit
    self.root = parser.parse(content=file_data.read(), path_info=file_path)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 50, in parse
    self.parse_block(parsed, root)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 62, in parse_block
    directive_inst = self.directive_factory(parsed_type, parsed_name, parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 76, in directive_factory
    self.parse_block(children, inst)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 60, in parse_block
    self._resolve_include(parsed_args, parent)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 108, in _resolve_include
    return self._resolve_file_include(pattern=pattern, parent=parent)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 119, in _resolve_file_include
    self.parse_file(file_path, include)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 27, in parse_file
    return self.parse(content=content, root=root, path_info=path)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 50, in parse
    self.parse_block(parsed, root)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 62, in parse_block
    directive_inst = self.directive_factory(parsed_type, parsed_name, parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 76, in directive_factory
    self.parse_block(children, inst)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 60, in parse_block
    self._resolve_include(parsed_args, parent)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 108, in _resolve_include
    return self._resolve_file_include(pattern=pattern, parent=parent)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 119, in _resolve_file_include
    self.parse_file(file_path, include)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 27, in parse_file
    return self.parse(content=content, root=root, path_info=path)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 50, in parse
    self.parse_block(parsed, root)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 62, in parse_block
    directive_inst = self.directive_factory(parsed_type, parsed_name, parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/gixy/parser/nginx_parser.py", line 72, in directive_factory
    args = [str(v).strip() for v in parsed_args[0]]
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
buglloc commented 6 years ago

Hi! can your attach /etc/nginx/fastcgi_params file to this issue or via email buglloc [at] yandex.ru?

Josue-T commented 6 years ago

Hello,

This is my fastcgi_params file :

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;