payload: {"action":"created","issue":{"url":"https://api.github.com/repos/stelligent/cfn_nag/issues/307","repository_url":"https://api.github.com/repos/stelligent/cfn_nag","labels_url":"https://api.github.com/repos/stelligent/cfn_nag/issues/307/labels{/name}","comments_url":"https://api.github.com/repos/stelligent/cfn_nag/issues/307/comments","events_url":"https://api.github.com/repos/stelligent/cfn_nag/issues/307/events","html_url":"https://github.com/stelligent/cfn_nag/issues/307","id":521538321,"node_id":"MDU6SXNzdWU1MjE1MzgzMjE=","number":307,"title":"Trying to raise an Exception if there is no S3::BucketPolicy ","user":{"login":"joaquin386","id":14437027,"node_id":"MDQ6VXNlcjE0NDM3MDI3","avatar_url":"https://avatars0.githubusercontent.com/u/14437027?v=4","gravatar_id":"","url":"https://api.github.com/users/joaquin386","html_url":"https://github.com/joaquin386","followers_url":"https://api.github.com/users/joaquin386/followers","following_url":"https://api.github.com/users/joaquin386/following{/other_user}","gists_url":"https://api.github.com/users/joaquin386/gists{/gist_id}","starred_url":"https://api.github.com/users/joaquin386/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaquin386/subscriptions","organizations_url":"https://api.github.com/users/joaquin386/orgs","repos_url":"https://api.github.com/users/joaquin386/repos","events_url":"https://api.github.com/users/joaquin386/events{/privacy}","received_events_url":"https://api.github.com/users/joaquin386/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2019-11-12T13:03:51Z","updated_at":"2019-11-13T16:25:56Z","closed_at":"2019-11-12T17:22:58Z","author_association":"NONE","body":"I am trying to raise a Fail if there is a AWS::S3::Bucket but no AWS::S3::BucketPolicy.\r\nSo far I get into the Inside Alarm but can not raise an issue to FAIL on AWS::S3::BucketPolicy\r\nIt runs correctly but doesn't show the Fail.\r\nWhat do I need to send back on the part of the \"Inside Alarm\"?\r\n\r\n```\r\n  def audit_impl(cfn_model)\r\n\r\n    s3policy = ''\r\n    violating_buckets = Hash.new\r\n    resources = cfn_model.resources_by_type('AWS::S3::Bucket')\r\n    if !resources.nil?\r\n      puts 'Inside Policy'\r\n      resources_policy = cfn_model.resources_by_type('AWS::S3::BucketPolicy')\r\n      pp resources_policy\r\n      if !resources_policy.empty?\r\n        violating_buckets = resources.select do |bucketpolicy|\r\n          puts 'Inside BucketPolicy'\r\n          begin\r\n            #pp bucketpolicy\r\n            bucketpolicy. policy_document.statement.select do |policy|\r\n              puts policy.effect\r\n              puts policy.condition.bool['aws:SecureTransport']\r\n              if policy.effect == 'Deny' and policy.condition.bool['aws:SecureTransport'] == false\r\n                puts 'Inside if'\r\n                s3policy = true\r\n              end\r\n            end\r\n          rescue\r\n            puts 'Inside Exception'\r\n            s3policy = false\r\n          end\r\n        end\r\n      else\r\n        s3policy = false\r\n      end\r\n    end\r\n\r\n    puts s3policy\r\n    if s3policy\r\n      puts 'Inside No alarm'\r\n      logical_resource_ids = []\r\n    else\r\n      puts 'Inside alarm'\r\n      logical_resource_id = ['BucketPolicy']\r\n      violating_buckets.map(&:logical_resource_id)\r\n    end\r\n\r\n  end\r\n\r\nend\r\n```"},"comment":{"url":"https://api.github.com/repos/stelligent/cfn_nag/issues/comments/553479172","html_url":"https://github.com/stelligent/cfn_nag/issues/307#issuecomment-553479172","issue_url":"https://api.github.com/repos/stelligent/cfn_nag/issues/307","id":553479172,"node_id":"MDEyOklzc3VlQ29tbWVudDU1MzQ3OTE3Mg==","user":{"login":"erickascic","id":5263155,"node_id":"MDQ6VXNlcjUyNjMxNTU=","avatar_url":"https://avatars2.githubusercontent.com/u/5263155?v=4","gravatar_id":"","url":"https://api.github.com/users/erickascic","html_url":"https://github.com/erickascic","followers_url":"https://api.github.com/users/erickascic/followers","following_url":"https://api.github.com/users/erickascic/following{/other_user}","gists_url":"https://api.github.com/users/erickascic/gists{/gist_id}","starred_url":"https://api.github.com/users/erickascic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erickascic/subscriptions","organizations_url":"https://api.github.com/users/erickascic/orgs","repos_url":"https://api.github.com/users/erickascic/repos","events_url":"https://api.github.com/users/erickascic/events{/privacy}","received_events_url":"https://api.github.com/users/erickascic/received_events","type":"User","site_admin":false},"created_at":"2019-11-13T16:25:56Z","updated_at":"2019-11-13T16:25:56Z","author_association":"CONTRIBUTOR","body":"@joaquin386 are you sure this code does what you want?  if you want to find all buckets without a matching bucket policy resource..... i'd expect to generate a set of all \"bucket\" attributes in S3::BucketPolicy resources, and compare that to the set of S3::Bucket resources - with some magic to deal with Ref and the like."}}
other: {"actor":{"display_login":"erickascic"}}