inspec 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -1
- data/Gemfile +1 -2
- data/docs/resources/mount.md.erb +1 -1
- data/docs/resources/zfs_dataset.md.erb +63 -0
- data/docs/resources/zfs_pool.md.erb +57 -0
- data/docs/shared/matcher_cmp.md.erb +4 -4
- data/examples/meta-profile/inspec.lock +1 -1
- data/examples/meta-profile/vendor/6bdab40a3fe9f9de4e7c87f4f3844fdcf2c5cba6f84089b68d47c72392b51fdc.tar.gz +0 -0
- data/lib/bundles/inspec-compliance/cli.rb +1 -1
- data/lib/inspec/resource.rb +2 -0
- data/lib/inspec/rspec_json_formatter.rb +64 -4
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/file.rb +1 -1
- data/lib/resources/kernel_module.rb +6 -5
- data/lib/resources/mount.rb +34 -4
- data/lib/resources/service.rb +2 -2
- data/lib/resources/zfs_dataset.rb +60 -0
- data/lib/resources/zfs_pool.rb +49 -0
- data/lib/utils/parser.rb +15 -1
- metadata +7 -3
- data/examples/meta-profile/vendor/3d473e72d8b70018386a53e0a105e92ccbb4115dc268cadc16ff53d550d2898e.tar.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3a96e098c7ff3d2cb9f43ea5d89cf3a75e34169
|
4
|
+
data.tar.gz: c16f66e486f2502feb4c0596c182d494cf2279f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d052313445bc953e03e27d8f6f35f078df54249fc1736fc6b48c61c4cffe96b5bebc3ecede732b534ca56337134285c96ec915954dde7b9ccb19eca62bd296d
|
7
|
+
data.tar.gz: 4cd5c91590c765f3c9dc8f07721187663245c3092f478672cdaaad95c9ff6ea2f6a3848e76ae36eda2ba5c76a799b01ecdfe22914974816e4a1e7bf70d916cef
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,36 @@
|
|
1
|
+
|
2
|
+
n.n.n / 2017-03-02
|
3
|
+
==================
|
4
|
+
|
5
|
+
* Merge pull request #1520 from chef/adamleff/fix-habitat-build
|
6
|
+
* Add Rake to Habitat build Gemfile
|
7
|
+
* Merge pull request #1454 from jkerry/FunctionalJUnitReporter
|
8
|
+
* correcting a typo, anonymnous -> anonymous
|
9
|
+
* adding gitignore entries for the tar.gz files that result from the functional tests
|
10
|
+
* resolving old junit unit tests with the new format. Adding a skipped test node as a result
|
11
|
+
* Converting the junit reporter to use nokogiri on top of the json reporter output hash
|
1
12
|
# Change Log
|
2
13
|
|
14
|
+
## [1.16.0](https://github.com/chef/inspec/tree/1.16.0) (2017-03-02)
|
15
|
+
[Full Changelog](https://github.com/chef/inspec/compare/v1.15.0...v1.16.0)
|
16
|
+
|
17
|
+
**Implemented enhancements:**
|
18
|
+
|
19
|
+
- Functional JUnit reporter [\#1454](https://github.com/chef/inspec/pull/1454) ([jkerry](https://github.com/jkerry))
|
20
|
+
|
21
|
+
**Closed issues:**
|
22
|
+
|
23
|
+
- Small bug on the registry\_key docs page [\#1523](https://github.com/chef/inspec/issues/1523)
|
24
|
+
|
25
|
+
**Merged pull requests:**
|
26
|
+
|
27
|
+
- use -- for description of inspec login\_automate [\#1527](https://github.com/chef/inspec/pull/1527) ([chris-rock](https://github.com/chris-rock))
|
28
|
+
- fix ident in cmp matcher docs [\#1524](https://github.com/chef/inspec/pull/1524) ([chris-rock](https://github.com/chris-rock))
|
29
|
+
- Add Rake to Habitat build Gemfile [\#1520](https://github.com/chef/inspec/pull/1520) ([adamleff](https://github.com/adamleff))
|
30
|
+
- Fix kernel\_module for centos/redhat [\#1513](https://github.com/chef/inspec/pull/1513) ([postgred](https://github.com/postgred))
|
31
|
+
- Added oracle linux to rhel platform section of 'service' resource. [\#1511](https://github.com/chef/inspec/pull/1511) ([carldjohnston](https://github.com/carldjohnston))
|
32
|
+
- Add FreeBSD support for ZFS datasets and pools [\#1501](https://github.com/chef/inspec/pull/1501) ([jbenden](https://github.com/jbenden))
|
33
|
+
|
3
34
|
## [v1.15.0](https://github.com/chef/inspec/tree/v1.15.0) (2017-02-27)
|
4
35
|
[Full Changelog](https://github.com/chef/inspec/compare/v1.14.1...v1.15.0)
|
5
36
|
|
@@ -27,6 +58,7 @@
|
|
27
58
|
|
28
59
|
**Merged pull requests:**
|
29
60
|
|
61
|
+
- 1.15.0 [\#1519](https://github.com/chef/inspec/pull/1519) ([adamleff](https://github.com/adamleff))
|
30
62
|
- Fix formatting and colors on Windows [\#1510](https://github.com/chef/inspec/pull/1510) ([trickyearlobe](https://github.com/trickyearlobe))
|
31
63
|
- Adding a Habitat profile artifact creator [\#1505](https://github.com/chef/inspec/pull/1505) ([adamleff](https://github.com/adamleff))
|
32
64
|
- create inspec.io/tutorial.html [\#1490](https://github.com/chef/inspec/pull/1490) ([arlimus](https://github.com/arlimus))
|
@@ -2170,4 +2202,4 @@
|
|
2170
2202
|
|
2171
2203
|
|
2172
2204
|
|
2173
|
-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
2205
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/Gemfile
CHANGED
@@ -8,7 +8,7 @@ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2')
|
|
8
8
|
end
|
9
9
|
|
10
10
|
gem 'ffi', '>= 1.9.14'
|
11
|
-
gem '
|
11
|
+
gem 'nokogiri', '~> 1.6'
|
12
12
|
|
13
13
|
group :test do
|
14
14
|
gem 'bundler', '~> 1.5'
|
@@ -19,7 +19,6 @@ group :test do
|
|
19
19
|
gem 'concurrent-ruby', '~> 0.9'
|
20
20
|
gem 'mocha', '~> 1.1'
|
21
21
|
gem 'ruby-progressbar', '~> 1.8'
|
22
|
-
gem 'nokogiri', '~> 1.6'
|
23
22
|
gem 'webmock', '~> 2.3.2'
|
24
23
|
end
|
25
24
|
|
data/docs/resources/mount.md.erb
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
---
|
2
|
+
title: About the zfs_dataset Resource
|
3
|
+
---
|
4
|
+
|
5
|
+
# zfs_dataset
|
6
|
+
|
7
|
+
Use the `zfs_dataset` InSpec audit resource to test the ZFS datasets on FreeBSD systems.
|
8
|
+
|
9
|
+
## Syntax
|
10
|
+
|
11
|
+
A `zfs_dataset` resource block declares the ZFS dataset properties that should be tested:
|
12
|
+
|
13
|
+
describe zfs_dataset('dataset') do
|
14
|
+
it { should MATCHER 'value' }
|
15
|
+
end
|
16
|
+
|
17
|
+
where
|
18
|
+
|
19
|
+
* `('dataset')` is the name of the ZFS dataset (eg: `'tank/tmp'`)
|
20
|
+
* `MATCHER` is a valid matcher for this resource
|
21
|
+
* `'value'` is the value to be tested
|
22
|
+
|
23
|
+
|
24
|
+
## Matchers
|
25
|
+
|
26
|
+
This InSpec audit resource has the matchers listed below, in addition to dynamically exposing all ZFS dataset properties available (see: `man zfs` for the list of supported properties.)
|
27
|
+
|
28
|
+
### be
|
29
|
+
|
30
|
+
<%= partial "/shared/matcher_be" %>
|
31
|
+
|
32
|
+
### be_mounted
|
33
|
+
|
34
|
+
The `be_mounted` matcher tests if the dataset is accessible from the file system:
|
35
|
+
|
36
|
+
it { should be_mounted }
|
37
|
+
|
38
|
+
### cmp
|
39
|
+
|
40
|
+
<%= partial "/shared/matcher_cmp" %>
|
41
|
+
|
42
|
+
### eq
|
43
|
+
|
44
|
+
<%= partial "/shared/matcher_eq" %>
|
45
|
+
|
46
|
+
### match
|
47
|
+
|
48
|
+
<%= partial "/shared/matcher_match" %>
|
49
|
+
|
50
|
+
## Examples
|
51
|
+
|
52
|
+
The following examples show how to use this InSpec audit resource.
|
53
|
+
|
54
|
+
### Test a dataset of 'tank/tmp'
|
55
|
+
|
56
|
+
describe zfs_dataset('tank/tmp') do
|
57
|
+
it { should be_mounted }
|
58
|
+
its('atime') { should eq 'on' }
|
59
|
+
its('compression') { should eq 'lz4' }
|
60
|
+
its('exec') { should eq 'off' }
|
61
|
+
its('readonly') { should eq 'off' }
|
62
|
+
its('setuid') { should eq 'off' }
|
63
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
title: About the zfs_pool Resource
|
3
|
+
---
|
4
|
+
|
5
|
+
# zfs_pool
|
6
|
+
|
7
|
+
Use the `zfs_pool` InSpec audit resource to test the ZFS pools on FreeBSD systems.
|
8
|
+
|
9
|
+
## Syntax
|
10
|
+
|
11
|
+
A `zfs_pool` resource block declares the ZFS pool properties that should be tested:
|
12
|
+
|
13
|
+
describe zfs_pool('pool') do
|
14
|
+
it { should MATCHER 'value' }
|
15
|
+
end
|
16
|
+
|
17
|
+
where
|
18
|
+
|
19
|
+
* `('pool')` is the name of the ZFS pool (eg: `'tank'`)
|
20
|
+
* `MATCHER` is a valid matcher for this resource
|
21
|
+
* `'value'` is the value to be tested
|
22
|
+
|
23
|
+
|
24
|
+
## Matchers
|
25
|
+
|
26
|
+
This InSpec audit resource has the matchers listed below, in addition to dynamically exposing all ZFS pool properties available (see: `man zpool` for the list of supported properties.)
|
27
|
+
|
28
|
+
### be
|
29
|
+
|
30
|
+
<%= partial "/shared/matcher_be" %>
|
31
|
+
|
32
|
+
### cmp
|
33
|
+
|
34
|
+
<%= partial "/shared/matcher_cmp" %>
|
35
|
+
|
36
|
+
### eq
|
37
|
+
|
38
|
+
<%= partial "/shared/matcher_eq" %>
|
39
|
+
|
40
|
+
### match
|
41
|
+
|
42
|
+
<%= partial "/shared/matcher_match" %>
|
43
|
+
|
44
|
+
## Examples
|
45
|
+
|
46
|
+
The following examples show how to use this InSpec audit resource.
|
47
|
+
|
48
|
+
### Test a pool of 'tank'
|
49
|
+
|
50
|
+
describe zfs_pool('tank') do
|
51
|
+
its('autoexpand') { should eq 'off' }
|
52
|
+
its('failmode') { should eq 'continue' }
|
53
|
+
its('feature@lz4_compress') { should eq 'active' }
|
54
|
+
its('health') { should eq 'ONLINE' }
|
55
|
+
its('listsnapshots') { should eq 'off' }
|
56
|
+
its('readonly') { should eq 'off' }
|
57
|
+
end
|
@@ -28,10 +28,10 @@ vs:
|
|
28
28
|
|
29
29
|
Ignoring case sensitivity:
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
describe some_resource do
|
32
|
+
its('setting') { should cmp 'raw' }
|
33
|
+
its('setting') { should cmp 'RAW' }
|
34
|
+
end
|
35
35
|
|
36
36
|
Printing octal values:
|
37
37
|
|
@@ -14,5 +14,5 @@ depends:
|
|
14
14
|
- name: windows-patch-benchmark
|
15
15
|
resolved_source:
|
16
16
|
url: https://github.com/chris-rock/windows-patch-benchmark/archive/master.tar.gz
|
17
|
-
sha256:
|
17
|
+
sha256: 6bdab40a3fe9f9de4e7c87f4f3844fdcf2c5cba6f84089b68d47c72392b51fdc
|
18
18
|
version_constraints: ">= 0"
|
Binary file
|
@@ -76,7 +76,7 @@ module Compliance
|
|
76
76
|
if !options['dctoken'].nil? || !options['usertoken'].nil?
|
77
77
|
msg = login_automate_config(url, options['user'], options['dctoken'], options['usertoken'], options['ent'], options['insecure'])
|
78
78
|
else
|
79
|
-
puts "Please specify a token using --dctoken='DATA_COLLECTOR_TOKEN' or usertoken='AUTOMATE_TOKEN' "
|
79
|
+
puts "Please specify a token using --dctoken='DATA_COLLECTOR_TOKEN' or --usertoken='AUTOMATE_TOKEN' "
|
80
80
|
exit 1
|
81
81
|
end
|
82
82
|
else
|
data/lib/inspec/resource.rb
CHANGED
@@ -132,6 +132,8 @@ require 'resources/windows_task'
|
|
132
132
|
require 'resources/xinetd'
|
133
133
|
require 'resources/wmi'
|
134
134
|
require 'resources/yum'
|
135
|
+
require 'resources/zfs_dataset'
|
136
|
+
require 'resources/zfs_pool'
|
135
137
|
|
136
138
|
# file formats, depend on json implementation
|
137
139
|
require 'resources/json'
|
@@ -791,13 +791,73 @@ class InspecRspecCli < InspecRspecJson # rubocop:disable Metrics/ClassLength
|
|
791
791
|
end
|
792
792
|
end
|
793
793
|
|
794
|
-
class InspecRspecJUnit <
|
794
|
+
class InspecRspecJUnit < InspecRspecJson
|
795
795
|
RSpec::Core::Formatters.register self, :close
|
796
796
|
|
797
|
-
|
798
|
-
|
797
|
+
#
|
798
|
+
# This is the last method is invoked through the formatter interface.
|
799
|
+
# Converts the junit formatter constructed output_hash into nokogiri generated
|
800
|
+
# XML and writes it to output.
|
801
|
+
#
|
802
|
+
def close(_notification)
|
803
|
+
require 'nokogiri'
|
804
|
+
xml_output = Nokogiri::XML::Builder.new { |xml|
|
805
|
+
xml.testsuites do
|
806
|
+
@output_hash[:profiles].each do |profile|
|
807
|
+
build_profile_xml(xml, profile)
|
808
|
+
end
|
809
|
+
end
|
810
|
+
}.to_xml
|
811
|
+
output.puts xml_output
|
799
812
|
end
|
800
813
|
|
801
|
-
|
814
|
+
private
|
815
|
+
|
816
|
+
def build_profile_xml(xml, profile)
|
817
|
+
xml.testsuite(
|
818
|
+
name: profile[:name],
|
819
|
+
tests: count_profile_tests(profile),
|
820
|
+
failed: count_profile_failed_tests(profile),
|
821
|
+
) do
|
822
|
+
profile[:controls].each do |control|
|
823
|
+
build_control_xml(xml, control)
|
824
|
+
end
|
825
|
+
end
|
826
|
+
end
|
827
|
+
|
828
|
+
def build_control_xml(xml, control)
|
829
|
+
return if control[:results].nil?
|
830
|
+
control[:results].each do |result|
|
831
|
+
build_result_xml(xml, control, result)
|
832
|
+
end
|
833
|
+
end
|
834
|
+
|
835
|
+
def build_result_xml(xml, control, result)
|
836
|
+
test_class = control[:title].nil? ? 'Anonymous' : control[:id]
|
837
|
+
xml.testcase(name: result[:code_desc], class: test_class, time: result[:run_time]) do
|
838
|
+
if result[:status] == 'failed'
|
839
|
+
xml.failure(message: result[:message])
|
840
|
+
elsif result[:status] == 'skipped'
|
841
|
+
xml.skipped
|
842
|
+
end
|
843
|
+
end
|
844
|
+
end
|
845
|
+
|
846
|
+
def count_profile_tests(profile)
|
847
|
+
profile[:controls].reduce(0) { |acc, elem|
|
848
|
+
acc + (elem[:results].nil? ? 0 : elem[:results].count)
|
849
|
+
}
|
850
|
+
end
|
851
|
+
|
852
|
+
def count_profile_failed_tests(profile)
|
853
|
+
profile[:controls].reduce(0) { |acc, elem|
|
854
|
+
if elem[:results].nil?
|
855
|
+
acc
|
856
|
+
else
|
857
|
+
acc + elem[:results].reduce(0) { |fail_test_total, test_case|
|
858
|
+
test_case[:status] == 'failed' ? fail_test_total + 1 : fail_test_total
|
859
|
+
}
|
860
|
+
end
|
861
|
+
}
|
802
862
|
end
|
803
863
|
end
|
data/lib/inspec/version.rb
CHANGED
data/lib/resources/file.rb
CHANGED
@@ -19,7 +19,7 @@ module Inspec::Resources
|
|
19
19
|
|
20
20
|
class FileResource < Inspec.resource(1)
|
21
21
|
include FilePermissionsSelector
|
22
|
-
include
|
22
|
+
include LinuxMountParser
|
23
23
|
|
24
24
|
name 'file'
|
25
25
|
desc 'Use the file InSpec audit resource to test all system file types, including files, directories, symbolic links, named pipes, sockets, character devices, block devices, and doors.'
|
@@ -21,10 +21,11 @@ module Inspec::Resources
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def loaded?
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
if inspec.os.redhat? || inspec.os.name == 'fedora'
|
25
|
+
lsmod_cmd = '/sbin/lsmod'
|
26
|
+
else
|
27
|
+
lsmod_cmd = 'lsmod'
|
28
|
+
end
|
28
29
|
|
29
30
|
# get list of all modules
|
30
31
|
cmd = inspec.command(lsmod_cmd)
|
@@ -37,7 +38,7 @@ module Inspec::Resources
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def version
|
40
|
-
if inspec.os
|
41
|
+
if inspec.os.redhat? || inspec.os.name == 'fedora'
|
41
42
|
modinfo_cmd = "/sbin/modinfo -F version #{@module}"
|
42
43
|
else
|
43
44
|
modinfo_cmd = "modinfo -F version #{@module}"
|
data/lib/resources/mount.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# author: Christoph Hartmann
|
3
3
|
# author: Dominik Richter
|
4
|
+
# author: Joseph Benden
|
4
5
|
|
5
6
|
require 'utils/simpleconfig'
|
6
7
|
|
@@ -18,13 +19,12 @@ module Inspec::Resources
|
|
18
19
|
its('options') { should include 'nodev' }
|
19
20
|
end
|
20
21
|
"
|
21
|
-
include MountParser
|
22
|
-
|
23
22
|
attr_reader :file
|
24
23
|
|
25
24
|
def initialize(path)
|
26
25
|
@path = path
|
27
|
-
|
26
|
+
@mount_manager = mount_manager_for_os
|
27
|
+
return skip_resource 'The `mount` resource is not supported on your OS yet.' if @mount_manager.nil?
|
28
28
|
@file = inspec.backend.file(@path)
|
29
29
|
end
|
30
30
|
|
@@ -49,12 +49,42 @@ module Inspec::Resources
|
|
49
49
|
line = mounted.stdout.lines.to_a.last if mounted.stdout.lines.count > 1
|
50
50
|
|
51
51
|
# parse content if we are on linux
|
52
|
-
@mount_options ||= parse_mount_options(line)
|
52
|
+
@mount_options ||= @mount_manager.parse_mount_options(line)
|
53
53
|
@mount_options[name]
|
54
54
|
end
|
55
55
|
|
56
56
|
def to_s
|
57
57
|
"Mount #{@path}"
|
58
58
|
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def mount_manager_for_os
|
63
|
+
os = inspec.os
|
64
|
+
if os.linux?
|
65
|
+
LinuxMounts.new(inspec)
|
66
|
+
elsif ['freebsd'].include?(os[:family])
|
67
|
+
BsdMounts.new(inspec)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class MountsInfo
|
73
|
+
attr_reader :inspec
|
74
|
+
def initialize(inspec)
|
75
|
+
@inspec = inspec
|
76
|
+
end
|
77
|
+
|
78
|
+
def parse_mount_options(_mount_line, _compatibility = false)
|
79
|
+
raise NotImplementedError
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class LinuxMounts < MountsInfo
|
84
|
+
include LinuxMountParser
|
85
|
+
end
|
86
|
+
|
87
|
+
class BsdMounts < MountsInfo
|
88
|
+
include BsdMountParser
|
59
89
|
end
|
60
90
|
end
|
data/lib/resources/service.rb
CHANGED
@@ -134,9 +134,9 @@ module Inspec::Resources
|
|
134
134
|
else
|
135
135
|
SysV.new(inspec, service_ctl || '/usr/sbin/service')
|
136
136
|
end
|
137
|
-
elsif %w{redhat fedora centos}.include?(platform)
|
137
|
+
elsif %w{redhat fedora centos oracle}.include?(platform)
|
138
138
|
version = os[:release].to_i
|
139
|
-
if (%w{ redhat centos }.include?(platform) && version >= 7) || (platform == 'fedora' && version >= 15)
|
139
|
+
if (%w{ redhat centos oracle }.include?(platform) && version >= 7) || (platform == 'fedora' && version >= 15)
|
140
140
|
Systemd.new(inspec, service_ctl)
|
141
141
|
else
|
142
142
|
SysV.new(inspec, service_ctl || '/sbin/service')
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Joseph Benden
|
3
|
+
|
4
|
+
module Inspec::Resources
|
5
|
+
class ZfsDataset < Inspec.resource(1)
|
6
|
+
name 'zfs_dataset'
|
7
|
+
desc "
|
8
|
+
Use the zfs_dataset InSpec audit resource to test if the named
|
9
|
+
ZFS Dataset is present and/or has certain properties.
|
10
|
+
"
|
11
|
+
example "
|
12
|
+
describe zfs_dataset('tank/tmp') do
|
13
|
+
its('exec') { should eq('off') }
|
14
|
+
its('setuid') { should eq('off') }
|
15
|
+
end
|
16
|
+
"
|
17
|
+
|
18
|
+
def initialize(zfs_dataset)
|
19
|
+
return skip_resource 'The `zfs_dataset` resource is not supported on your OS yet.' if !inspec.os.bsd?
|
20
|
+
@zfs_dataset = zfs_dataset
|
21
|
+
|
22
|
+
@params = gather
|
23
|
+
end
|
24
|
+
|
25
|
+
# method called by 'it { should exist }'
|
26
|
+
def exists?
|
27
|
+
inspec.command("/sbin/zfs get -Hp all #{@zfs_dataset}").exit_status == 0
|
28
|
+
end
|
29
|
+
|
30
|
+
def mounted?
|
31
|
+
return false if !exists?
|
32
|
+
inspec.mount(@params['mountpoint']).mounted?
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
"ZFS Dataset #{@zfs_dataset}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def gather
|
40
|
+
cmd = inspec.command("/sbin/zfs get -Hp all #{@zfs_dataset}")
|
41
|
+
return nil if cmd.exit_status.to_i != 0
|
42
|
+
|
43
|
+
# parse data
|
44
|
+
cmd.stdout.chomp.split("\n").each_with_object(Hash.new(0)) do |line, h|
|
45
|
+
t = line.split("\t")
|
46
|
+
h[t[1].to_s] = t[2].to_s
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# override method
|
51
|
+
def exec
|
52
|
+
@params['exec']
|
53
|
+
end
|
54
|
+
|
55
|
+
# expose all parameters
|
56
|
+
def method_missing(name)
|
57
|
+
@params[name.to_s]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Joseph Benden
|
3
|
+
|
4
|
+
module Inspec::Resources
|
5
|
+
class ZfsPool < Inspec.resource(1)
|
6
|
+
name 'zfs_pool'
|
7
|
+
desc "
|
8
|
+
Use the zfs_pool InSpec audit resource to test if the named
|
9
|
+
ZFS Pool is present and/or has certain properties.
|
10
|
+
"
|
11
|
+
example "
|
12
|
+
describe zfs_pool('tank') do
|
13
|
+
its('failmode') { should eq('continue') }
|
14
|
+
end
|
15
|
+
"
|
16
|
+
|
17
|
+
def initialize(zfs_pool)
|
18
|
+
return skip_resource 'The `zfs_pool` resource is not supported on your OS yet.' if !inspec.os.bsd?
|
19
|
+
@zfs_pool = zfs_pool
|
20
|
+
|
21
|
+
@params = gather
|
22
|
+
end
|
23
|
+
|
24
|
+
# method called by 'it { should exist }'
|
25
|
+
def exists?
|
26
|
+
inspec.command("/sbin/zpool get -Hp all #{@zfs_pool}").exit_status == 0
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
"ZFS Pool #{@zfs_pool}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def gather
|
34
|
+
cmd = inspec.command("/sbin/zpool get -Hp all #{@zfs_pool}")
|
35
|
+
return nil if cmd.exit_status.to_i != 0
|
36
|
+
|
37
|
+
# parse data
|
38
|
+
cmd.stdout.chomp.split("\n").each_with_object(Hash.new(0)) do |line, h|
|
39
|
+
t = line.split("\t")
|
40
|
+
h[t[1].to_s] = t[2].to_s
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# expose all parameters
|
45
|
+
def method_missing(name)
|
46
|
+
@params[name.to_s]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/utils/parser.rb
CHANGED
@@ -63,7 +63,7 @@ module CommentParser
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
module
|
66
|
+
module LinuxMountParser
|
67
67
|
# this parses the output of mount command (only tested on linux)
|
68
68
|
# this method expects only one line of the mount output
|
69
69
|
def parse_mount_options(mount_line, compatibility = false)
|
@@ -94,6 +94,20 @@ module MountParser
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
+
module BsdMountParser
|
98
|
+
# this parses the output of mount command (only tested on freebsd)
|
99
|
+
# this method expects only one line of the mount output
|
100
|
+
def parse_mount_options(mount_line, _compatibility = false)
|
101
|
+
return {} if mount_line.nil? || mount_line.empty?
|
102
|
+
|
103
|
+
mount = mount_line.chomp.split(' ', 4)
|
104
|
+
options = mount[3].tr('()', '').split(', ')
|
105
|
+
|
106
|
+
# parse device and type
|
107
|
+
{ device: mount[0], type: options.shift, options: options }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
97
111
|
module SolarisNetstatParser
|
98
112
|
# takes this as a input and parses the values
|
99
113
|
# UDP: IPv4
|
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: 1.
|
4
|
+
version: 1.16.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: 2017-02
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: train
|
@@ -346,6 +346,8 @@ files:
|
|
346
346
|
- docs/resources/xinetd_conf.md.erb
|
347
347
|
- docs/resources/yaml.md.erb
|
348
348
|
- docs/resources/yum.md.erb
|
349
|
+
- docs/resources/zfs_dataset.md.erb
|
350
|
+
- docs/resources/zfs_pool.md.erb
|
349
351
|
- docs/ruby_usage.md
|
350
352
|
- docs/shared/matcher_be.md.erb
|
351
353
|
- docs/shared/matcher_cmp.md.erb
|
@@ -384,7 +386,7 @@ files:
|
|
384
386
|
- examples/meta-profile/controls/example.rb
|
385
387
|
- examples/meta-profile/inspec.lock
|
386
388
|
- examples/meta-profile/inspec.yml
|
387
|
-
- examples/meta-profile/vendor/
|
389
|
+
- examples/meta-profile/vendor/6bdab40a3fe9f9de4e7c87f4f3844fdcf2c5cba6f84089b68d47c72392b51fdc.tar.gz
|
388
390
|
- examples/meta-profile/vendor/9ad48391d4e6efff0a13d06736c5b075fb021410e0a629e087bc21e9617d957c.tar.gz
|
389
391
|
- examples/meta-profile/vendor/e25d521fb1093b4c23b31a7dc8f41b5540236f4a433960b151bc427523662ab6.tar.gz
|
390
392
|
- examples/profile-attribute.yml
|
@@ -558,6 +560,8 @@ files:
|
|
558
560
|
- lib/resources/xinetd.rb
|
559
561
|
- lib/resources/yaml.rb
|
560
562
|
- lib/resources/yum.rb
|
563
|
+
- lib/resources/zfs_dataset.rb
|
564
|
+
- lib/resources/zfs_pool.rb
|
561
565
|
- lib/source_readers/flat.rb
|
562
566
|
- lib/source_readers/inspec.rb
|
563
567
|
- lib/utils/command_wrapper.rb
|