inspec-core 4.56.58 → 5.7.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +24 -9
  3. data/etc/deprecations.json +12 -11
  4. data/inspec-core.gemspec +3 -5
  5. data/lib/inspec/base_cli.rb +14 -2
  6. data/lib/inspec/cli.rb +16 -7
  7. data/lib/inspec/dependencies/dependency_set.rb +2 -6
  8. data/lib/inspec/dependency_installer.rb +74 -0
  9. data/lib/inspec/dependency_loader.rb +97 -0
  10. data/lib/inspec/dsl.rb +16 -23
  11. data/lib/inspec/env_printer.rb +1 -1
  12. data/lib/inspec/errors.rb +7 -0
  13. data/lib/inspec/fetcher/git.rb +28 -43
  14. data/lib/inspec/fetcher/url.rb +1 -1
  15. data/lib/inspec/formatters/base.rb +22 -0
  16. data/lib/inspec/metadata.rb +36 -0
  17. data/lib/inspec/plugin/v2/plugin_types/streaming_reporter.rb +44 -1
  18. data/lib/inspec/profile.rb +81 -29
  19. data/lib/inspec/reporters/automate.rb +1 -1
  20. data/lib/inspec/reporters/cli.rb +1 -1
  21. data/lib/inspec/reporters/json.rb +31 -11
  22. data/lib/inspec/resource.rb +6 -0
  23. data/lib/inspec/resources/cassandradb_session.rb +3 -4
  24. data/lib/inspec/resources/cron.rb +49 -0
  25. data/lib/inspec/resources/file.rb +1 -1
  26. data/lib/inspec/resources/ibmdb2_session.rb +3 -4
  27. data/lib/inspec/resources/ipfilter.rb +59 -0
  28. data/lib/inspec/resources/ipnat.rb +58 -0
  29. data/lib/inspec/resources/mongodb_session.rb +1 -7
  30. data/lib/inspec/resources/oracledb_session.rb +7 -20
  31. data/lib/inspec/resources/postgres_session.rb +5 -7
  32. data/lib/inspec/resources/processes.rb +4 -6
  33. data/lib/inspec/resources/service.rb +2 -4
  34. data/lib/inspec/resources.rb +3 -16
  35. data/lib/inspec/rule.rb +1 -1
  36. data/lib/inspec/runner.rb +18 -1
  37. data/lib/inspec/runner_rspec.rb +15 -0
  38. data/lib/inspec/schema/exec_json.rb +59 -58
  39. data/lib/inspec/schema/exec_json_min.rb +16 -16
  40. data/lib/inspec/schema/primitives.rb +68 -51
  41. data/lib/inspec/schema/profile_json.rb +27 -27
  42. data/lib/inspec/schema.rb +1 -0
  43. data/lib/inspec/secrets/yaml.rb +1 -7
  44. data/lib/inspec/ui.rb +1 -0
  45. data/lib/inspec/utils/deprecated_cloud_resources_list.rb +54 -0
  46. data/lib/inspec/version.rb +1 -1
  47. data/lib/inspec.rb +3 -0
  48. data/lib/matchers/matchers.rb +1 -7
  49. data/lib/plugins/inspec-init/lib/inspec-init/cli.rb +1 -0
  50. data/lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb +9 -0
  51. data/lib/plugins/inspec-init/lib/inspec-init/cli_resource.rb +126 -0
  52. data/lib/plugins/inspec-init/lib/inspec-init/renderer.rb +9 -8
  53. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/plugin.erb +16 -0
  54. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/streaming_reporter.erb +31 -0
  55. data/lib/plugins/inspec-init/templates/profiles/aws/inspec.yml +1 -1
  56. data/lib/plugins/inspec-init/templates/resources/basic/docs/resource-doc.erb +77 -0
  57. data/lib/plugins/inspec-init/templates/resources/basic/libraries/inspec-resource-template.erb +94 -0
  58. data/lib/plugins/inspec-init/templates/resources/plural/docs/resource-doc.erb +62 -0
  59. data/lib/plugins/inspec-init/templates/resources/plural/libraries/inspec-resource-template.erb +73 -0
  60. data/lib/plugins/inspec-reporter-html2/templates/body.html.erb +6 -4
  61. data/lib/plugins/inspec-reporter-html2/templates/control.html.erb +4 -1
  62. data/lib/plugins/inspec-reporter-html2/templates/profile.html.erb +2 -1
  63. data/lib/plugins/inspec-reporter-html2/templates/result.html.erb +1 -0
  64. data/lib/plugins/inspec-streaming-reporter-progress-bar/README.md +5 -0
  65. data/lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar/plugin.rb +13 -0
  66. data/lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar/streaming_reporter.rb +112 -0
  67. data/lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar/version.rb +8 -0
  68. data/lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar.rb +15 -0
  69. metadata +24 -7
