inspec 3.9.0 → 3.9.3
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/lib/inspec.rb +1 -0
- data/lib/inspec/base_cli.rb +3 -1
- data/lib/inspec/objects/input.rb +2 -2
- data/lib/inspec/runner.rb +6 -2
- data/lib/inspec/utils/telemetry.rb +3 -0
- data/lib/inspec/utils/telemetry/collector.rb +60 -0
- data/lib/inspec/utils/telemetry/data_series.rb +42 -0
- data/lib/inspec/utils/telemetry/global_methods.rb +21 -0
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/crontab.rb +7 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6acb1580248137e250e50e82452ca06ffbb270db5f166c206050ae8d2ce0f046
|
4
|
+
data.tar.gz: e6c0db990f81559518f2f39b1d9a3bafb4455ff6fa25f478c94488d1c5e3b620
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d379f6e0f71d1c79ced4577c381d75e0e3005c52652dc59e68486ddc20dad952067d9960187088db6713e23e81d5c226b7b1da43ff81835f6d22f23925db42b2
|
7
|
+
data.tar.gz: 0bdefe99c446850501e474c8391fe370266038440e866b3f6d96ddea41b8e07af9668b206452d019af678f0a7ef8e9aefe71f28536990d7755dba66b55c86709
|
data/lib/inspec.rb
CHANGED
data/lib/inspec/base_cli.rb
CHANGED
@@ -107,8 +107,10 @@ module Inspec
|
|
107
107
|
option :reporter, type: :array,
|
108
108
|
banner: 'one two:/output/file/path',
|
109
109
|
desc: 'Enable one or more output reporters: cli, documentation, html, progress, json, json-min, json-rspec, junit, yaml'
|
110
|
-
option :
|
110
|
+
option :input_file, type: :array,
|
111
111
|
desc: 'Load one or more input files, a YAML file with values for the profile to use'
|
112
|
+
option :attrs, type: :array,
|
113
|
+
desc: 'Legacy name for --input-file - deprecated.'
|
112
114
|
option :create_lockfile, type: :boolean,
|
113
115
|
desc: 'Write out a lockfile based on this execution (unless one already exists)'
|
114
116
|
option :backend_cache, type: :boolean,
|
data/lib/inspec/objects/input.rb
CHANGED
@@ -23,8 +23,8 @@ module Inspec
|
|
23
23
|
|
24
24
|
# output warn message if we are in a exec call
|
25
25
|
Inspec::Log.warn(
|
26
|
-
"
|
27
|
-
"Use --
|
26
|
+
"Input '#{@name}' does not have a value. "\
|
27
|
+
"Use --input-file to provide a value for '#{@name}' or specify a "\
|
28
28
|
"value with `attribute('#{@name}', value: 'somevalue', ...)`.",
|
29
29
|
) if Inspec::BaseCLI.inspec_cli_command == :exec
|
30
30
|
end
|
data/lib/inspec/runner.rb
CHANGED
@@ -151,10 +151,14 @@ module Inspec
|
|
151
151
|
|
152
152
|
# determine all inputs before the execution, fetch data from secrets backend
|
153
153
|
def load_inputs(options)
|
154
|
-
# TODO: - rename :attributes
|
154
|
+
# TODO: - rename :attributes - it is user-visible
|
155
155
|
options[:attributes] ||= {}
|
156
156
|
|
157
|
-
|
157
|
+
if options.key?(:attrs)
|
158
|
+
Inspec.deprecate(:rename_attributes_to_inputs, 'Use --input-file on the command line instead of --attrs.')
|
159
|
+
options[:input_file] = options.delete(:attrs)
|
160
|
+
end
|
161
|
+
secrets_targets = options[:input_file]
|
158
162
|
return options[:attributes] if secrets_targets.nil?
|
159
163
|
|
160
164
|
secrets_targets.each do |target|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'inspec/utils/telemetry/data_series'
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
module Inspec::Telemetry
|
5
|
+
# A Singleton collection of data series objects.
|
6
|
+
class Collector
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@data_series = []
|
11
|
+
@enabled = true
|
12
|
+
end
|
13
|
+
|
14
|
+
# Add a data series to the collection.
|
15
|
+
# @return [True]
|
16
|
+
def add_data_series(data_series)
|
17
|
+
@data_series << data_series
|
18
|
+
end
|
19
|
+
|
20
|
+
# Is the Telemetry system enabled or disabled?
|
21
|
+
# Always true until we add configuration parsing.
|
22
|
+
# @return [True, False]
|
23
|
+
def telemetry_enabled?
|
24
|
+
@enabled
|
25
|
+
end
|
26
|
+
|
27
|
+
# A way to disable the telemetry system.
|
28
|
+
# @return [True]
|
29
|
+
def disable_telemetry
|
30
|
+
@enabled = false
|
31
|
+
end
|
32
|
+
|
33
|
+
# The entire data series collection.
|
34
|
+
# @return [Array]
|
35
|
+
def list_data_series
|
36
|
+
@data_series
|
37
|
+
end
|
38
|
+
|
39
|
+
# Finds the data series object with the specified name and returns it.
|
40
|
+
# If it does not exist then creates a new data series with that name
|
41
|
+
# and returns it.
|
42
|
+
# @return [Inspec::Telemetry::DataSeries]
|
43
|
+
def find_or_create_data_series(name)
|
44
|
+
ds = @data_series.select { |data_series| data_series.name.eql?(name) }
|
45
|
+
if ds.empty?
|
46
|
+
new_data_series = Inspec::Telemetry::DataSeries.new(name)
|
47
|
+
@data_series << new_data_series
|
48
|
+
new_data_series
|
49
|
+
else
|
50
|
+
ds.first
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Blanks the contents of the data series collection.
|
55
|
+
# @return [True]
|
56
|
+
def reset
|
57
|
+
@data_series = []
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
# A minimal Dataseries Object
|
4
|
+
# Stores the name of the data series and an array of data.
|
5
|
+
# Stored data should be a object that supports #to_s
|
6
|
+
module Inspec::Telemetry
|
7
|
+
class DataSeries
|
8
|
+
def initialize(name)
|
9
|
+
@name = name
|
10
|
+
@enabled = true
|
11
|
+
@data ||= []
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :data, :name
|
15
|
+
|
16
|
+
# This needs to also be set by configuration.
|
17
|
+
def enabled?
|
18
|
+
@enabled
|
19
|
+
end
|
20
|
+
|
21
|
+
def disable
|
22
|
+
@enabled = false
|
23
|
+
end
|
24
|
+
|
25
|
+
def <<(appending_data)
|
26
|
+
data << appending_data
|
27
|
+
end
|
28
|
+
|
29
|
+
alias push <<
|
30
|
+
|
31
|
+
def to_h
|
32
|
+
{
|
33
|
+
name: @name,
|
34
|
+
data: @data,
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_json
|
39
|
+
to_h.to_json
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'inspec/utils/telemetry'
|
2
|
+
|
3
|
+
module Inspec
|
4
|
+
# A Global method to add a data series object to the Telemetry Collection.
|
5
|
+
# `data_series_name`s are unique, so `:dependency_group` will always return
|
6
|
+
# the same object.
|
7
|
+
# `data_point` is optional, you may also supply a block with several data points.
|
8
|
+
# All data points should allow #to_s
|
9
|
+
def self.record_telemetry_data(data_series_name, data_point = nil)
|
10
|
+
coll = Inspec::Telemetry::Collector.instance
|
11
|
+
return unless coll.telemetry_enabled?
|
12
|
+
ds = coll.find_or_create_data_series(data_series_name)
|
13
|
+
return unless ds.enabled?
|
14
|
+
|
15
|
+
if block_given?
|
16
|
+
ds << yield
|
17
|
+
else
|
18
|
+
ds << data_point
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/inspec/version.rb
CHANGED
data/lib/resources/crontab.rb
CHANGED
@@ -41,6 +41,7 @@ module Inspec::Resources
|
|
41
41
|
@user = opts.fetch(:user, nil)
|
42
42
|
@path = opts.fetch(:path, nil)
|
43
43
|
raise Inspec::Exceptions::ResourceFailed, 'A user or path must be supplied.' if @user.nil? && @path.nil?
|
44
|
+
raise Inspec::Exceptions::ResourceFailed, 'Either user or path must be supplied, not both!' if !@user.nil? && !@path.nil?
|
44
45
|
else
|
45
46
|
@user = opts
|
46
47
|
@path = nil
|
@@ -49,7 +50,12 @@ module Inspec::Resources
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def read_crontab
|
52
|
-
|
53
|
+
if is_system_crontab?
|
54
|
+
raise Inspec::Exceptions::ResourceFailed, "Supplied crontab path '#{@path}' must exist!" if !inspec.file(@path).exist?
|
55
|
+
ct = inspec.file(@path).content
|
56
|
+
else
|
57
|
+
ct = inspec.command(crontab_cmd).stdout
|
58
|
+
end
|
53
59
|
ct.lines.map { |l| parse_crontab_line(l) }.compact
|
54
60
|
end
|
55
61
|
|
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: 3.9.
|
4
|
+
version: 3.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: train
|
@@ -493,6 +493,10 @@ files:
|
|
493
493
|
- lib/inspec/shell_detector.rb
|
494
494
|
- lib/inspec/source_reader.rb
|
495
495
|
- lib/inspec/ui.rb
|
496
|
+
- lib/inspec/utils/telemetry.rb
|
497
|
+
- lib/inspec/utils/telemetry/collector.rb
|
498
|
+
- lib/inspec/utils/telemetry/data_series.rb
|
499
|
+
- lib/inspec/utils/telemetry/global_methods.rb
|
496
500
|
- lib/inspec/version.rb
|
497
501
|
- lib/matchers/matchers.rb
|
498
502
|
- lib/plugins/README.md
|