inspec-core 6.6.0 → 6.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +22 -22
  3. data/etc/features.sig +6 -6
  4. data/etc/features.yaml +3 -0
  5. data/inspec-core.gemspec +10 -3
  6. data/lib/inspec/base_cli.rb +1 -1
  7. data/lib/inspec/cli.rb +1 -1
  8. data/lib/inspec/config.rb +9 -0
  9. data/lib/inspec/dependencies/dependency_set.rb +2 -2
  10. data/lib/inspec/dsl.rb +1 -1
  11. data/lib/inspec/feature/runner.rb +4 -1
  12. data/lib/inspec/feature.rb +8 -0
  13. data/lib/inspec/fetcher/url.rb +29 -7
  14. data/lib/inspec/iaf_file.rb +3 -2
  15. data/lib/inspec/input_registry.rb +5 -1
  16. data/lib/inspec/profile.rb +2 -2
  17. data/lib/inspec/reporters/cli.rb +1 -1
  18. data/lib/inspec/resources/nftables.rb +14 -1
  19. data/lib/inspec/resources/oracledb_session.rb +12 -3
  20. data/lib/inspec/resources/ssh_config.rb +100 -9
  21. data/lib/inspec/resources/ssh_key.rb +124 -0
  22. data/lib/inspec/resources/sshd_active_config.rb +2 -0
  23. data/lib/inspec/resources/sybase_session.rb +11 -2
  24. data/lib/inspec/resources/virtualization.rb +1 -1
  25. data/lib/inspec/resources.rb +1 -0
  26. data/lib/inspec/rule.rb +15 -10
  27. data/lib/inspec/runner.rb +10 -2
  28. data/lib/inspec/utils/profile_ast_helpers.rb +1 -2
  29. data/lib/inspec/utils/telemetry/base.rb +149 -0
  30. data/lib/inspec/utils/telemetry/http.rb +40 -0
  31. data/lib/inspec/utils/telemetry/null.rb +11 -0
  32. data/lib/inspec/utils/telemetry/run_context_probe.rb +13 -1
  33. data/lib/inspec/utils/telemetry.rb +74 -3
  34. data/lib/inspec/utils/waivers/csv_file_reader.rb +1 -1
  35. data/lib/inspec/utils/waivers/excel_file_reader.rb +1 -1
  36. data/lib/inspec/version.rb +1 -1
  37. data/lib/inspec.rb +0 -1
  38. data/lib/matchers/matchers.rb +3 -3
  39. data/lib/plugins/inspec-parallel/lib/inspec-parallel/runner.rb +5 -0
  40. data/lib/plugins/inspec-parallel/lib/inspec-parallel/super_reporter/status.rb +1 -0
  41. data/lib/plugins/inspec-sign/lib/inspec-sign/base.rb +14 -6
  42. metadata +27 -11
  43. data/lib/inspec/utils/telemetry/collector.rb +0 -81
  44. data/lib/inspec/utils/telemetry/data_series.rb +0 -44
  45. data/lib/inspec/utils/telemetry/global_methods.rb +0 -22
@@ -32,15 +32,22 @@ module InspecPlugins
32
32
  def self.keygen(options)
33
33
  key = KEY_ALG.new KEY_BITS
34
34
 
35
- path = File.join(Inspec.config_dir, "keys")
35
+ # config_dir is the directory where the keys will be stored.
36
+ # options["config_dir"] is passed explicitly only for testing purposes.
37
+ config_dir = options["config_dir"] || Inspec.config_dir
38
+ path = File.join(config_dir, "keys")
36
39
  FileUtils.mkdir_p(path)
37
40
 
38
41
  puts "Generating signing key in #{path}/#{options["keyname"]}.pem.key"
39
- open "#{path}/#{options["keyname"]}.pem.key", "w" do |io|
42
+ # https://github.com/inspec/inspec/security/code-scanning/1
43
+ # https://github.com/inspec/inspec/security/code-scanning/2
44
+ # The following line was flagged by GitHub code scanning as a security vulnerability.
45
+ # Update the code to eliminate the vulnerability.
46
+ File.open("#{path}/#{options["keyname"]}.pem.key", "w") do |io|
40
47
  io.write key.to_pem
41
48
  end
42
49
  puts "Generating validation key in #{path}/#{options["keyname"]}.pem.pub"
43
- open "#{path}/#{options["keyname"]}.pem.pub", "w" do |io|
50
+ File.open("#{path}/#{options["keyname"]}.pem.pub", "w") do |io|
44
51
  io.write key.public_key.to_pem
45
52
  end
46
53
  end
@@ -54,7 +61,7 @@ module InspecPlugins
54
61
  end
55
62
 
