inspec-core 4.50.3 → 5.7.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -11
  3. data/etc/deprecations.json +12 -11
  4. data/inspec-core.gemspec +2 -2
  5. data/lib/bundles/inspec-supermarket/README.md +21 -2
  6. data/lib/bundles/inspec-supermarket/cli.rb +20 -3
  7. data/lib/bundles/inspec-supermarket/target.rb +3 -2
  8. data/lib/inspec/base_cli.rb +22 -2
  9. data/lib/inspec/cli.rb +15 -0
  10. data/lib/inspec/config.rb +5 -1
  11. data/lib/inspec/dependencies/requirement.rb +2 -1
  12. data/lib/inspec/dependency_installer.rb +74 -0
  13. data/lib/inspec/dependency_loader.rb +97 -0
  14. data/lib/inspec/dsl.rb +11 -2
  15. data/lib/inspec/errors.rb +7 -0
  16. data/lib/inspec/formatters/base.rb +31 -6
  17. data/lib/inspec/library_eval_context.rb +2 -0
  18. data/lib/inspec/metadata.rb +36 -0
  19. data/lib/inspec/plugin/v1/registry.rb +1 -1
  20. data/lib/inspec/plugin/v2/plugin_types/streaming_reporter.rb +53 -0
  21. data/lib/inspec/profile.rb +63 -0
  22. data/lib/inspec/profile_context.rb +1 -6
  23. data/lib/inspec/reporters/automate.rb +1 -1
  24. data/lib/inspec/reporters/cli.rb +1 -1
  25. data/lib/inspec/reporters/json.rb +31 -11
  26. data/lib/inspec/resource.rb +6 -0
  27. data/lib/inspec/resources/auditd.rb +5 -4
  28. data/lib/inspec/resources/bash.rb +2 -0
  29. data/lib/inspec/resources/cron.rb +49 -0
  30. data/lib/inspec/resources/file.rb +38 -0
  31. data/lib/inspec/resources/firewalld.rb +83 -9
  32. data/lib/inspec/resources/grub_conf.rb +1 -1
  33. data/lib/inspec/resources/http.rb +31 -2
  34. data/lib/inspec/resources/ibmdb2_session.rb +2 -2
  35. data/lib/inspec/resources/ipfilter.rb +59 -0
  36. data/lib/inspec/resources/ipnat.rb +58 -0
  37. data/lib/inspec/resources/iptables.rb +18 -2
  38. data/lib/inspec/resources/kernel_parameters.rb +58 -0
  39. data/lib/inspec/resources/mssql_session.rb +11 -3
  40. data/lib/inspec/resources/oracledb_session.rb +3 -1
  41. data/lib/inspec/resources/package.rb +74 -1
  42. data/lib/inspec/resources/packages.rb +21 -0
  43. data/lib/inspec/resources/registry_key.rb +30 -0
  44. data/lib/inspec/resources/selinux.rb +6 -1
  45. data/lib/inspec/resources/service.rb +58 -9
  46. data/lib/inspec/resources/ssl.rb +7 -0
  47. data/lib/inspec/resources/timezone.rb +65 -0
  48. data/lib/inspec/resources.rb +5 -16
  49. data/lib/inspec/runner.rb +18 -1
  50. data/lib/inspec/runner_rspec.rb +45 -0
  51. data/lib/inspec/schema/exec_json.rb +59 -58
  52. data/lib/inspec/schema/exec_json_min.rb +16 -16
  53. data/lib/inspec/schema/primitives.rb +68 -51
  54. data/lib/inspec/schema/profile_json.rb +27 -27
  55. data/lib/inspec/schema.rb +1 -0
  56. data/lib/inspec/ui.rb +1 -0
  57. data/lib/inspec/utils/deprecated_cloud_resources_list.rb +54 -0
  58. data/lib/inspec/utils/filter.rb +46 -2
  59. data/lib/inspec/utils/run_data_filters.rb +1 -1
  60. data/lib/inspec/version.rb +1 -1
  61. data/lib/inspec.rb +3 -0
  62. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +1 -1
  63. data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +4 -3
  64. data/lib/plugins/inspec-init/lib/inspec-init/cli.rb +1 -0
  65. data/lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb +9 -0
  66. data/lib/plugins/inspec-init/lib/inspec-init/cli_resource.rb +126 -0
  67. data/lib/plugins/inspec-init/lib/inspec-init/renderer.rb +9 -8
  68. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/plugin.erb +16 -0
  69. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/streaming_reporter.erb +31 -0
  70. data/lib/plugins/inspec-init/templates/profiles/aws/inspec.yml +1 -1
  71. data/lib/plugins/inspec-init/templates/resources/basic/docs/resource-doc.erb +77 -0
  72. data/lib/plugins/inspec-init/templates/resources/basic/libraries/inspec-resource-template.erb +94 -0
  73. data/lib/plugins/inspec-init/templates/resources/plural/docs/resource-doc.erb +62 -0
  74. data/lib/plugins/inspec-init/templates/resources/plural/libraries/inspec-resource-template.erb +73 -0
  75. data/lib/plugins/inspec-reporter-html2/templates/body.html.erb +2 -0
  76. data/lib/plugins/inspec-reporter-html2/templates/control.html.erb +3 -0
  77. data/lib/plugins/inspec-reporter-html2/templates/profile.html.erb +1 -0
  78. data/lib/plugins/inspec-reporter-html2/templates/result.html.erb +1 -0
  79. data/lib/plugins/inspec-streaming-reporter-progress-bar/README.md +5 -0
  80. data/lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar/plugin.rb +13 -0
  81. data/lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar/streaming_reporter.rb +112 -0
  82. data/lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar/version.rb +8 -0
  83. data/lib/plugins/inspec-streaming-reporter-progress-bar/lib/inspec-streaming-reporter-progress-bar.rb +15 -0
  84. metadata +25 -5
