Sha256: d5199ffa9624e18bdbdb6a28772d9d639f2586cdfbc598bf93805f9418e19322

Contents?: true

Size: 788 Bytes

Versions: 120

Compression:

Stored size: 788 Bytes

Contents

FactoryGirl.define do
  factory :mdm_route, :aliases => [:route], :class => Mdm::Route do
    #
    # Associations
    #
    association :session, :factory => :mdm_session

    netmask { generate :mdm_route_netmask }
    subnet { generate :mdm_route_subnet }
  end

  sequence :mdm_route_netmask do |n|
    bits = 32
    bitmask = n % bits

    [ (~((2 ** (bits - bitmask)) - 1)) & 0xffffffff ].pack('N').unpack('CCCC').join('.')

    bits = 32
    shift = n % bits
    mask_range = 2 ** bits
    full_mask = mask_range - 1

    integer_netmask = (full_mask << shift)
    formatted_netmask = [integer_netmask].pack('N').unpack('CCCC').join('.')

    formatted_netmask
  end

  sequence :mdm_route_subnet do |n|
    class_c_network = n % 255

    "192.168.#{class_c_network}.0"
  end


end

Version data entries

120 entries across 120 versions & 1 rubygems

Version Path
metasploit_data_models-2.0.17 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.16 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.15 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.14 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.13 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.12 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.11 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.10 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.9 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.8 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.7 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.6 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.5 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.4 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.1 spec/factories/mdm/routes.rb
metasploit_data_models-2.0.0 spec/factories/mdm/routes.rb
metasploit_data_models-1.3.0 spec/factories/mdm/routes.rb
metasploit_data_models-1.2.11 spec/factories/mdm/routes.rb
metasploit_data_models-1.2.10 spec/factories/mdm/routes.rb
metasploit_data_models-1.2.9 spec/factories/mdm/routes.rb