56
63
  puts "Signing #{profile_path} with key #{options["keyname"]}"
57
- keypath = Inspec::IafFile.find_signing_key(options["keyname"])
64
+ keypath = Inspec::IafFile.find_signing_key(options["keyname"], options["config_dir"])
58
65
 
59
66
  # Read name and version from metadata and use them to form the filename
60
67
  profile_md = artifact.read_profile_metadata(profile_path)
@@ -67,7 +74,8 @@ module InspecPlugins
67
74
  # Generating tar.gz file using archive method of Inspec Cli
68
75
  Inspec::InspecCLI.new.archive(profile_path, "error")
69
76
  tarfile = "#{filename}.tar.gz"
70
- tar_content = IO.binread(tarfile)
77
+ # Update IO.binread with File.binread because of https://github.com/inspec/inspec/security/code-scanning/3
78
+ tar_content = File.binread(tarfile)
71
79
  FileUtils.rm(tarfile)
72
80
 
73
81
  # Generate the signature
@@ -156,7 +164,7 @@ module InspecPlugins
156
164
  ui.exit(:usage_error)
157
165
  end
158
166
 
159
- lines = IO.readlines(p)
167
+ lines = File.readlines(p)
160
168
  lines << "\nprofile_content_id: #{profile_content_id}\n"
161
169
 
162
170
  File.open("#{p}", "w" ) do |f|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.6.0
4
+ version: 6.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef InSpec Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-09 00:00:00.000000000 Z
11
+ date: 2024-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-telemetry
@@ -119,7 +119,7 @@ dependencies:
119
119
  version: '3.9'
120
120
  - - "<="
121
121
  - !ruby/object:Gem::Version
122
- version: '3.12'
122
+ version: '3.14'
123
123
  type: :runtime
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
@@ -129,7 +129,7 @@ dependencies:
129
129
  version: '3.9'
130
130
  - - "<="
131
131
  - !ruby/object:Gem::Version
132
- version: '3.12'
132
+ version: '3.14'
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: rspec-its
135
135
  requirement: !ruby/object:Gem::Requirement
@@ -364,6 +364,20 @@ dependencies:
364
364
  - - "~>"
365
365
  - !ruby/object:Gem::Version
366
366
  version: '2.0'
367
+ - !ruby/object:Gem::Dependency
368
+ name: cookstyle
369
+ requirement: !ruby/object:Gem::Requirement
370
+ requirements:
371
+ - - ">="
372
+ - !ruby/object:Gem::Version
373
+ version: '0'
374
+ type: :runtime
375
+ prerelease: false
376
+ version_requirements: !ruby/object:Gem::Requirement
377
+ requirements:
378
+ - - ">="
379
+ - !ruby/object:Gem::Version
380
+ version: '0'
367
381
  - !ruby/object:Gem::Dependency
368
382
  name: train-core
369
383
  requirement: !ruby/object:Gem::Requirement
@@ -384,14 +398,14 @@ dependencies:
384
398
  requirements:
385
399
  - - ">="
386
400
  - !ruby/object:Gem::Version
387
- version: 0.7.5
401
+ version: 1.0.2
388
402
  type: :runtime
389
403
  prerelease: false
390
404
  version_requirements: !ruby/object:Gem::Requirement
391
405
  requirements:
392
406
  - - ">="
393
407
  - !ruby/object:Gem::Version
394
- version: 0.7.5
408
+ version: 1.0.2
395
409
  description: |+
396
410
  InSpec provides a framework for creating end-to-end infrastructure tests. You can use it for integration or even compliance testing. Create fully portable test profiles and use them in your workflow to ensure stability and security. Integrate InSpec in your change lifecycle for local testing, CI/CD, and deployment verification.
397
411
  This has local support only. See the `inspec` gem for full support.
@@ -659,6 +673,8 @@ files:
659
673
  - lib/inspec/resources/service.rb
660
674
  - lib/inspec/resources/shadow.rb
661
675
  - lib/inspec/resources/ssh_config.rb
676
+ - lib/inspec/resources/ssh_key.rb
677
+ - lib/inspec/resources/sshd_active_config.rb
662
678
  - lib/inspec/resources/sshd_config.rb
663
679
  - lib/inspec/resources/ssl.rb
664
680
  - lib/inspec/resources/sybase_conf.rb
@@ -746,9 +762,9 @@ files:
746
762
  - lib/inspec/utils/spdx.rb
747
763
  - lib/inspec/utils/spdx.txt
748
764
  - lib/inspec/utils/telemetry.rb
