Sha256: d0d99952139df58479f3aa5039598f6f4afe761ac2965aa43daf569b9894b95a

Contents?: true

Size: 745 Bytes

Versions: 193

Compression:

Stored size: 745 Bytes

Contents

require_relative 'traffic.rb'

class IpPermission
  def initialize(group, ip, ingress, exclusions)
    @group = group
    @ip = ip
    @ingress = ingress
    @exclusions = exclusions
  end

  def traffic
    cidr_traffic + group_traffic
  end

  private
  def port_range
    @ip.protocol == '-1' ? '*' : [@ip.from, @ip.to].uniq.join('-') + '/' + @ip.protocol
  end

  def cidr_traffic
    @ip.ip_ranges
      .select { |range| !@exclusions.match(range)}
      .collect { |range|
      Traffic.new(@ingress, range.cidr_ip, @group.name, port_range)
    }
  end

  def group_traffic
    @ip.groups
      .select { |gp| !@exclusions.match(gp.name)}
      .collect { |gp|
      Traffic.new(@ingress, gp.name, @group.name, port_range)
    }
  end
end

Version data entries

193 entries across 193 versions & 1 rubygems

Version Path
aws_security_viz-0.2.5.pre.alpha.pre.35 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.34 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.33 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.32 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.31 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.30 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.29 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.28 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.27 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.26 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.25 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.24 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.23 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.22 lib/ec2/ip_permission.rb
aws_security_viz-0.2.5.pre.alpha.pre.21 lib/ec2/ip_permission.rb
aws_security_viz-0.2.4 lib/ec2/ip_permission.rb
aws_security_viz-0.2.4.pre.alpha.pre.20 lib/ec2/ip_permission.rb
aws_security_viz-0.2.4.pre.alpha.pre.19 lib/ec2/ip_permission.rb
aws_security_viz-0.2.4.pre.alpha.pre.18 lib/ec2/ip_permission.rb
aws_security_viz-0.2.4.pre.alpha.pre.15 lib/ec2/ip_permission.rb