@@ -0,0 +1,112 @@
1
+ require "progress_bar"
2
+ module InspecPlugins::StreamingReporterProgressBar
3
+ # This class will provide the actual Streaming Reporter implementation.
4
+ # Its superclass is provided by another call to Inspec.plugin,
5
+ # this time with two args. The first arg specifies we are requesting
6
+ # version 2 of the Plugins API. The second says we are making a
7
+ # Streaming Reporter plugin component, so please make available any DSL needed
8
+ # for that.
9
+
10
+ class StreamingReporter < Inspec.plugin(2, :streaming_reporter)
11
+ # Registering these methods with RSpec::Core::Formatters class is mandatory
12
+ RSpec::Core::Formatters.register self, :example_passed, :example_failed, :example_pending
13
+
14
+ case RUBY_PLATFORM
15
+ when /windows|mswin|msys|mingw|cygwin/
16
+ # Most currently available Windows terminals have poor support
17
+ # for ANSI extended colors
18
+ COLORS = {
19
+ "failed" => "\033[0;1;31m",
20
+ "passed" => "\033[0;1;32m",
21
+ "skipped" => "\033[0;37m",
22
+ "reset" => "\033[0m",
23
+ }.freeze
24
+
25
+ # Most currently available Windows terminals have poor support
26
+ # for UTF-8 characters so use these boring indicators
27
+ INDICATORS = {
28
+ "failed" => "[FAIL]",
29
+ "skipped" => "[SKIP]",
30
+ "passed" => "[PASS]",
31
+ }.freeze
32
+ else
33
+ # Extended colors for everyone else
34
+ COLORS = {
35
+ "failed" => "\033[38;5;9m",
36
+ "passed" => "\033[38;5;41m",
37
+ "skipped" => "\033[38;5;247m",
38
+ "reset" => "\033[0m",
39
+ }.freeze
40
+
41
+ # Groovy UTF-8 characters for everyone else...
42
+ # ...even though they probably only work on Mac
43
+ INDICATORS = {
44
+ "failed" => "×",
45
+ "skipped" => "↺",
46
+ "passed" => "✔",
47
+ }.freeze
48
+ end
49
+
50
+ def initialize(output)
51
+ @bar = nil
52
+ @status_mapping = {}
53
+ initialize_streaming_reporter
54
+ end
55
+
56
+ def example_passed(notification)
57
+ control_id = notification.example.metadata[:id]
58
+ set_status_mapping(control_id, "passed")
59
+ show_progress(control_id) if control_ended?(control_id)
60
+ end
61
+
62
+ def example_failed(notification)
63
+ control_id = notification.example.metadata[:id]
64
+ set_status_mapping(control_id, "failed")
65
+ show_progress(control_id) if control_ended?(control_id)
66
+ end
67
+
68
+ def example_pending(notification)
69
+ control_id = notification.example.metadata[:id]
70
+ set_status_mapping(control_id, "skipped")
71
+ show_progress(control_id) if control_ended?(control_id)
72
+ end
73
+
74
+ private
75
+
76
+ def show_progress(control_id)
77
+ @bar ||= ProgressBar.new(controls_count, :bar, :counter, :percentage)
78
+ sleep 0.1
79
+ @bar.increment!
80
+ @bar.puts format_it(control_id)
81
+ rescue Exception => ex
82
+ raise "Exception in Progress Bar streaming reporter: #{ex}"
83
+ end
84
+
85
+ def format_it(control_id)
86
+ control_status = if @status_mapping[control_id].include? "failed"
87
+ "failed"
88
+ elsif @status_mapping[control_id].include? "skipped"
89
+ "skipped"
90
+ elsif @status_mapping[control_id].include? "passed"
91
+ "passed"
92
+ end
93
+
94
+ indicator = INDICATORS[control_status]
95
+ message_to_format = ""
96
+ message_to_format += "#{indicator} "
97
+ message_to_format += control_id.to_s.lstrip.force_encoding(Encoding::UTF_8)
98
+ format_with_color(control_status, message_to_format)
99
+ end
100
+
101
+ def format_with_color(color_name, text)
102
+ "#{COLORS[color_name]}#{text}#{COLORS["reset"]}"
103
+ end
104
+
105
+ # status mapping with control id to decide the final state of the control
106
+ def set_status_mapping(control_id, status)
107
+ @status_mapping[control_id] = [] if @status_mapping[control_id].nil?
108
+ @status_mapping[control_id].push(status)
109
+ end
110
+
111
+ end
112
+ end
@@ -0,0 +1,8 @@
1
+ # This file simply makes it easier for CI engines to update
2
+ # the version stamp, and provide a clean way for the gemspec
3
+ # to learn the current version.
4
+ module InspecPlugins
5
+ module StreamingReporterProgressBar
6
+ VERSION = "0.1.0".freeze
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ # This file is known as the "entry point."
2
+ # This is the file InSpec will try to load if it
3
+ # thinks your plugin is installed.
4
+
5
+ # The *only* thing this file should do is setup the
6
+ # load path, then load the plugin definition file.
7
+
8
+ # Next two lines simply add the path of the gem to the load path.
9
+ # This is not needed when being loaded as a gem; but when doing
10
+ # plugin development, you may need it. Either way, it's harmless.
11
+ libdir = File.dirname(__FILE__)
12
+
13
+ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
14
+
15
+ require "inspec-streaming-reporter-progress-bar/plugin"
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: 4.56.58
4
+ version: 5.7.9
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-10-24 00:00:00.000000000 Z
11
+ date: 2022-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-telemetry
@@ -59,7 +59,7 @@ dependencies:
59
59
  version: '0.20'
