optimize regular expression for postgres config parsing

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
This commit is contained in:
Christoph Hartmann 2017-01-03 18:51:39 +01:00
parent 32ace063e8
commit efab62ef00
3 changed files with 12 additions and 1 deletions

View file

@ -74,7 +74,10 @@ module Inspec::Resources
raw_conf = read_file(to_read[0])
@content += raw_conf
params = SimpleConfig.new(raw_conf).params
opts = {
assignment_re: /^\s*([^=]*?)\s*=\s*[']?\s*(.*?)\s*[']?\s*$/,
}
params = SimpleConfig.new(raw_conf, opts).params
@params.merge!(params)
to_read = to_read.drop(1)

View file

@ -128,6 +128,7 @@ class MockLoader
'/etc/xinetd.d/chargen-stream' => mockfile.call('xinetd.d_chargen-stream'),
'/etc/xinetd.d/chargen-dgram' => mockfile.call('xinetd.d_chargen-dgram'),
'/etc/sysctl.conf' => mockfile.call('sysctl.conf'),
'/etc/postgresql/9.4/main/postgresql.conf' => mockfile.call('postgresql.conf'),
}
# create all mock commands

View file

@ -0,0 +1,7 @@
# PostgreSQL configuration file
data_directory = '/var/lib/postgresql/9.4/main'
datestyle = 'iso, mdy'
log_connections = on
doublequote = ''value''
empty =
key