inspec 1.13.0 → 1.14.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 +20 -2
- data/Gemfile +1 -1
- data/examples/meta-profile/inspec.lock +18 -0
- data/examples/meta-profile/vendor/3d473e72d8b70018386a53e0a105e92ccbb4115dc268cadc16ff53d550d2898e.tar.gz +0 -0
- data/examples/meta-profile/vendor/793adcbb91cfc2da0044bb9cbf0863773ae2cf89ce9b8343b4295b137f70897b.tar.gz +0 -0
- data/examples/meta-profile/vendor/e25d521fb1093b4c23b31a7dc8f41b5540236f4a433960b151bc427523662ab6.tar.gz +0 -0
- data/lib/bundles/inspec-artifact/cli.rb +6 -6
- data/lib/bundles/inspec-compliance/http.rb +11 -3
- data/lib/bundles/inspec-compliance/target.rb +2 -2
- data/lib/bundles/inspec-supermarket/cli.rb +1 -1
- data/lib/fetchers/git.rb +1 -1
- data/lib/inspec/backend.rb +2 -2
- data/lib/inspec/base_cli.rb +1 -1
- data/lib/inspec/cached_fetcher.rb +2 -2
- data/lib/inspec/cli.rb +1 -0
- data/lib/inspec/control_eval_context.rb +0 -2
- data/lib/inspec/dependencies/lockfile.rb +6 -4
- data/lib/inspec/dependencies/requirement.rb +1 -1
- data/lib/inspec/dependencies/resolver.rb +4 -4
- data/lib/inspec/dsl.rb +2 -2
- data/lib/inspec/fetcher.rb +1 -1
- data/lib/inspec/file_provider.rb +4 -4
- data/lib/inspec/library_eval_context.rb +1 -1
- data/lib/inspec/objects/list.rb +1 -1
- data/lib/inspec/plugins.rb +1 -1
- data/lib/inspec/plugins/fetcher.rb +4 -4
- data/lib/inspec/plugins/resource.rb +0 -1
- data/lib/inspec/plugins/source_reader.rb +3 -3
- data/lib/inspec/profile.rb +4 -4
- data/lib/inspec/profile_context.rb +1 -1
- data/lib/inspec/resource.rb +2 -2
- data/lib/inspec/runner.rb +4 -4
- data/lib/inspec/secrets.rb +1 -1
- data/lib/inspec/shell.rb +1 -1
- data/lib/inspec/source_reader.rb +1 -1
- data/lib/inspec/version.rb +1 -1
- data/lib/matchers/matchers.rb +7 -7
- data/lib/resources/apache_conf.rb +1 -1
- data/lib/resources/auditd_conf.rb +1 -1
- data/lib/resources/auditd_rules.rb +1 -1
- data/lib/resources/bridge.rb +1 -1
- data/lib/resources/etc_group.rb +2 -2
- data/lib/resources/file.rb +6 -6
- data/lib/resources/groups.rb +4 -4
- data/lib/resources/grub_conf.rb +3 -3
- data/lib/resources/host.rb +1 -1
- data/lib/resources/inetd_conf.rb +1 -1
- data/lib/resources/interface.rb +1 -1
- data/lib/resources/json.rb +1 -1
- data/lib/resources/limits_conf.rb +1 -1
- data/lib/resources/login_def.rb +1 -1
- data/lib/resources/mysql_conf.rb +1 -1
- data/lib/resources/ntp_conf.rb +1 -1
- data/lib/resources/packages.rb +2 -2
- data/lib/resources/parse_config.rb +1 -1
- data/lib/resources/port.rb +2 -2
- data/lib/resources/postgres_conf.rb +1 -1
- data/lib/resources/security_policy.rb +1 -1
- data/lib/resources/ssh_conf.rb +1 -1
- data/lib/resources/ssl.rb +1 -1
- data/lib/resources/users.rb +5 -5
- data/lib/resources/xinetd.rb +1 -1
- data/lib/utils/command_wrapper.rb +3 -3
- data/lib/utils/filter.rb +1 -1
- data/lib/utils/plugin_registry.rb +3 -3
- data/lib/utils/simpleconfig.rb +1 -1
- metadata +6 -2
@@ -15,7 +15,7 @@ module Inspec
|
|
15
15
|
#
|
16
16
|
# @return [Inspec::Metadata] profile metadata
|
17
17
|
def metadata
|
18
|
-
|
18
|
+
raise "SourceReader #{self} does not implement `metadata()`. This method is required"
|
19
19
|
end
|
20
20
|
|
21
21
|
# Retrieve this profile's tests
|
@@ -26,14 +26,14 @@ module Inspec
|
|
26
26
|
#
|
27
27
|
# @return [Hash] Collection with references pointing to test contents
|
28
28
|
def tests
|
29
|
-
|
29
|
+
raise "SourceReader #{self} does not implement `tests()`. This method is required"
|
30
30
|
end
|
31
31
|
|
32
32
|
# Retrieve this profile's libraries
|
33
33
|
#
|
34
34
|
# @return [Hash] Collection with references pointing to library contents
|
35
35
|
def libraries
|
36
|
-
|
36
|
+
raise "SourceReader #{self} does not implement `libraries()`. This method is required"
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/inspec/profile.rb
CHANGED
@@ -57,7 +57,7 @@ module Inspec
|
|
57
57
|
|
58
58
|
reader = Inspec::SourceReader.resolve(rp)
|
59
59
|
if reader.nil?
|
60
|
-
|
60
|
+
raise("Don't understand inspec profile in #{path}, it " \
|
61
61
|
"doesn't look like a supported profile structure.")
|
62
62
|
end
|
63
63
|
new(reader, opts)
|
@@ -108,7 +108,7 @@ module Inspec
|
|
108
108
|
metadata.params[:version]
|
109
109
|
end
|
110
110
|
|
111
|
-
def writable?
|
111
|
+
def writable?
|
112
112
|
@writable
|
113
113
|
end
|
114
114
|
|
@@ -397,10 +397,10 @@ module Inspec
|
|
397
397
|
end
|
398
398
|
|
399
399
|
name = params[:name] ||
|
400
|
-
|
400
|
+
raise('Cannot create an archive without a profile name! Please '\
|
401
401
|
'specify the name in metadata or use --output to create the archive.')
|
402
402
|
version = params[:version] ||
|
403
|
-
|
403
|
+
raise('Cannot create an archive without a profile version! Please '\
|
404
404
|
'specify the version in metadata or use --output to create the archive.')
|
405
405
|
ext = opts[:zip] ? 'zip' : 'tar.gz'
|
406
406
|
slug = name.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '_')
|
@@ -21,7 +21,7 @@ module Inspec
|
|
21
21
|
attr_accessor :rules
|
22
22
|
def initialize(profile_id, backend, conf)
|
23
23
|
if backend.nil?
|
24
|
-
|
24
|
+
raise 'ProfileContext is initiated with a backend == nil. ' \
|
25
25
|
'This is a backend error which must be fixed upstream.'
|
26
26
|
end
|
27
27
|
@profile_id = profile_id
|
data/lib/inspec/resource.rb
CHANGED
@@ -39,7 +39,7 @@ module Inspec
|
|
39
39
|
profile_context.subcontext_by_name(profile_name)
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
raise ProfileNotFound, "Cannot find profile named: #{profile_name}" if inner_context.nil?
|
43
43
|
inner_context.resource_registry[resource_name]
|
44
44
|
end
|
45
45
|
|
@@ -64,7 +64,7 @@ module Inspec
|
|
64
64
|
|
65
65
|
def self.validate_resource_dsl_version!(version)
|
66
66
|
if version != 1
|
67
|
-
|
67
|
+
raise 'Only resource version 1 is supported!'
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
data/lib/inspec/runner.rb
CHANGED
@@ -166,7 +166,7 @@ module Inspec
|
|
166
166
|
backend: @backend,
|
167
167
|
controls: @controls,
|
168
168
|
attributes: @conf[:attributes])
|
169
|
-
|
169
|
+
raise "Could not resolve #{target} to valid input." if profile.nil?
|
170
170
|
@target_profiles << profile if supports_profile?(profile)
|
171
171
|
end
|
172
172
|
|
@@ -174,13 +174,13 @@ module Inspec
|
|
174
174
|
return true if @ignore_supports
|
175
175
|
|
176
176
|
if !profile.supports_runtime?
|
177
|
-
|
177
|
+
raise 'This profile requires InSpec version '\
|
178
178
|
"#{profile.metadata.inspec_requirement}. You are running "\
|
179
179
|
"InSpec v#{Inspec::VERSION}.\n"
|
180
180
|
end
|
181
181
|
|
182
182
|
if !profile.supports_os?
|
183
|
-
|
183
|
+
raise "This OS/platform (#{@backend.os[:name]}) is not supported by this profile."
|
184
184
|
end
|
185
185
|
|
186
186
|
true
|
@@ -249,7 +249,7 @@ module Inspec
|
|
249
249
|
# otherwise return all working tests
|
250
250
|
return ok_tests
|
251
251
|
else
|
252
|
-
|
252
|
+
raise "A rule was registered with #{method_name.inspect}, "\
|
253
253
|
"which isn't understood and cannot be processed."
|
254
254
|
end
|
255
255
|
end
|
data/lib/inspec/secrets.rb
CHANGED
data/lib/inspec/shell.rb
CHANGED
@@ -79,7 +79,7 @@ module Inspec
|
|
79
79
|
# determine min whitespace that can be removed
|
80
80
|
min = nil
|
81
81
|
example.lines.each do |line|
|
82
|
-
if line.strip.
|
82
|
+
if !line.strip.empty? # ignore empty lines
|
83
83
|
line_whitespace = line.length - line.lstrip.length
|
84
84
|
min = line_whitespace if min.nil? || line_whitespace < min
|
85
85
|
end
|
data/lib/inspec/source_reader.rb
CHANGED
data/lib/inspec/version.rb
CHANGED
data/lib/matchers/matchers.rb
CHANGED
@@ -105,7 +105,7 @@ RSpec::Matchers.define :be_installed do
|
|
105
105
|
end
|
106
106
|
|
107
107
|
chain :by do
|
108
|
-
|
108
|
+
raise "[UNSUPPORTED] Please use the new resources 'gem', 'npm' or 'pip'."
|
109
109
|
end
|
110
110
|
|
111
111
|
chain :with_version do |version|
|
@@ -121,7 +121,7 @@ RSpec::Matchers.define :be_enabled do
|
|
121
121
|
end
|
122
122
|
|
123
123
|
chain :with_level do |_level|
|
124
|
-
|
124
|
+
raise '[UNSUPPORTED] with level is not supported'
|
125
125
|
end
|
126
126
|
|
127
127
|
failure_message do |service|
|
@@ -137,7 +137,7 @@ RSpec::Matchers.define :be_running do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
chain :under do |_under|
|
140
|
-
|
140
|
+
raise '[UNSUPPORTED] under is not supported'
|
141
141
|
end
|
142
142
|
|
143
143
|
failure_message do |service|
|
@@ -178,7 +178,7 @@ RSpec::Matchers.define :be_reachable do
|
|
178
178
|
end
|
179
179
|
|
180
180
|
chain :with do |_attr|
|
181
|
-
|
181
|
+
raise '[UNSUPPORTED] `with` is not supported in combination with `be_reachable`'
|
182
182
|
end
|
183
183
|
|
184
184
|
failure_message do |host|
|
@@ -193,7 +193,7 @@ RSpec::Matchers.define :be_resolvable do
|
|
193
193
|
end
|
194
194
|
|
195
195
|
chain :by do |_type|
|
196
|
-
|
196
|
+
raise "[UNSUPPORTED] `by` is not supported in combination with `be_resolvable`. Please use the following syntax `host('example.com', port: 53, proto: 'udp')`."
|
197
197
|
end
|
198
198
|
|
199
199
|
failure_message do |host|
|
@@ -208,11 +208,11 @@ RSpec::Matchers.define :have_rule do |rule|
|
|
208
208
|
end
|
209
209
|
|
210
210
|
chain :with_table do |_table|
|
211
|
-
|
211
|
+
raise "[UNSUPPORTED] `with_table` is not supported in combination with `have_rule`. Please use the following syntax `iptables(table:'mangle', chain: 'input')`."
|
212
212
|
end
|
213
213
|
|
214
214
|
chain :with_chain do |_chain|
|
215
|
-
|
215
|
+
raise "[UNSUPPORTED] `with_table` is not supported in combination with `with_chain`. Please use the following syntax `iptables(table:'mangle', chain: 'input')`."
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
@@ -93,7 +93,7 @@ module Inspec::Resources
|
|
93
93
|
# rubocop:disable Style/MethodName
|
94
94
|
def LIST_RULES
|
95
95
|
return @legacy.LIST_RULES if @legacy
|
96
|
-
|
96
|
+
raise 'Using legacy auditd_rules LIST_RULES interface with non-legacy audit package. Please use the new syntax.'
|
97
97
|
end
|
98
98
|
|
99
99
|
def status(name = nil)
|
data/lib/resources/bridge.rb
CHANGED
@@ -115,7 +115,7 @@ module Inspec::Resources
|
|
115
115
|
adapter_collection.push(info) if info[:name].casecmp(bridge_name) == 0
|
116
116
|
end
|
117
117
|
|
118
|
-
return nil if bridges.
|
118
|
+
return nil if bridges.empty?
|
119
119
|
warn "[Possible Error] detected multiple bridges interfaces with the name #{bridge_name}" if bridges.size > 1
|
120
120
|
bridges[0]
|
121
121
|
end
|
data/lib/resources/etc_group.rb
CHANGED
@@ -107,7 +107,7 @@ module Inspec::Resources
|
|
107
107
|
# iterate over each line and filter comments
|
108
108
|
@content.split("\n").each_with_object([]) do |line, lines|
|
109
109
|
grp_info = parse_group_line(line)
|
110
|
-
lines.push(grp_info) if !grp_info.nil? && grp_info.
|
110
|
+
lines.push(grp_info) if !grp_info.nil? && !grp_info.empty?
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -119,7 +119,7 @@ module Inspec::Resources
|
|
119
119
|
line, _idx_nl = parse_comment_line(line, opts)
|
120
120
|
x = line.split(':')
|
121
121
|
# abort if we have an empty or comment line
|
122
|
-
return nil if x.
|
122
|
+
return nil if x.empty?
|
123
123
|
# map data
|
124
124
|
{
|
125
125
|
'name' => x.at(0), # Name of the group.
|
data/lib/resources/file.rb
CHANGED
@@ -61,7 +61,7 @@ module Inspec::Resources
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def contain(*_)
|
64
|
-
|
64
|
+
raise 'Contain is not supported. Please use standard RSpec matchers.'
|
65
65
|
end
|
66
66
|
|
67
67
|
def readable?(by_usergroup, by_specific_user)
|
@@ -128,7 +128,7 @@ module Inspec::Resources
|
|
128
128
|
private
|
129
129
|
|
130
130
|
def file_permission_granted?(access_type, by_usergroup, by_specific_user)
|
131
|
-
|
131
|
+
raise '`file_permission_granted?` is not supported on your OS' if @perms_provider.nil?
|
132
132
|
if by_specific_user.nil? || by_specific_user.empty?
|
133
133
|
@perms_provider.check_file_permission_by_mask(file, access_type, by_usergroup, by_specific_user)
|
134
134
|
else
|
@@ -154,7 +154,7 @@ module Inspec::Resources
|
|
154
154
|
when 'execute'
|
155
155
|
'x'
|
156
156
|
else
|
157
|
-
|
157
|
+
raise 'Invalid access_type provided'
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
@@ -172,7 +172,7 @@ module Inspec::Resources
|
|
172
172
|
usergroup = usergroup_for(usergroup, specific_user)
|
173
173
|
flag = permission_flag(access_type)
|
174
174
|
mask = file.unix_mode_mask(usergroup, flag)
|
175
|
-
|
175
|
+
raise 'Invalid usergroup/owner provided' if mask.nil?
|
176
176
|
(file.mode & mask) != 0
|
177
177
|
end
|
178
178
|
|
@@ -197,7 +197,7 @@ module Inspec::Resources
|
|
197
197
|
|
198
198
|
class WindowsFilePermissions < FilePermissions
|
199
199
|
def check_file_permission_by_mask(_file, _access_type, _usergroup, _specific_user)
|
200
|
-
|
200
|
+
raise '`check_file_permission_by_mask` is not supported on Windows'
|
201
201
|
end
|
202
202
|
|
203
203
|
def check_file_permission_by_user(access_type, user, path)
|
@@ -209,7 +209,7 @@ module Inspec::Resources
|
|
209
209
|
when 'execute'
|
210
210
|
'@(\'FullControl\', \'Modify\', \'ReadAndExecute\', \'ExecuteFile\')'
|
211
211
|
else
|
212
|
-
|
212
|
+
raise 'Invalid access_type provided'
|
213
213
|
end
|
214
214
|
cmd = inspec.command("@(@((Get-Acl '#{path}').access | Where-Object {$_.AccessControlType -eq 'Allow' -and $_.IdentityReference -eq '#{user}' }) | Where-Object {($_.FileSystemRights.ToString().Split(',') | % {$_.trim()} | ? {#{access_rule} -contains $_}) -ne $null}) | measure | % { $_.Count }")
|
215
215
|
cmd.stdout.chomp == '0' ? false : true
|
data/lib/resources/groups.rb
CHANGED
@@ -99,18 +99,18 @@ module Inspec::Resources
|
|
99
99
|
|
100
100
|
# verifies if a group exists
|
101
101
|
def exists?
|
102
|
-
group_info.entries.
|
102
|
+
!group_info.entries.empty?
|
103
103
|
end
|
104
104
|
|
105
105
|
def gid
|
106
106
|
gids = group_info.gids
|
107
|
-
if gids.
|
107
|
+
if gids.empty?
|
108
108
|
nil
|
109
109
|
# the default case should be one group
|
110
110
|
elsif gids.size == 1
|
111
111
|
gids.entries[0]
|
112
112
|
else
|
113
|
-
|
113
|
+
raise 'found more than one group with the same name, please use `groups` resource'
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
@@ -144,7 +144,7 @@ module Inspec::Resources
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def groups
|
147
|
-
|
147
|
+
raise 'group provider must implement the `groups` method'
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
data/lib/resources/grub_conf.rb
CHANGED
@@ -38,11 +38,11 @@ class GrubConfig < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
|
38
38
|
@conf_path = path || '/boot/grub/grub.cfg'
|
39
39
|
@defaults_path = '/etc/default/grub'
|
40
40
|
@version = 'grub2'
|
41
|
-
elsif os[:name] == 'amazon'
|
41
|
+
elsif os[:name] == 'amazon'
|
42
42
|
@conf_path = path || '/etc/grub.conf'
|
43
43
|
@version = 'legacy'
|
44
44
|
else
|
45
|
-
|
45
|
+
raise UnknownGrubConfig
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -145,7 +145,7 @@ class GrubConfig < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
|
145
145
|
|
146
146
|
content = file.content
|
147
147
|
|
148
|
-
if content.empty? && file.
|
148
|
+
if content.empty? && !file.empty?
|
149
149
|
skip_resource "Can't read file '#{@conf_path}'"
|
150
150
|
return @params = {}
|
151
151
|
end
|
data/lib/resources/host.rb
CHANGED
@@ -60,7 +60,7 @@ module Inspec::Resources
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def reachable?(port = nil, proto = nil, timeout = nil)
|
63
|
-
|
63
|
+
raise "Use `host` resource with host('#{@hostname}', port: #{port}, proto: '#{proto}') parameters." if !port.nil? || !proto.nil? || !timeout.nil?
|
64
64
|
ping.nil? ? false : ping
|
65
65
|
end
|
66
66
|
|
data/lib/resources/inetd_conf.rb
CHANGED
data/lib/resources/interface.rb
CHANGED
@@ -121,7 +121,7 @@ module Inspec::Resources
|
|
121
121
|
adapter_collection.push(info) if info[:name].casecmp(iface) == 0
|
122
122
|
end
|
123
123
|
|
124
|
-
return nil if adapters.
|
124
|
+
return nil if adapters.empty?
|
125
125
|
warn "[Possible Error] detected multiple network interfaces with the name #{iface}" if adapters.size > 1
|
126
126
|
adapters[0]
|
127
127
|
end
|
data/lib/resources/json.rb
CHANGED
data/lib/resources/login_def.rb
CHANGED
data/lib/resources/mysql_conf.rb
CHANGED
@@ -73,7 +73,7 @@ module Inspec::Resources
|
|
73
73
|
return skip_resource "Can't find file \"#{@conf_path}\""
|
74
74
|
end
|
75
75
|
raw_conf = read_file(@conf_path)
|
76
|
-
if raw_conf.empty? && inspec.file(@conf_path).
|
76
|
+
if raw_conf.empty? && !inspec.file(@conf_path).empty?
|
77
77
|
return skip_resource("Can't read file \"#{@conf_path}\"")
|
78
78
|
end
|
79
79
|
|