749
- - lib/inspec/utils/telemetry/collector.rb
750
- - lib/inspec/utils/telemetry/data_series.rb
751
- - lib/inspec/utils/telemetry/global_methods.rb
765
+ - lib/inspec/utils/telemetry/base.rb
766
+ - lib/inspec/utils/telemetry/http.rb
767
+ - lib/inspec/utils/telemetry/null.rb
752
768
  - lib/inspec/utils/telemetry/run_context_probe.rb
753
769
  - lib/inspec/utils/waivers/csv_file_reader.rb
754
770
  - lib/inspec/utils/waivers/excel_file_reader.rb
@@ -887,14 +903,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
887
903
  requirements:
888
904
  - - ">="
889
905
  - !ruby/object:Gem::Version
890
- version: '2.7'
906
+ version: 3.1.0
891
907
  required_rubygems_version: !ruby/object:Gem::Requirement
892
908
  requirements:
893
909
  - - ">="
894
910
  - !ruby/object:Gem::Version
895
911
  version: '0'
896
912
  requirements: []
897
- rubygems_version: 3.1.4
913
+ rubygems_version: 3.2.3
898
914
  signing_key:
899
915
  specification_version: 4
900
916
  summary: Infrastructure and compliance testing. Core library.
@@ -1,81 +0,0 @@
1
- require "inspec/config"
2
- require "inspec/utils/telemetry/data_series"
3
- require "singleton" unless defined?(Singleton)
4
-
5
- module Inspec::Telemetry
6
- # A Singleton collection of data series objects.
7
- class Collector
8
- include Singleton
9
-
10
- attr_reader :config
11
-
12
- def initialize
13
- @data_series = []
14
- @telemetry_toggled_off = false
15
- load_config
16
- end
17
-
18
- # Allow loading a configuration, useful when testing.
19
- def load_config(config = Inspec::Config.cached)
20
- @config = config
21
- end
22
-
23
- # Add a data series to the collection.
24
- # @return [True]
25
- def add_data_series(data_series)
26
- @data_series << data_series
27
- end
28
-
29
- # The loaded configuration should have a option to configure
30
- # telemetry, if not default to false.
31
- # @return [True, False]
32
- def telemetry_enabled?
33
- if @telemetry_toggled_off
34
- false
35
- else
36
- config_telemetry_options.fetch("enable_telemetry", false)
37
- end
38
- end
39
-
40
- # A way to disable the telemetry system.
41
- def disable_telemetry
42
- @telemetry_toggled_off = true
43
- end
44
-
45
- # The entire data series collection.
46
- # @return [Array]
47
- def list_data_series
48
- @data_series
49
- end
50
-
51
- # Finds the data series object with the specified name and returns it.
52
- # If it does not exist then creates a new data series with that name
53
- # and returns it.
54
- # @return [Inspec::Telemetry::DataSeries]
55
- def find_or_create_data_series(name)
56
- ds = @data_series.select { |data_series| data_series.name.eql?(name) }
57
- if ds.empty?
58
- new_data_series = Inspec::Telemetry::DataSeries.new(name)
59
- @data_series << new_data_series
60
- new_data_series
61
- else
62
- ds.first
63
- end
64
- end
65
-
66
- # Blanks the contents of the data series collection.
67
- # Reset telemetry toggle
68
- # @return [True]
69
- def reset!
70
- @data_series = []
71
- @telemetry_toggled_off = false
72
- end
73
-
74
- private
75
-
76
- # Minimize exposure of Inspec::Config interface
77
- def config_telemetry_options
78
- config.telemetry_options
79
- end
80
- end
81
- end
@@ -1,44 +0,0 @@
1
- require "json" unless defined?(JSON)
2
-
3
- module Inspec; end
4
-
5
- # A minimal Dataseries Object
6
- # Stores the name of the data series and an array of data.
7
- # Stored data should be a object that supports #to_s
8
- module Inspec::Telemetry
9
- class DataSeries
10
- def initialize(name)
11
- @name = name
12
- @enabled = true
13
- @data ||= []
14
- end
15
-
16
- attr_reader :data, :name
17
-
18
- # This needs to also be set by configuration.
19
- def enabled?
20
- @enabled
21
- end
22
-
23
- def disable
24
- @enabled = false
25
- end
26
-
27
- def <<(appending_data)
28
- data << appending_data
29
- end
30
-
31
- alias push <<
32
-
33
- def to_h
34
- {
35
- name: @name,
36
- data: @data,
37
- }
38
- end
39
-
40
- def to_json
41
- to_h.to_json
42
- end
43
- end
44
- end
@@ -1,22 +0,0 @@
1
- require "inspec/utils/telemetry/collector"
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
-
13
- ds = coll.find_or_create_data_series(data_series_name)
14
- return unless ds.enabled?
15
-
16
- if block_given?
17
- ds << yield
18
- else
19
- ds << data_point
20
- end
21
- end
22
- end