From e49afeb6651c3d917644f48a88dd0948017e4b54 Mon Sep 17 00:00:00 2001 From: Mitch Clarke Date: Fri, 9 Jun 2023 16:54:35 +1000 Subject: [PATCH 1/2] Add logic for resources with Id in a lower level --- lib/cfnguardian/compile.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/cfnguardian/compile.rb b/lib/cfnguardian/compile.rb index 1f077bf..56c3e72 100644 --- a/lib/cfnguardian/compile.rb +++ b/lib/cfnguardian/compile.rb @@ -90,8 +90,15 @@ def get_resources @resource_groups.each do |group,resources| resources.each do |resource| if !resource.has_key?('Id') - @errors << "CfnGuardian::NoIdKeyForResourceError - resource: #{resource} in resource group: #{group} doesn't have the `Id:` key" - next + if !resource.has_key?('Hosts') + @errors << "CfnGuardian::NoIdKeyForResourceError - resource: #{resource} in resource group: #{group} doesn't have the `Id:` key" + next + else + if !resource['Hosts'].has_key?('Id') + @errors << "CfnGuardian::NoIdKeyForResourceError - resource: #{resource} in resource group: #{group} doesn't have the `Id:` key" + next + end + end end begin From 63de360a789fd735deb16c7ebb51dd18d98e8b3a Mon Sep 17 00:00:00 2001 From: Mitch Clarke Date: Mon, 19 Jun 2023 15:16:24 +1000 Subject: [PATCH 2/2] Add support for NRPE and HTTP resources --- lib/cfnguardian/compile.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/cfnguardian/compile.rb b/lib/cfnguardian/compile.rb index 56c3e72..96f3717 100644 --- a/lib/cfnguardian/compile.rb +++ b/lib/cfnguardian/compile.rb @@ -94,10 +94,13 @@ def get_resources @errors << "CfnGuardian::NoIdKeyForResourceError - resource: #{resource} in resource group: #{group} doesn't have the `Id:` key" next else - if !resource['Hosts'].has_key?('Id') - @errors << "CfnGuardian::NoIdKeyForResourceError - resource: #{resource} in resource group: #{group} doesn't have the `Id:` key" - next - end + resource['Hosts'].each { |host| + if !host.has_key?('Id') + @errors << "CfnGuardian::NoIdKeyForResourceError - resource: #{resource} in resource group: #{group} doesn't have the `Id:` key" + next + end + } + end end