From b25f13cd5608f066bf97dd03652c327613b431f1 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 16 Oct 2020 10:53:59 -0700 Subject: [PATCH 01/15] Update Ruby to 2.7.2 Now that Ruby 2.7.2 no longer throws deprecation warnings left and right we should update InSpec to use the latest and greatest Ruby that we use in Chef Infra Client and Workstation. Signed-off-by: Tim Smith --- omnibus_overrides.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omnibus_overrides.rb b/omnibus_overrides.rb index 6296b33ec..25c836ef9 100644 --- a/omnibus_overrides.rb +++ b/omnibus_overrides.rb @@ -3,4 +3,4 @@ # grab the current train release from rubygems.org train_stable = /^train \((.*)\)/.match(`gem list ^train$ --remote`)[1] override "train", version: "v#{train_stable}" -override "ruby", version: "2.6.6" +override "ruby", version: "2.7.2" From 918b7fe84010bbc957be36f3150fcbad795c4725 Mon Sep 17 00:00:00 2001 From: James Stocks Date: Wed, 11 Nov 2020 10:56:23 +0000 Subject: [PATCH 02/15] grub_conf - handle no menuentry config Fixes #5305 grub_conf assumes for grub2 that the config (default `/etc/default/grub`) contains `menuentry` lines. i.e. entries in the menu of kernels to boot. A customer reports, and we can reproduce on the Vagrant `centos/8` image, that the default config for grub2 contains no such entries. Signed-off-by: James Stocks --- lib/inspec/resources/grub_conf.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/inspec/resources/grub_conf.rb b/lib/inspec/resources/grub_conf.rb index 28cfad6ac..a71ddb4ed 100644 --- a/lib/inspec/resources/grub_conf.rb +++ b/lib/inspec/resources/grub_conf.rb @@ -29,7 +29,7 @@ module Inspec::Resources @content = read_file(@conf_path) @kernel = kernel || "default" rescue UnknownGrubConfig - skip_resource "The `grub_config` resource is not supported on your OS yet." + skip_resource "The `grub_conf` resource is not yet supported on the target OS #{inspec.os[:name]}." end def config_for_platform(path) @@ -77,6 +77,7 @@ module Inspec::Resources def grub2_parse_kernel_lines(content, conf) menu_entries = extract_menu_entries(content) + return {} if menu_entries.empty? if @kernel == "default" default_menu_entry(menu_entries, conf["GRUB_DEFAULT"]) From a85f7a228fa4c9002ae53e814b8049f5d6530c9c Mon Sep 17 00:00:00 2001 From: Clinton Wolfe Date: Thu, 12 Nov 2020 15:05:59 -0500 Subject: [PATCH 03/15] Don't reload plugins if load_all is called repeatedly. Signed-off-by: Clinton Wolfe --- lib/inspec/plugin/v2/loader.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/inspec/plugin/v2/loader.rb b/lib/inspec/plugin/v2/loader.rb index 5887625d7..4dcb689d1 100644 --- a/lib/inspec/plugin/v2/loader.rb +++ b/lib/inspec/plugin/v2/loader.rb @@ -50,6 +50,11 @@ module Inspec::Plugin::V2 # we want to allow "sidecar loading", in which case a plugin may add an entry to the registry. registry.plugin_names.dup.each do |plugin_name| plugin_details = registry[plugin_name] + + # Under some conditions (kitchen-inspec with multiple test suites, for example), this may be + # called multple times. Don't reload anything. + next if plugin_details.loaded + # We want to capture literally any possible exception here, since we are storing them. # rubocop: disable Lint/RescueException begin From 638ec26abeb169d7fdcd7190b263cd2fff2e6b81 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Wed, 18 Nov 2020 14:17:02 +0000 Subject: [PATCH 04/15] Bump version to 4.23.20 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 10 ++++++++-- VERSION | 2 +- inspec-bin/lib/inspec-bin/version.rb | 2 +- lib/inspec/version.rb | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dfecbb45..6191975b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # Change Log - -## Unreleased + +## [v4.23.20](https://github.com/inspec/inspec/tree/v4.23.20) (2020-11-18) + +#### Bug Fixes +- Don't reload plugins if load_all is called repeatedly [#5308](https://github.com/inspec/inspec/pull/5308) ([clintoncwolfe](https://github.com/clintoncwolfe)) #### Merged Pull Requests - Update Codeowners file for Docs [#5298](https://github.com/inspec/inspec/pull/5298) ([mjingle](https://github.com/mjingle)) @@ -10,6 +13,9 @@ ### Changes since 4.23.15 release +#### Bug Fixes +- Don't reload plugins if load_all is called repeatedly [#5308](https://github.com/inspec/inspec/pull/5308) ([clintoncwolfe](https://github.com/clintoncwolfe)) + #### Merged Pull Requests - Update Codeowners file for Docs [#5298](https://github.com/inspec/inspec/pull/5298) ([mjingle](https://github.com/mjingle)) - Bumps parallel for ruby 2.4 issue [#5304](https://github.com/inspec/inspec/pull/5304) ([Schwad](https://github.com/Schwad)) diff --git a/VERSION b/VERSION index 9352eb456..96a56c39a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.23.19 \ No newline at end of file +4.23.20 \ No newline at end of file diff --git a/inspec-bin/lib/inspec-bin/version.rb b/inspec-bin/lib/inspec-bin/version.rb index 48d1d8070..2b667ea9e 100644 --- a/inspec-bin/lib/inspec-bin/version.rb +++ b/inspec-bin/lib/inspec-bin/version.rb @@ -1,5 +1,5 @@ # This file managed by automation - do not edit manually module InspecBin INSPECBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "4.23.19".freeze + VERSION = "4.23.20".freeze end diff --git a/lib/inspec/version.rb b/lib/inspec/version.rb index baf049807..d052c8866 100644 --- a/lib/inspec/version.rb +++ b/lib/inspec/version.rb @@ -1,3 +1,3 @@ module Inspec - VERSION = "4.23.19".freeze + VERSION = "4.23.20".freeze end From 65da44b6f78cf8f5c3b4a5d6e6e6a4c0dfb92e51 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Wed, 18 Nov 2020 15:41:02 +0000 Subject: [PATCH 05/15] Bump version to 4.23.21 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 10 ++++------ VERSION | 2 +- inspec-bin/lib/inspec-bin/version.rb | 2 +- lib/inspec/version.rb | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6191975b6..f090a2ba8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,10 @@ # Change Log - -## [v4.23.20](https://github.com/inspec/inspec/tree/v4.23.20) (2020-11-18) - -#### Bug Fixes -- Don't reload plugins if load_all is called repeatedly [#5308](https://github.com/inspec/inspec/pull/5308) ([clintoncwolfe](https://github.com/clintoncwolfe)) + +## [v4.23.21](https://github.com/inspec/inspec/tree/v4.23.21) (2020-11-18) #### Merged Pull Requests -- Update Codeowners file for Docs [#5298](https://github.com/inspec/inspec/pull/5298) ([mjingle](https://github.com/mjingle)) +- grub_conf - handle no menuentry config [#5306](https://github.com/inspec/inspec/pull/5306) ([james-stocks](https://github.com/james-stocks)) @@ -17,6 +14,7 @@ - Don't reload plugins if load_all is called repeatedly [#5308](https://github.com/inspec/inspec/pull/5308) ([clintoncwolfe](https://github.com/clintoncwolfe)) #### Merged Pull Requests +- grub_conf - handle no menuentry config [#5306](https://github.com/inspec/inspec/pull/5306) ([james-stocks](https://github.com/james-stocks)) - Update Codeowners file for Docs [#5298](https://github.com/inspec/inspec/pull/5298) ([mjingle](https://github.com/mjingle)) - Bumps parallel for ruby 2.4 issue [#5304](https://github.com/inspec/inspec/pull/5304) ([Schwad](https://github.com/Schwad)) - replace deprecated attributes section with inputs [#5295](https://github.com/inspec/inspec/pull/5295) ([KonradSchieban](https://github.com/KonradSchieban)) diff --git a/VERSION b/VERSION index 96a56c39a..981ff88f8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.23.20 \ No newline at end of file +4.23.21 \ No newline at end of file diff --git a/inspec-bin/lib/inspec-bin/version.rb b/inspec-bin/lib/inspec-bin/version.rb index 2b667ea9e..b4e2157b3 100644 --- a/inspec-bin/lib/inspec-bin/version.rb +++ b/inspec-bin/lib/inspec-bin/version.rb @@ -1,5 +1,5 @@ # This file managed by automation - do not edit manually module InspecBin INSPECBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "4.23.20".freeze + VERSION = "4.23.21".freeze end diff --git a/lib/inspec/version.rb b/lib/inspec/version.rb index d052c8866..a0078c181 100644 --- a/lib/inspec/version.rb +++ b/lib/inspec/version.rb @@ -1,3 +1,3 @@ module Inspec - VERSION = "4.23.20".freeze + VERSION = "4.23.21".freeze end From 345a832eb1eef16e749d6f22b7382fc2481e7c2f Mon Sep 17 00:00:00 2001 From: Nick Schwaderer Date: Fri, 4 Sep 2020 08:59:01 +0100 Subject: [PATCH 06/15] Supply resource name, params to code_desc Signed-off-by: Nick Schwaderer --- dev-docs/plugins.md | 1 + lib/inspec/formatters/base.rb | 16 +++++++++++++++ lib/inspec/reporters/json.rb | 2 ++ lib/inspec/resource.rb | 2 ++ lib/inspec/run_data.rb | 2 +- lib/inspec/run_data/result.rb | 2 ++ lib/inspec/schema.rb | 2 ++ test/fixtures/reporters/json_merged_output | 9 ++++++--- test/fixtures/reporters/json_output | 2 +- test/fixtures/reporters/yaml_output | 5 +++-- test/functional/inspec_exec_json_test.rb | 23 ++++++++++++++++++++++ test/unit/reporters/json_automate_test.rb | 1 - test/unit/reporters/json_test.rb | 2 ++ 13 files changed, 61 insertions(+), 8 deletions(-) diff --git a/dev-docs/plugins.md b/dev-docs/plugins.md index 6fd713f02..ee5d3360b 100644 --- a/dev-docs/plugins.md +++ b/dev-docs/plugins.md @@ -486,6 +486,7 @@ The `run_data` object contains all data from the Chef InSpec run. Here is an ove v0.1.0 - Initial version v0.2.0 - added `run_data.profiles[0].inputs[0].options.sensitive` +v0.3.0 - added resource_name && params ## Implementing Input Plugins diff --git a/lib/inspec/formatters/base.rb b/lib/inspec/formatters/base.rb index 72d99d2c0..0dabb28ea 100644 --- a/lib/inspec/formatters/base.rb +++ b/lib/inspec/formatters/base.rb @@ -159,6 +159,14 @@ module Inspec::Formatters resource_title: example.metadata[:described_class] || example.metadata[:example_group][:description], expectation_message: format_expectation_message(example), waiver_data: example.metadata[:waiver_data], + # This enforces the resource name as expected based off of the class + # name. However, if we wanted the `name` attribute against the class + # to be canonical for this case (consider edge cases!) we would use + # example.metadata[:described_class].instance_variable_get(:@__resource_name__)&.to_s + resource_class: example.metadata[:described_class].class.superclass.name, + # This is a raw grep of the text passed to the resource in any format, + # and is used to enforce near-uniqueness against the resource. + resource_params: find_resource_params(example.metadata[:described_class]), } unless (pid = example.metadata[:profile_id]).nil? @@ -174,6 +182,14 @@ module Inspec::Formatters res end + def find_resource_params(example) + if example.class.ancestors.include?(Inspec::Resource) + example.instance_variable_get(:@resource_params) + else + [] + end + end + def format_expectation_message(example) if (example.metadata[:example_group][:description_args].first == example.metadata[:example_group][:described_class]) || example.metadata[:example_group][:described_class].nil? diff --git a/lib/inspec/reporters/json.rb b/lib/inspec/reporters/json.rb index 839bcd929..b5138c075 100644 --- a/lib/inspec/reporters/json.rb +++ b/lib/inspec/reporters/json.rb @@ -40,6 +40,8 @@ module Inspec::Reporters message: r[:message], exception: r[:exception], backtrace: r[:backtrace], + resource_class: r[:resource_class], + resource_params: r[:resource_params].to_s, }.reject { |_k, v| v.nil? } } end diff --git a/lib/inspec/resource.rb b/lib/inspec/resource.rb index a3751cfc3..4a9364b7a 100644 --- a/lib/inspec/resource.rb +++ b/lib/inspec/resource.rb @@ -108,6 +108,7 @@ module Inspec # Infrastructure / Bookkeeping def self.__register(name, resource_klass) + # This has bitten us and should be a great candidate to remove in InSpec5 cl = Class.new(resource_klass) do # TODO: remove # As best I can figure out, this anonymous class only exists # because we're trying to avoid having resources with @@ -116,6 +117,7 @@ module Inspec # documentation. def initialize(backend, name, *args) supersuper_initialize(backend, name) do + @resource_params = args super(*args) end end diff --git a/lib/inspec/run_data.rb b/lib/inspec/run_data.rb index 5011efd33..3fbf1e129 100644 --- a/lib/inspec/run_data.rb +++ b/lib/inspec/run_data.rb @@ -47,7 +47,7 @@ module Inspec # core reporters have been migrated to plugins. It is probable that new data elements # and new Hash compatibility behavior will be added during the core reporter plugin # conversion process. - SCHEMA_VERSION = "0.2.0".freeze + SCHEMA_VERSION = "0.3.0".freeze def self.compatible_schema?(constraints) reqs = Gem::Requirement.create(constraints) diff --git a/lib/inspec/run_data/result.rb b/lib/inspec/run_data/result.rb index 92d1a4265..b6c8a2de9 100644 --- a/lib/inspec/run_data/result.rb +++ b/lib/inspec/run_data/result.rb @@ -8,6 +8,7 @@ module Inspec :run_time, # Float seconds execution time :skip_message, # String :start_time, # DateTime + :resource_params, # What is passed to the resource as a raw grep :status, # String :resource_title, # Ugly internals # :waiver_data, # Undocumented tramp data / not exposed in this API @@ -34,6 +35,7 @@ module Inspec end self.resource_name = raw_res_data[:resource_title].instance_variable_get(:@__resource_name__)&.to_s + self.resource_params = raw_res_data[:resource_title].instance_variable_get(:@grep)&.to_s end end end diff --git a/lib/inspec/schema.rb b/lib/inspec/schema.rb index 61dcfd3fa..32711518e 100644 --- a/lib/inspec/schema.rb +++ b/lib/inspec/schema.rb @@ -56,6 +56,7 @@ module Inspec "code_desc" => { "type" => "string" }, "run_time" => { "type" => "number" }, "start_time" => { "type" => "string" }, + "resource_class" => { "type" => "string", "optional" => true }, "skip_message" => { "type" => "string", "optional" => true }, "resource" => { "type" => "string", "optional" => true }, "message" => { "type" => "string", "optional" => true }, @@ -194,6 +195,7 @@ module Inspec "profile_sha256" => { "type" => "string" }, "status" => { "type" => "string" }, "code_desc" => { "type" => "string" }, + "resource_class" => { "type" => "string", "optional" => true }, "skip_message" => { "type" => "string", "optional" => true }, "resource" => { "type" => "string", "optional" => true }, "message" => { "type" => "string", "optional" => true }, diff --git a/test/fixtures/reporters/json_merged_output b/test/fixtures/reporters/json_merged_output index 10f91b577..49dd8349d 100644 --- a/test/fixtures/reporters/json_merged_output +++ b/test/fixtures/reporters/json_merged_output @@ -61,7 +61,8 @@ "status": "passed", "code_desc": "File /etc/hosts mode should eq 420", "run_time": 0.031503, - "start_time": "2018-07-30T08:56:41-04:00" + "start_time": "2018-07-30T08:56:41-04:00", + "resource_params": "" } ] }, @@ -101,7 +102,8 @@ "status": "passed", "code_desc": "File /etc/passwd should exist", "run_time": 0.003954, - "start_time": "2018-07-30T08:56:41-04:00" + "start_time": "2018-07-30T08:56:41-04:00", + "resource_params": "" } ] }, @@ -131,7 +133,8 @@ "run_time": 2.9e-05, "start_time": "2018-07-30T08:56:41-04:00", "resource": "Operating System Detection", - "skip_message": "Skipped control due to only_if condition." + "skip_message": "Skipped control due to only_if condition.", + "resource_params": "" } ] } diff --git a/test/fixtures/reporters/json_output b/test/fixtures/reporters/json_output index 6f1168fa4..fcd0474fb 100644 --- a/test/fixtures/reporters/json_output +++ b/test/fixtures/reporters/json_output @@ -1 +1 @@ -{"platform":{"name":"mac_os_x","release":"17.2.0"},"profiles":[{"name":"long_commands","version":"0.1.0","sha256":"4f816f8cf18f165f05f1cf20936aaad06a15287de3f578891197647ca05c7df4","title":"InSpec Profile","maintainer":"The Authors","summary":"An InSpec Compliance Profile","license":"Apache-2.0","copyright":"The Authors","copyright_email":"you@example.com","supports":[{"os-family":"bds"},{"os-name":"mac_os_x","release":"17.*"}],"attributes":[],"groups":[{"id":"controls/example.rb","controls":["(generated from example.rb:7 871cd54043069c5c4f6e382fd5627830)","tmp-1.0","(generated from example.rb:21 2ff474c5357e7070f4c3efa932032dcb)"],"title":"sample section"},{"id":"controls/run_command.rb","controls":["(generated from run_command.rb:5 a411d4ded1530b2f48170840e1127584)"]}],"controls":[{"id":"(generated from example.rb:7 871cd54043069c5c4f6e382fd5627830)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"waiver_data":{},"results":[{"status":"passed","code_desc":"File /tmp should be directory","run_time":0.002058,"start_time":"2018-01-05 11:43:04 -0500"}]},{"id":"tmp-1.0","title":"Create /tmp directory","desc":"An optional description...","descriptions":[{"label":"default","data":"An optional description..."}],"impact":0.7,"refs":[],"tags":{},"code":"control 'tmp-1.0' do # A unique ID for this control\n impact 0.7 # The criticality, if this control fails.\n title 'Create /tmp directory' # A human-readable title\n desc 'An optional description...'\n describe file('/tmp') do # The actual test\n it { should be_directory }\n end\nend\n","waiver_data":{},"source_location":{"line":12,"ref":"../inspec-demo/_test/long_commands/controls/example.rb"},"results":[{"status":"passed","code_desc":"File /tmp should be directory","run_time":0.000102,"start_time":"2018-01-05 11:43:04 -0500"}]},{"id":"(generated from example.rb:21 2ff474c5357e7070f4c3efa932032dcb)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","waiver_data":{},"source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"results":[{"status":"failed","code_desc":"gem package rubocop should be installed","run_time":0.000168,"start_time":"2018-01-05 11:43:04 -0500","message":"rubocop is not installed"}]},{"id":"(generated from run_command.rb:5 a411d4ded1530b2f48170840e1127584)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","waiver_data":{},"source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"results":[{"status":"passed","code_desc":"Command whoami stdout should eq \"jquick\\n\"","run_time":0.034938,"start_time":"2018-01-05 11:43:04 -0500"}]}]}],"statistics":{"duration":0.039182},"version":"1.49.2"} +{"platform":{"name":"mac_os_x","release":"17.2.0"},"profiles":[{"name":"long_commands","version":"0.1.0","sha256":"4f816f8cf18f165f05f1cf20936aaad06a15287de3f578891197647ca05c7df4","title":"InSpec Profile","maintainer":"The Authors","summary":"An InSpec Compliance Profile","license":"Apache-2.0","copyright":"The Authors","copyright_email":"you@example.com","supports":[{"os-family":"bds"},{"os-name":"mac_os_x","release":"17.*"}],"attributes":[],"groups":[{"id":"controls/example.rb","controls":["(generated from example.rb:7 871cd54043069c5c4f6e382fd5627830)","tmp-1.0","(generated from example.rb:21 2ff474c5357e7070f4c3efa932032dcb)"],"title":"sample section"},{"id":"controls/run_command.rb","controls":["(generated from run_command.rb:5 a411d4ded1530b2f48170840e1127584)"]}],"controls":[{"id":"(generated from example.rb:7 871cd54043069c5c4f6e382fd5627830)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"waiver_data":{},"results":[{"status":"passed","code_desc":"File /tmp should be directory","run_time":0.002058,"start_time":"2018-01-05 11:43:04 -0500","resource_params":""}]},{"id":"tmp-1.0","title":"Create /tmp directory","desc":"An optional description...","descriptions":[{"label":"default","data":"An optional description..."}],"impact":0.7,"refs":[],"tags":{},"code":"control 'tmp-1.0' do # A unique ID for this control\n impact 0.7 # The criticality, if this control fails.\n title 'Create /tmp directory' # A human-readable title\n desc 'An optional description...'\n describe file('/tmp') do # The actual test\n it { should be_directory }\n end\nend\n","waiver_data":{},"source_location":{"line":12,"ref":"../inspec-demo/_test/long_commands/controls/example.rb"},"results":[{"status":"passed","code_desc":"File /tmp should be directory","run_time":0.000102,"start_time":"2018-01-05 11:43:04 -0500","resource_params":""}]},{"id":"(generated from example.rb:21 2ff474c5357e7070f4c3efa932032dcb)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","waiver_data":{},"source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"results":[{"status":"failed","code_desc":"gem package rubocop should be installed","run_time":0.000168,"start_time":"2018-01-05 11:43:04 -0500","message":"rubocop is not installed","resource_params":""}]},{"id":"(generated from run_command.rb:5 a411d4ded1530b2f48170840e1127584)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","waiver_data":{},"source_location":{"line":89,"ref":"/Users/jquick/Chef/inspec/lib/inspec/control_eval_context.rb"},"results":[{"status":"passed","code_desc":"Command whoami stdout should eq \"jquick\\n\"","run_time":0.034938,"start_time":"2018-01-05 11:43:04 -0500","resource_params":""}]}]}],"statistics":{"duration":0.039182},"version":"1.49.2"} diff --git a/test/fixtures/reporters/yaml_output b/test/fixtures/reporters/yaml_output index 7c416f5fc..6f811b38b 100644 --- a/test/fixtures/reporters/yaml_output +++ b/test/fixtures/reporters/yaml_output @@ -14,8 +14,8 @@ - "(generated from t.rb:1 0aa70d93be7b0cf41b97a1363bb5e8b8)" :controls: - :id: "(generated from t.rb:1 0aa70d93be7b0cf41b97a1363bb5e8b8)" - :title: - :desc: + :title: + :desc: :descriptions: [] :impact: 0.5 :refs: [] @@ -30,6 +30,7 @@ :code_desc: File /tmp should exist :run_time: 0.001313935 :start_time: '2018-05-31T16:22:19+05:30' + :resource_params: '' :statistics: :duration: 0.002678506 :version: 2.1.83 diff --git a/test/functional/inspec_exec_json_test.rb b/test/functional/inspec_exec_json_test.rb index 7d30d4f1f..e18f81872 100644 --- a/test/functional/inspec_exec_json_test.rb +++ b/test/functional/inspec_exec_json_test.rb @@ -187,6 +187,29 @@ describe "inspec exec with json formatter" do _(ex1["impact"]).must_equal 0.7 end + describe "results" do + let(:result) { ex1["results"][0] } + let(:result2) { ex2["results"][0] } + + it "has a code_desc" do + _(result["code_desc"]).must_equal "File / is expected to be directory" + end + + it "has a resource_class" do + _(result["resource_class"]).must_equal "file" + end + + # This is a raw grep of the argument(s) passed to the resource, currently + # used by automate to identify and sort differing resources + it "has a resource_params that's empty" do + _(result["resource_params"]).must_equal "[\"/\"]" + end + + it "has a resource_params with values" do + _(result2["resource_params"]).must_equal "[\"/\"]" + end + end + it "has all the metadata" do actual = profile.dup key = actual.delete("controls") diff --git a/test/unit/reporters/json_automate_test.rb b/test/unit/reporters/json_automate_test.rb index 81a16fced..a33fb8e03 100644 --- a/test/unit/reporters/json_automate_test.rb +++ b/test/unit/reporters/json_automate_test.rb @@ -15,7 +15,6 @@ describe Inspec::Reporters::JsonAutomate do report.render actual = JSON.parse(report.rendered_output, symbolize_names: true) - _(actual).must_equal output end end diff --git a/test/unit/reporters/json_test.rb b/test/unit/reporters/json_test.rb index c81bba920..f9bc20d49 100644 --- a/test/unit/reporters/json_test.rb +++ b/test/unit/reporters/json_test.rb @@ -55,6 +55,7 @@ describe Inspec::Reporters::Json do code_desc: "File /tmp should be directory", run_time: 0.002058, start_time: "2018-01-05 11:43:04 -0500", + resource_params: "", } result = report.send(:profile_results, control) _(result.first).must_equal hash @@ -68,6 +69,7 @@ describe Inspec::Reporters::Json do code_desc: "File /tmp should be directory", run_time: 0.002058, start_time: "2018-01-05 11:43:04 -0500", + resource_params: "", resource: "File", skip_message: "skipping", } From 0860e631a7a63f8aa8c951248fe53136ea1913ba Mon Sep 17 00:00:00 2001 From: Nick Schwaderer Date: Mon, 23 Nov 2020 15:46:19 +0000 Subject: [PATCH 07/15] Revert "Supply resource name, params to code_desc" This reverts commit 345a832eb1eef16e749d6f22b7382fc2481e7c2f. Signed-off-by: Nick Schwaderer --- test/fixtures/reporters/yaml_output | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/fixtures/reporters/yaml_output b/test/fixtures/reporters/yaml_output index 6f811b38b..7c416f5fc 100644 --- a/test/fixtures/reporters/yaml_output +++ b/test/fixtures/reporters/yaml_output @@ -14,8 +14,8 @@ - "(generated from t.rb:1 0aa70d93be7b0cf41b97a1363bb5e8b8)" :controls: - :id: "(generated from t.rb:1 0aa70d93be7b0cf41b97a1363bb5e8b8)" - :title: - :desc: + :title: + :desc: :descriptions: [] :impact: 0.5 :refs: [] @@ -30,7 +30,6 @@ :code_desc: File /tmp should exist :run_time: 0.001313935 :start_time: '2018-05-31T16:22:19+05:30' - :resource_params: '' :statistics: :duration: 0.002678506 :version: 2.1.83 From acf2b2bbabc44674d29d3b56c8ddae779133f641 Mon Sep 17 00:00:00 2001 From: Nick Schwaderer Date: Mon, 23 Nov 2020 15:49:52 +0000 Subject: [PATCH 08/15] Reverts without bug Signed-off-by: Nick Schwaderer --- test/fixtures/reporters/yaml_output | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fixtures/reporters/yaml_output b/test/fixtures/reporters/yaml_output index 7c416f5fc..b742290d6 100644 --- a/test/fixtures/reporters/yaml_output +++ b/test/fixtures/reporters/yaml_output @@ -30,6 +30,7 @@ :code_desc: File /tmp should exist :run_time: 0.001313935 :start_time: '2018-05-31T16:22:19+05:30' + :resource_params: '' :statistics: :duration: 0.002678506 :version: 2.1.83 From ecc26f4f12ec19b30a186077ca6721f90bb6fbb8 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Mon, 23 Nov 2020 16:41:13 +0000 Subject: [PATCH 09/15] Bump version to 4.23.22 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 11 +++++++---- VERSION | 2 +- inspec-bin/lib/inspec-bin/version.rb | 2 +- lib/inspec/version.rb | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f090a2ba8..87d5ff718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,18 @@ # Change Log - -## [v4.23.21](https://github.com/inspec/inspec/tree/v4.23.21) (2020-11-18) + +## [v4.23.22](https://github.com/inspec/inspec/tree/v4.23.22) (2020-11-23) -#### Merged Pull Requests -- grub_conf - handle no menuentry config [#5306](https://github.com/inspec/inspec/pull/5306) ([james-stocks](https://github.com/james-stocks)) +#### New Features +- InSpec Cloud: Reporting by Resource [#5241](https://github.com/inspec/inspec/pull/5241) ([Schwad](https://github.com/Schwad)) ### Changes since 4.23.15 release +#### New Features +- InSpec Cloud: Reporting by Resource [#5241](https://github.com/inspec/inspec/pull/5241) ([Schwad](https://github.com/Schwad)) + #### Bug Fixes - Don't reload plugins if load_all is called repeatedly [#5308](https://github.com/inspec/inspec/pull/5308) ([clintoncwolfe](https://github.com/clintoncwolfe)) diff --git a/VERSION b/VERSION index 981ff88f8..1415ea7ed 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.23.21 \ No newline at end of file +4.23.22 \ No newline at end of file diff --git a/inspec-bin/lib/inspec-bin/version.rb b/inspec-bin/lib/inspec-bin/version.rb index b4e2157b3..ca33893f5 100644 --- a/inspec-bin/lib/inspec-bin/version.rb +++ b/inspec-bin/lib/inspec-bin/version.rb @@ -1,5 +1,5 @@ # This file managed by automation - do not edit manually module InspecBin INSPECBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "4.23.21".freeze + VERSION = "4.23.22".freeze end diff --git a/lib/inspec/version.rb b/lib/inspec/version.rb index a0078c181..cad2afdd7 100644 --- a/lib/inspec/version.rb +++ b/lib/inspec/version.rb @@ -1,3 +1,3 @@ module Inspec - VERSION = "4.23.21".freeze + VERSION = "4.23.22".freeze end From e5dfa9d65252635a8bc76ad60cc39207a122c369 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Wed, 25 Nov 2020 12:41:26 +0000 Subject: [PATCH 10/15] Update CHANGELOG.md with details from pull request #5281 Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d5ff718..442010d70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ # Change Log - -## [v4.23.22](https://github.com/inspec/inspec/tree/v4.23.22) (2020-11-23) + +## Unreleased -#### New Features -- InSpec Cloud: Reporting by Resource [#5241](https://github.com/inspec/inspec/pull/5241) ([Schwad](https://github.com/Schwad)) +#### Merged Pull Requests +- Update Ruby to 2.7.2 [#5281](https://github.com/inspec/inspec/pull/5281) ([tas50](https://github.com/tas50)) @@ -17,6 +17,7 @@ - Don't reload plugins if load_all is called repeatedly [#5308](https://github.com/inspec/inspec/pull/5308) ([clintoncwolfe](https://github.com/clintoncwolfe)) #### Merged Pull Requests +- Update Ruby to 2.7.2 [#5281](https://github.com/inspec/inspec/pull/5281) ([tas50](https://github.com/tas50)) - grub_conf - handle no menuentry config [#5306](https://github.com/inspec/inspec/pull/5306) ([james-stocks](https://github.com/james-stocks)) - Update Codeowners file for Docs [#5298](https://github.com/inspec/inspec/pull/5298) ([mjingle](https://github.com/mjingle)) - Bumps parallel for ruby 2.4 issue [#5304](https://github.com/inspec/inspec/pull/5304) ([Schwad](https://github.com/Schwad)) From db5c39884a91550d2ec004621d9023eb79774977 Mon Sep 17 00:00:00 2001 From: Clinton Wolfe Date: Mon, 30 Nov 2020 14:43:48 -0500 Subject: [PATCH 11/15] Remove Ruby 2.4 from test matrix Signed-off-by: Clinton Wolfe --- .expeditor/verify.pipeline.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml index 0fb7d6d25..f4527739a 100644 --- a/.expeditor/verify.pipeline.yml +++ b/.expeditor/verify.pipeline.yml @@ -17,14 +17,6 @@ steps: docker: image: ruby:2.6 - - label: run-tests-ruby-2.4 - command: - - /workdir/.expeditor/buildkite/verify.sh - expeditor: - executor: - docker: - image: ruby:2.4 - - label: run-tests-ruby-2.5 command: - /workdir/.expeditor/buildkite/verify.sh From 6493534843c584082f4049478756d4c0c987b5c3 Mon Sep 17 00:00:00 2001 From: Clinton Wolfe Date: Mon, 30 Nov 2020 15:41:26 -0500 Subject: [PATCH 12/15] Conditionally pin chef-utils on Ruby 2.5 Signed-off-by: Clinton Wolfe --- Gemfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index 56ddae642..af32fb28f 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,11 @@ gem "inspec-bin", path: "./inspec-bin" gem "ffi", ">= 1.9.14", "!= 1.13.0" +if Gem.ruby_version.to_s.start_with?("2.5") + # 16.7.23 required ruby 2.6+ + gem "chef-utils", "< 16.7.23" # TODO: remove when we drop ruby 2.5 +end + group :omnibus do gem "rb-readline" gem "appbundler" From a6cff007ed83b2d45e6634de29af1b8aaa68b2bc Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 30 Nov 2020 18:02:50 -0800 Subject: [PATCH 13/15] Fix Windows escaping of Windows package names This resolves #5235 and supersedes #5238. Instead of using `-match` use `-like` when querying the Windows registry. This completely removes the problem of trying to clean the string for a regex and just let's Powershell do that with `-like`. I confirmed this works with the use case of having a package name such as `Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.28.29325` work as-is without any modification. Signed-off-by: Lance Albertson --- lib/inspec/resources/package.rb | 2 +- test/helpers/mock_loader.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/inspec/resources/package.rb b/lib/inspec/resources/package.rb index 68e4060e1..3874c091f 100644 --- a/lib/inspec/resources/package.rb +++ b/lib/inspec/resources/package.rb @@ -314,7 +314,7 @@ module Inspec::Resources # Find the package cmd = inspec.command <<-EOF.gsub(/^\s*/, "") Get-ItemProperty (@("#{search_paths.join('", "')}") | Where-Object { Test-Path $_ }) | - Where-Object { $_.DisplayName -match "^\s*#{package_name.shellescape}\.*" -or $_.PSChildName -match "^\s*#{package_name.shellescape}\.*" } | + Where-Object { $_.DisplayName -like "#{package_name}" -or $_.PSChildName -like "#{package_name}" } | Select-Object -Property DisplayName,DisplayVersion | ConvertTo-Json EOF diff --git a/test/helpers/mock_loader.rb b/test/helpers/mock_loader.rb index 7e1f9ff42..cef4d00f2 100644 --- a/test/helpers/mock_loader.rb +++ b/test/helpers/mock_loader.rb @@ -269,7 +269,7 @@ class MockLoader "rmsock f0000000000000001 tcpcb" => cmd.call("rmsock-f0001"), "rmsock f0000000000000002 tcpcb" => cmd.call("rmsock-f0002"), # packages on windows - "f7718ece69188bb19cd458e2aeab0a8d968f3d40ac2f4199e21cc976f8db5ef6" => cmd.call("get-item-property-package"), + "6785190b3df7291a7622b0b75b0217a9a78bd04690bc978df51ae17ec852a282" => cmd.call("get-item-property-package"), # service status upstart on ubuntu "initctl status ssh" => cmd.call("initctl-status-ssh"), # upstart version on ubuntu From 6923d1d75f1fce129d6122f9e72468928afb09ee Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Tue, 1 Dec 2020 12:51:38 +0000 Subject: [PATCH 14/15] Bump version to 4.23.23 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 6 ++++-- VERSION | 2 +- inspec-bin/lib/inspec-bin/version.rb | 2 +- lib/inspec/version.rb | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 442010d70..2bca9b508 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # Change Log - -## Unreleased + +## [v4.23.23](https://github.com/inspec/inspec/tree/v4.23.23) (2020-12-01) #### Merged Pull Requests +- Drop EOL Ruby 2.4 from testing, Fix Ruby 2.5 Gem build [#5321](https://github.com/inspec/inspec/pull/5321) ([clintoncwolfe](https://github.com/clintoncwolfe)) - Update Ruby to 2.7.2 [#5281](https://github.com/inspec/inspec/pull/5281) ([tas50](https://github.com/tas50)) @@ -17,6 +18,7 @@ - Don't reload plugins if load_all is called repeatedly [#5308](https://github.com/inspec/inspec/pull/5308) ([clintoncwolfe](https://github.com/clintoncwolfe)) #### Merged Pull Requests +- Drop EOL Ruby 2.4 from testing, Fix Ruby 2.5 Gem build [#5321](https://github.com/inspec/inspec/pull/5321) ([clintoncwolfe](https://github.com/clintoncwolfe)) - Update Ruby to 2.7.2 [#5281](https://github.com/inspec/inspec/pull/5281) ([tas50](https://github.com/tas50)) - grub_conf - handle no menuentry config [#5306](https://github.com/inspec/inspec/pull/5306) ([james-stocks](https://github.com/james-stocks)) - Update Codeowners file for Docs [#5298](https://github.com/inspec/inspec/pull/5298) ([mjingle](https://github.com/mjingle)) diff --git a/VERSION b/VERSION index 1415ea7ed..9859b0062 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.23.22 \ No newline at end of file +4.23.23 \ No newline at end of file diff --git a/inspec-bin/lib/inspec-bin/version.rb b/inspec-bin/lib/inspec-bin/version.rb index ca33893f5..80486418f 100644 --- a/inspec-bin/lib/inspec-bin/version.rb +++ b/inspec-bin/lib/inspec-bin/version.rb @@ -1,5 +1,5 @@ # This file managed by automation - do not edit manually module InspecBin INSPECBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "4.23.22".freeze + VERSION = "4.23.23".freeze end diff --git a/lib/inspec/version.rb b/lib/inspec/version.rb index cad2afdd7..0ffbb2716 100644 --- a/lib/inspec/version.rb +++ b/lib/inspec/version.rb @@ -1,3 +1,3 @@ module Inspec - VERSION = "4.23.22".freeze + VERSION = "4.23.23".freeze end From 8a608dac7632290002323cbbfe7f9571b4e5c352 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Tue, 1 Dec 2020 17:19:29 +0000 Subject: [PATCH 15/15] Bump version to 4.23.24 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 8 ++++---- VERSION | 2 +- inspec-bin/lib/inspec-bin/version.rb | 2 +- lib/inspec/version.rb | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bca9b508..3f6ee7cc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,10 @@ # Change Log - -## [v4.23.23](https://github.com/inspec/inspec/tree/v4.23.23) (2020-12-01) + +## [v4.23.24](https://github.com/inspec/inspec/tree/v4.23.24) (2020-12-01) #### Merged Pull Requests -- Drop EOL Ruby 2.4 from testing, Fix Ruby 2.5 Gem build [#5321](https://github.com/inspec/inspec/pull/5321) ([clintoncwolfe](https://github.com/clintoncwolfe)) -- Update Ruby to 2.7.2 [#5281](https://github.com/inspec/inspec/pull/5281) ([tas50](https://github.com/tas50)) +- Fix escaping of Windows package names [#5323](https://github.com/inspec/inspec/pull/5323) ([ramereth](https://github.com/ramereth)) @@ -18,6 +17,7 @@ - Don't reload plugins if load_all is called repeatedly [#5308](https://github.com/inspec/inspec/pull/5308) ([clintoncwolfe](https://github.com/clintoncwolfe)) #### Merged Pull Requests +- Fix escaping of Windows package names [#5323](https://github.com/inspec/inspec/pull/5323) ([ramereth](https://github.com/ramereth)) - Drop EOL Ruby 2.4 from testing, Fix Ruby 2.5 Gem build [#5321](https://github.com/inspec/inspec/pull/5321) ([clintoncwolfe](https://github.com/clintoncwolfe)) - Update Ruby to 2.7.2 [#5281](https://github.com/inspec/inspec/pull/5281) ([tas50](https://github.com/tas50)) - grub_conf - handle no menuentry config [#5306](https://github.com/inspec/inspec/pull/5306) ([james-stocks](https://github.com/james-stocks)) diff --git a/VERSION b/VERSION index 9859b0062..b9dece1b1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.23.23 \ No newline at end of file +4.23.24 \ No newline at end of file diff --git a/inspec-bin/lib/inspec-bin/version.rb b/inspec-bin/lib/inspec-bin/version.rb index 80486418f..90dd76a2b 100644 --- a/inspec-bin/lib/inspec-bin/version.rb +++ b/inspec-bin/lib/inspec-bin/version.rb @@ -1,5 +1,5 @@ # This file managed by automation - do not edit manually module InspecBin INSPECBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "4.23.23".freeze + VERSION = "4.23.24".freeze end diff --git a/lib/inspec/version.rb b/lib/inspec/version.rb index 0ffbb2716..1cccef1f3 100644 --- a/lib/inspec/version.rb +++ b/lib/inspec/version.rb @@ -1,3 +1,3 @@ module Inspec - VERSION = "4.23.23".freeze + VERSION = "4.23.24".freeze end