60
60
  - - "<"
61
61
  - !ruby/object:Gem::Version
62
- version: 1.3.0
62
+ version: '2.0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -69,7 +69,7 @@ dependencies:
69
69
  version: '0.20'
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
- version: 1.3.0
72
+ version: '2.0'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: method_source
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -119,7 +119,7 @@ dependencies:
119
119
  version: '3.9'
120
120
  - - "<="
121
121
  - !ruby/object:Gem::Version
122
- version: '3.13'
122
+ version: '3.11'
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.13'
132
+ version: '3.11'
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: rspec-its
135
135
  requirement: !ruby/object:Gem::Requirement
@@ -422,6 +422,8 @@ files:
422
422
  - lib/inspec/dependencies/lockfile.rb
423
423
  - lib/inspec/dependencies/requirement.rb
424
424
  - lib/inspec/dependencies/resolver.rb
425
+ - lib/inspec/dependency_installer.rb
426
+ - lib/inspec/dependency_loader.rb
425
427
  - lib/inspec/describe_base.rb
426
428
  - lib/inspec/dist.rb
427
429
  - lib/inspec/dsl.rb
@@ -514,6 +516,7 @@ files:
514
516
  - lib/inspec/resources/command.rb
515
517
  - lib/inspec/resources/cpan.rb
516
518
  - lib/inspec/resources/cran.rb
