mirror of
https://github.com/inspec/inspec
synced 2024-09-21 06:51:56 +00:00
optimize regular expression for postgres config parsing
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
This commit is contained in:
parent
32ace063e8
commit
efab62ef00
3 changed files with 12 additions and 1 deletions
|
@ -74,7 +74,10 @@ module Inspec::Resources
|
||||||
raw_conf = read_file(to_read[0])
|
raw_conf = read_file(to_read[0])
|
||||||
@content += raw_conf
|
@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)
|
@params.merge!(params)
|
||||||
|
|
||||||
to_read = to_read.drop(1)
|
to_read = to_read.drop(1)
|
||||||
|
|
|
@ -128,6 +128,7 @@ class MockLoader
|
||||||
'/etc/xinetd.d/chargen-stream' => mockfile.call('xinetd.d_chargen-stream'),
|
'/etc/xinetd.d/chargen-stream' => mockfile.call('xinetd.d_chargen-stream'),
|
||||||
'/etc/xinetd.d/chargen-dgram' => mockfile.call('xinetd.d_chargen-dgram'),
|
'/etc/xinetd.d/chargen-dgram' => mockfile.call('xinetd.d_chargen-dgram'),
|
||||||
'/etc/sysctl.conf' => mockfile.call('sysctl.conf'),
|
'/etc/sysctl.conf' => mockfile.call('sysctl.conf'),
|
||||||
|
'/etc/postgresql/9.4/main/postgresql.conf' => mockfile.call('postgresql.conf'),
|
||||||
}
|
}
|
||||||
|
|
||||||
# create all mock commands
|
# create all mock commands
|
||||||
|
|
7
test/unit/mock/files/postgresql.conf
Normal file
7
test/unit/mock/files/postgresql.conf
Normal 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
|
Loading…
Reference in a new issue