class SecurityGroupEgressPortRangeRule

Public Instance Methods

audit_impl(cfn_model) click to toggle source

This will behave slightly different than the legacy jq based rule which was targeted against inline ingress only

# File lib/cfn-nag/custom_rules/SecurityGroupEgressPortRangeRule.rb, line 22
def audit_impl(cfn_model)
  violating_security_groups = cfn_model.security_groups.select do |security_group|
    violating_egresses = security_group.egresses.select do |egress|
      egress.fromPort != egress.toPort
    end

    !violating_egresses.empty?
  end

  violating_egresses = cfn_model.standalone_egress.select do |standalone_egress|
    standalone_egress.fromPort != standalone_egress.toPort
  end

  violating_security_groups.map(&:logical_resource_id) + violating_egresses.map(&:logical_resource_id)
end
rule_id() click to toggle source
# File lib/cfn-nag/custom_rules/SecurityGroupEgressPortRangeRule.rb, line 15
def rule_id
  'W29'
end
rule_text() click to toggle source
# File lib/cfn-nag/custom_rules/SecurityGroupEgressPortRangeRule.rb, line 7
def rule_text
  'Security Groups found egress with port range instead of just a single port'
end
rule_type() click to toggle source
# File lib/cfn-nag/custom_rules/SecurityGroupEgressPortRangeRule.rb, line 11
def rule_type
  Violation::WARNING
end