519
+ - lib/inspec/resources/cron.rb
517
520
  - lib/inspec/resources/crontab.rb
518
521
  - lib/inspec/resources/csv.rb
519
522
  - lib/inspec/resources/dh_params.rb
@@ -551,6 +554,8 @@ files:
551
554
  - lib/inspec/resources/interface.rb
552
555
  - lib/inspec/resources/interfaces.rb
553
556
  - lib/inspec/resources/ip6tables.rb
557
+ - lib/inspec/resources/ipfilter.rb
558
+ - lib/inspec/resources/ipnat.rb
554
559
  - lib/inspec/resources/iptables.rb
555
560
  - lib/inspec/resources/json.rb
556
561
  - lib/inspec/resources/kernel_module.rb
@@ -670,6 +675,7 @@ files:
670
675
  - lib/inspec/utils/command_wrapper.rb
671
676
  - lib/inspec/utils/convert.rb
672
677
  - lib/inspec/utils/database_helpers.rb
678
+ - lib/inspec/utils/deprecated_cloud_resources_list.rb
673
679
  - lib/inspec/utils/deprecation.rb
674
680
  - lib/inspec/utils/deprecation/config_file.rb
675
681
  - lib/inspec/utils/deprecation/deprecator.rb
@@ -727,6 +733,7 @@ files:
727
733
  - lib/plugins/inspec-init/lib/inspec-init/cli.rb
728
734
  - lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb
729
735
  - lib/plugins/inspec-init/lib/inspec-init/cli_profile.rb
736
+ - lib/plugins/inspec-init/lib/inspec-init/cli_resource.rb
730
737
  - lib/plugins/inspec-init/lib/inspec-init/renderer.rb
731
738
  - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Gemfile
732
739
  - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/LICENSE
@@ -737,6 +744,7 @@ files:
737
744
  - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/cli_command.erb
738
745
  - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/plugin.erb
739
746
  - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/reporter.erb
747
+ - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/streaming_reporter.erb
740
748
  - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/version.erb
741
749
  - lib/plugins/inspec-init/templates/profiles/aws/README.md
742
750
  - lib/plugins/inspec-init/templates/profiles/aws/controls/example.rb
@@ -752,6 +760,10 @@ files:
752
760
  - lib/plugins/inspec-init/templates/profiles/os/README.md
753
761
  - lib/plugins/inspec-init/templates/profiles/os/controls/example.rb
754
762
  - lib/plugins/inspec-init/templates/profiles/os/inspec.yml
763
+ - lib/plugins/inspec-init/templates/resources/basic/docs/resource-doc.erb
764
+ - lib/plugins/inspec-init/templates/resources/basic/libraries/inspec-resource-template.erb
765
+ - lib/plugins/inspec-init/templates/resources/plural/docs/resource-doc.erb
766
+ - lib/plugins/inspec-init/templates/resources/plural/libraries/inspec-resource-template.erb
755
767
  - lib/plugins/inspec-plugin-manager-cli/README.md
756
768
  - lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli.rb
757
769
  - lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb
@@ -775,6 +787,11 @@ files:
775
787
  - lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit.rb
776
788
  - lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb
777
789
  - lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/version.rb
790
+ - lib/plugins/inspec-streaming-reporter-progress-bar/README.md
791
+ - lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar.rb
792
+ - lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar/plugin.rb
793
+ - lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar/streaming_reporter.rb
794
+ - lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar/version.rb
778
795
  - lib/plugins/shared/core_plugin_test_helper.rb
779
796
  - lib/plugins/things-for-train-integration.rb
780
797
  - lib/source_readers/flat.rb
@@ -791,7 +808,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
791
808
  requirements:
792
809
  - - ">="
793
810
  - !ruby/object:Gem::Version
794
- version: '2.6'
811
+ version: '2.7'
795
812
  required_rubygems_version: !ruby/object:Gem::Requirement
796
813
  requirements:
797
814
  - - ">="