inspec 0.32.0 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -2
- data/Gemfile +2 -1
- data/README.md +1 -1
- data/docs/dsl_inspec.rst +21 -0
- data/docs/resources.rst +3 -3
- data/docs/ruby_usage.rst +1 -1
- data/inspec.gemspec +1 -1
- data/lib/bundles/inspec-compliance/http.rb +2 -0
- data/lib/inspec/base_cli.rb +1 -1
- data/lib/inspec/control_eval_context.rb +145 -0
- data/lib/inspec/dependencies/dependency_set.rb +21 -6
- data/lib/inspec/dependencies/requirement.rb +13 -6
- data/lib/inspec/dependencies/resolver.rb +2 -2
- data/lib/inspec/dsl.rb +3 -32
- data/lib/inspec/dsl_shared.rb +25 -0
- data/lib/inspec/library_eval_context.rb +47 -0
- data/lib/inspec/plugins/resource.rb +63 -63
- data/lib/inspec/profile.rb +61 -31
- data/lib/inspec/profile_context.rb +48 -140
- data/lib/inspec/resource.rb +13 -7
- data/lib/inspec/rspec_json_formatter.rb +37 -6
- data/lib/inspec/rule.rb +4 -0
- data/lib/inspec/runner.rb +86 -86
- data/lib/inspec/version.rb +1 -1
- data/lib/matchers/matchers.rb +1 -1
- data/lib/resources/apache_conf.rb +1 -1
- data/lib/resources/mysql.rb +1 -1
- data/lib/resources/powershell.rb +3 -7
- data/lib/resources/service.rb +3 -3
- data/lib/resources/vbscript.rb +17 -1
- metadata +7 -4
data/lib/inspec/version.rb
CHANGED
data/lib/matchers/matchers.rb
CHANGED
@@ -21,7 +21,7 @@ module Inspec::Resources
|
|
21
21
|
|
22
22
|
def initialize(conf_path = nil)
|
23
23
|
@conf_path = conf_path || inspec.apache.conf_path
|
24
|
-
@conf_dir = File.dirname(@conf_path)
|
24
|
+
@conf_dir = conf_path ? File.dirname(@conf_path) : inspec.apache.conf_dir
|
25
25
|
@files_contents = {}
|
26
26
|
@content = nil
|
27
27
|
@params = nil
|
data/lib/resources/mysql.rb
CHANGED
data/lib/resources/powershell.rb
CHANGED
@@ -22,13 +22,9 @@ module Inspec::Resources
|
|
22
22
|
unless inspec.os.windows?
|
23
23
|
return skip_resource 'The `script` resource is not supported on your OS yet.'
|
24
24
|
end
|
25
|
-
|
26
|
-
#
|
27
|
-
|
28
|
-
require 'winrm'
|
29
|
-
script = WinRM::PowershellScript.new(script)
|
30
|
-
cmd = "powershell -encodedCommand #{script.encoded}"
|
31
|
-
super(cmd)
|
25
|
+
# since WinRM 2.0 and the default use of powershell for local execution in
|
26
|
+
# train, we do not need to wrap the script here anymore
|
27
|
+
super(script)
|
32
28
|
end
|
33
29
|
|
34
30
|
# we cannot determine if a command exists, because that does not work for scripts
|
data/lib/resources/service.rb
CHANGED
@@ -407,9 +407,9 @@ module Inspec::Resources
|
|
407
407
|
# read all enabled services from runlevel
|
408
408
|
# on rhel via: 'chkconfig --list', is not installed by default
|
409
409
|
# bash: for i in `find /etc/rc*.d -name S*`; do basename $i | sed -r 's/^S[0-9]+//'; done | sort | uniq
|
410
|
-
enabled_services_cmd = inspec.command('find /etc/rc*.d -name S*')
|
410
|
+
enabled_services_cmd = inspec.command('find /etc/rc*.d /etc/init.d/rc*.d -name S*').stdout
|
411
411
|
service_line = %r{rc(?<runlevel>[0-6])\.d/S[^/]*?#{Regexp.escape service_name}$}
|
412
|
-
all_services = enabled_services_cmd.
|
412
|
+
all_services = enabled_services_cmd.split("\n").map { |line|
|
413
413
|
service_line.match(line)
|
414
414
|
}.compact
|
415
415
|
enabled = !all_services.empty?
|
@@ -575,7 +575,7 @@ module Inspec::Resources
|
|
575
575
|
# - 6: Pause Pending
|
576
576
|
# - 7: Paused
|
577
577
|
def info(service_name)
|
578
|
-
cmd = inspec.command("New-Object -Type PSObject | Add-Member -MemberType NoteProperty -Name Service -Value (Get-Service -Name #{service_name}| Select-Object -Property Name, DisplayName, Status) -PassThru | Add-Member -MemberType NoteProperty -Name WMI -Value (Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -eq '#{service_name}' -or $_.DisplayName -eq '#{service_name}'} | Select-Object -Property StartMode) -PassThru | ConvertTo-Json")
|
578
|
+
cmd = inspec.command("New-Object -Type PSObject | Add-Member -MemberType NoteProperty -Name Service -Value (Get-Service -Name '#{service_name}'| Select-Object -Property Name, DisplayName, Status) -PassThru | Add-Member -MemberType NoteProperty -Name WMI -Value (Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -eq '#{service_name}' -or $_.DisplayName -eq '#{service_name}'} | Select-Object -Property StartMode) -PassThru | ConvertTo-Json")
|
579
579
|
|
580
580
|
# cannot rely on exit code for now, successful command returns exit code 1
|
581
581
|
# return nil if cmd.exit_status != 0
|
data/lib/resources/vbscript.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
# author: Christoph Hartmann
|
3
3
|
# author: Dominik Richter
|
4
4
|
|
5
|
+
require 'securerandom'
|
6
|
+
|
5
7
|
module Inspec::Resources
|
6
8
|
# This resource allows users to run vbscript on windows machines. We decided
|
7
9
|
# not to use scriptcontrol, due to the fact that it works on 32 bit systems only:
|
@@ -34,10 +36,11 @@ module Inspec::Resources
|
|
34
36
|
|
35
37
|
def initialize(vbscript)
|
36
38
|
return skip_resource 'The `vbscript` resource is not supported on your OS yet.' unless inspec.os.windows?
|
37
|
-
|
39
|
+
@seperator = SecureRandom.uuid
|
38
40
|
cmd = <<-EOH
|
39
41
|
$vbscript = @"
|
40
42
|
#{vbscript}
|
43
|
+
Wscript.Stdout.Write "#{@seperator}"
|
41
44
|
"@
|
42
45
|
$filename = [System.IO.Path]::GetTempFileName() + ".vbs"
|
43
46
|
New-Item $filename -type file -force -value $vbscript | Out-Null
|
@@ -47,8 +50,21 @@ EOH
|
|
47
50
|
super(cmd)
|
48
51
|
end
|
49
52
|
|
53
|
+
def result
|
54
|
+
@result ||= parse_stdout
|
55
|
+
end
|
56
|
+
|
50
57
|
def to_s
|
51
58
|
'Windows VBScript'
|
52
59
|
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def parse_stdout
|
64
|
+
res = inspec.backend.run_command(@command)
|
65
|
+
parsed_result = res.stdout.gsub(/#{@seperator}\r\n$/, '')
|
66
|
+
res.stdout = parsed_result
|
67
|
+
res
|
68
|
+
end
|
53
69
|
end
|
54
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.33.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: train
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.19.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '1.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.19.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '1.0'
|
@@ -296,6 +296,7 @@ files:
|
|
296
296
|
- lib/inspec/cli.rb
|
297
297
|
- lib/inspec/completions/bash.sh.erb
|
298
298
|
- lib/inspec/completions/zsh.sh.erb
|
299
|
+
- lib/inspec/control_eval_context.rb
|
299
300
|
- lib/inspec/dependencies/dependency_set.rb
|
300
301
|
- lib/inspec/dependencies/lockfile.rb
|
301
302
|
- lib/inspec/dependencies/requirement.rb
|
@@ -303,10 +304,12 @@ files:
|
|
303
304
|
- lib/inspec/dependencies/vendor_index.rb
|
304
305
|
- lib/inspec/describe.rb
|
305
306
|
- lib/inspec/dsl.rb
|
307
|
+
- lib/inspec/dsl_shared.rb
|
306
308
|
- lib/inspec/env_printer.rb
|
307
309
|
- lib/inspec/errors.rb
|
308
310
|
- lib/inspec/expect.rb
|
309
311
|
- lib/inspec/fetcher.rb
|
312
|
+
- lib/inspec/library_eval_context.rb
|
310
313
|
- lib/inspec/log.rb
|
311
314
|
- lib/inspec/metadata.rb
|
312
315
|
- lib/inspec/objects.rb
|