@@ -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.50.3
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: 2021-11-19 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
@@ -117,7 +117,7 @@ dependencies:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
119
  version: '3.9'
120
- - - "<"
120
+ - - "<="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '3.11'
123
123
  type: :runtime
@@ -127,7 +127,7 @@ dependencies:
127
127
  - - ">="
128
128
  - !ruby/object:Gem::Version
129
129
  version: '3.9'
130
- - - "<"
130
+ - - "<="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '3.11'
133
133
  - !ruby/object:Gem::Dependency
@@ -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
@@ -479,6 +481,7 @@ files:
479
481
  - lib/inspec/plugin/v2/plugin_types/input.rb
480
482
  - lib/inspec/plugin/v2/plugin_types/mock.rb
481
483
  - lib/inspec/plugin/v2/plugin_types/reporter.rb
484
+ - lib/inspec/plugin/v2/plugin_types/streaming_reporter.rb
482
485
  - lib/inspec/plugin/v2/registry.rb
483
486
  - lib/inspec/plugin/v2/status.rb
484
487
  - lib/inspec/profile.rb
@@ -513,6 +516,7 @@ files:
513
516
  - lib/inspec/resources/command.rb
514
517
  - lib/inspec/resources/cpan.rb
515
518
  - lib/inspec/resources/cran.rb
519
+ - lib/inspec/resources/cron.rb
516
520
  - lib/inspec/resources/crontab.rb
517
521
  - lib/inspec/resources/csv.rb
518
522
  - lib/inspec/resources/dh_params.rb
@@ -550,10 +554,13 @@ files:
550
554
  - lib/inspec/resources/interface.rb
551
555
  - lib/inspec/resources/interfaces.rb
552
556
  - lib/inspec/resources/ip6tables.rb
557
+ - lib/inspec/resources/ipfilter.rb
558
+ - lib/inspec/resources/ipnat.rb
553
559
  - lib/inspec/resources/iptables.rb
554
560
  - lib/inspec/resources/json.rb
555
561
  - lib/inspec/resources/kernel_module.rb
556
562
  - lib/inspec/resources/kernel_parameter.rb
563
+ - lib/inspec/resources/kernel_parameters.rb
557
564
  - lib/inspec/resources/key_rsa.rb
558
565
  - lib/inspec/resources/ksh.rb
559
566
  - lib/inspec/resources/launchd_service.rb
@@ -619,6 +626,7 @@ files:
619
626
  - lib/inspec/resources/sys_info.rb
620
627
  - lib/inspec/resources/systemd_service.rb
621
628
  - lib/inspec/resources/sysv_service.rb
629
+ - lib/inspec/resources/timezone.rb
622
630
  - lib/inspec/resources/toml.rb
623
631
  - lib/inspec/resources/upstart_service.rb
624
632
  - lib/inspec/resources/user.rb
@@ -667,6 +675,7 @@ files:
667
675
  - lib/inspec/utils/command_wrapper.rb
668
676
  - lib/inspec/utils/convert.rb
669
677
  - lib/inspec/utils/database_helpers.rb
678
+ - lib/inspec/utils/deprecated_cloud_resources_list.rb
670
679
  - lib/inspec/utils/deprecation.rb
671
680
  - lib/inspec/utils/deprecation/config_file.rb
672
681
  - lib/inspec/utils/deprecation/deprecator.rb
@@ -724,6 +733,7 @@ files:
724
733
  - lib/plugins/inspec-init/lib/inspec-init/cli.rb
725
734
  - lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb
726
735
  - lib/plugins/inspec-init/lib/inspec-init/cli_profile.rb
736
+ - lib/plugins/inspec-init/lib/inspec-init/cli_resource.rb
727
737
  - lib/plugins/inspec-init/lib/inspec-init/renderer.rb
728
738
  - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Gemfile
729
739
  - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/LICENSE
@@ -734,6 +744,7 @@ files:
734
744
  - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/cli_command.erb
735
745
  - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/plugin.erb
736
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
737
748
  - lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/version.erb
738
749
  - lib/plugins/inspec-init/templates/profiles/aws/README.md
739
750
  - lib/plugins/inspec-init/templates/profiles/aws/controls/example.rb
@@ -749,6 +760,10 @@ files:
749
760
  - lib/plugins/inspec-init/templates/profiles/os/README.md
750
761
  - lib/plugins/inspec-init/templates/profiles/os/controls/example.rb
751
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
752
767
  - lib/plugins/inspec-plugin-manager-cli/README.md
753
768
  - lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli.rb
754
769
  - lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb
@@ -772,6 +787,11 @@ files:
772
787
  - lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit.rb
773
788
  - lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb
774
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
775
795
  - lib/plugins/shared/core_plugin_test_helper.rb
776
796
  - lib/plugins/things-for-train-integration.rb
777
797
  - lib/source_readers/flat.rb
@@ -788,7 +808,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
788
808
  requirements:
789
809
  - - ">="
790
810
  - !ruby/object:Gem::Version
791
- version: '2.5'
811
+ version: '2.7'
792
812
  required_rubygems_version: !ruby/object:Gem::Requirement
793
813
  requirements:
794
814
  - - ">="