class Inspec::Resources::Nginx
Attributes
bin_dir[R]
params[R]
Public Class Methods
new(nginx_path = "/usr/sbin/nginx")
click to toggle source
# File lib/inspec/resources/nginx.rb, line 23 def initialize(nginx_path = "/usr/sbin/nginx") return skip_resource "The `nginx` resource is not yet available on your OS." if inspec.os.windows? return skip_resource "The `nginx` binary not found in the path provided." unless inspec.command(nginx_path).exist? cmd = inspec.command("#{nginx_path} -V 2>&1") if cmd.exit_status != 0 return skip_resource "Error using the command nginx -V" end @data = cmd.stdout @params = {} read_content end
Public Instance Methods
compiler_info()
click to toggle source
# File lib/inspec/resources/nginx.rb, line 48 def compiler_info result = @data.scan(/built by (\S+)\s(\S+)\s(\S+)/).flatten Hashie::Mash.new({ "compiler" => result[0], "version" => result[1], "date" => result[2] }) end
modules()
click to toggle source
# File lib/inspec/resources/nginx.rb, line 58 def modules @data.scan(/--with-(\S+)_module/).flatten end
openssl_version()
click to toggle source
# File lib/inspec/resources/nginx.rb, line 43 def openssl_version result = @data.scan(/built with OpenSSL\s(\S+)\s(\d+\s\S+\s\d{4})/).flatten Hashie::Mash.new({ "version" => result[0], "date" => result[1] }) end
support_info()
click to toggle source
# File lib/inspec/resources/nginx.rb, line 53 def support_info support_info = @data.scan(/(.*\S+) support enabled/).flatten support_info.empty? ? nil : support_info.join(" ") end
to_s()
click to toggle source
# File lib/inspec/resources/nginx.rb, line 62 def to_s "Nginx Environment" end
Private Instance Methods
parse_config()
click to toggle source
# File lib/inspec/resources/nginx.rb, line 74 def parse_config @params[:prefix] = @data.scan(/--prefix=(\S+)\s/).flatten.first @params[:service] = "nginx" @params[:version] = @data.scan(%r{nginx version: nginx\/(\S+)\s}).flatten.first end
parse_http_path()
click to toggle source
# File lib/inspec/resources/nginx.rb, line 88 def parse_http_path @params[:http_client_body_temp_path] = @data.scan(/--http-client-body-temp-path=(\S+)\s/).flatten.first @params[:http_proxy_temp_path] = @data.scan(/--http-proxy-temp-path=(\S+)\s/).flatten.first @params[:http_fastcgi_temp_path] = @data.scan(/--http-fastcgi-temp-path=(\S+)\s/).flatten.first @params[:http_uwsgi_temp_path] = @data.scan(/--http-uwsgi-temp-path=(\S+)\s/).flatten.first @params[:http_scgi_temp_path] = @data.scan(/--http-scgi-temp-path=(\S+)\s/).flatten.first end
parse_path()
click to toggle source
# File lib/inspec/resources/nginx.rb, line 80 def parse_path @params[:sbin_path] = @data.scan(/--sbin-path=(\S+)\s/).flatten.first @params[:modules_path] = @data.scan(/--modules-path=(\S+)\s/).flatten.first @params[:error_log_path] = @data.scan(/--error-log-path=(\S+)\s/).flatten.first @params[:http_log_path] = @data.scan(/--http-log-path=(\S+)\s/).flatten.first @params[:lock_path] = @data.scan(/--lock-path=(\S+)\s/).flatten.first end
read_content()
click to toggle source
# File lib/inspec/resources/nginx.rb, line 68 def read_content parse_config parse_path parse_http_path end