diff --git a/lib/inspec/metadata.rb b/lib/inspec/metadata.rb index a6f00c1c2..49c13cbbb 100644 --- a/lib/inspec/metadata.rb +++ b/lib/inspec/metadata.rb @@ -47,7 +47,12 @@ module Inspec def supports_transport?(backend) # make sure the supports field is always an array supp = params[:supports] - supp = [supp] unless supp.is_a?(Array) + supp = supp.is_a?(Hash) ? [supp] : Array(supp) + + # with no supports specified, always return true, as there are no + # constraints on the supported backend; it is equivalent to putting + # all fields into accept-all mode + return true if supp.empty? found = supp.find do |entry| try_support = self.class.symbolize_keys(entry) diff --git a/test/unit/metadata_test.rb b/test/unit/metadata_test.rb index 46853f003..79d73e3a3 100644 --- a/test/unit/metadata_test.rb +++ b/test/unit/metadata_test.rb @@ -20,7 +20,12 @@ describe 'metadata with supported operating systems' do Inspec::Metadata.finalize(res, 'mock') res end - + + it 'load a profile with empty supports clause' do + m = create_meta(nil) + m.supports_transport?(backend).must_equal true + end + it 'loads a profile which supports os ubuntu' do m = create_meta({ 'os' => 'ubuntu' }) m.supports_transport?(backend).must_equal true