metasploit_data_models 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e3831b7d870ff2f6137158b6b3834424a60d6e6
4
- data.tar.gz: 203a3c40853109a9c1f2b66c45d278c1eb42345b
3
+ metadata.gz: d898095525d403883a5352fb14f2efff85903028
4
+ data.tar.gz: 434cff7ec8f7c9ee4193113c0a060bb3d4203679
5
5
  SHA512:
6
- metadata.gz: 70986e57992f2d364bb3fc1ec81267f889529877f4a2795245af315ad3d12b339a353fab8d81e1f96104af9c6581037babbe50874f33289aee936e5b79b6a54d
7
- data.tar.gz: b99e4c92772eaf4223d2a6e68c0693a675d99268382287a8eeaad21c818361b3e13b4d5421793abbd19badf589378a0c26871f629f815c6e4733dac3abdf2675
6
+ metadata.gz: e64b1d46d9ad49a17d9a54c2c0bf7f9f59f3a5e24f78792e35fe6d4c7c2f7ba1445b3a8672c10b19713f121705d3d4c04dbf5ccf17ee724be7fabc86a02292f3
7
+ data.tar.gz: e0740f66d27b750de959950aa422864c81d64f28aac7ec8b3d0cd13db31bb7e378e70d926b4c9ad6d1c8c811cf7215fe12ba00b317df2aa58df4026e77f70a3c
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -61,6 +61,21 @@ class Mdm::Host < ActiveRecord::Base
61
61
  'unknown'
62
62
  ]
63
63
 
64
+ # Valid MAC address value
65
+ #hyphen-separated: 1a-2B-3c-4D-5e-6f
66
+ MAC_ADDRESS_HYPHEN_REGEX = /\A(?:[A-F0-9]{2}[-]){5}[A-F0-9]{2}\z/i
67
+
68
+ #colon-separated: 1a:2B:3c:4D:5e:6f
69
+ MAC_ADDRESS_COLON_REGEX = /\A(?:[A-F0-9]{2}[:]){5}[A-F0-9]{2}\z/i
70
+
71
+ #XXX for now, allow en empty MAC so as not to break things that exist with
72
+ # empty MACs.
73
+ MAC_ADDRESS_EMPTY_REGEX = /\A\z/
74
+
75
+ # 6-tuple of hex (case-insensitive) doublets (or empty)
76
+ MAC_ADDRESS_REGEX = Regexp.union(MAC_ADDRESS_HYPHEN_REGEX, MAC_ADDRESS_COLON_REGEX,
77
+ MAC_ADDRESS_EMPTY_REGEX)
78
+
64
79
  #
65
80
  # Aggregations
66
81
  #
@@ -474,6 +489,13 @@ class Mdm::Host < ActiveRecord::Base
474
489
  :inclusion => {
475
490
  :in => ARCHITECTURES
476
491
  }
492
+
493
+ validates :mac,
494
+ :format => {
495
+ :with => MAC_ADDRESS_REGEX,
496
+ :message => 'must be a valid MAC address'
497
+ }
498
+
477
499
  validates :state,
478
500
  :allow_nil => true,
479
501
  :inclusion => {
@@ -1,6 +1,6 @@
1
1
  module MetasploitDataModels
2
2
  # VERSION is managed by GemRelease
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
 
5
5
  # @return [String]
6
6
  #
@@ -55,6 +55,29 @@ RSpec.describe Mdm::Host, type: :model do
55
55
  it { is_expected.to eq(0.84) }
56
56
  end
57
57
 
58
+ describe 'MAC address format validation' do
59
+ context 'when colon delimited' do
60
+ it 'is valid' do
61
+ host = FactoryGirl.build(:mdm_host, mac: '1a:2B:3c:4D:5e:6f')
62
+ expect(host).to be_valid
63
+ end
64
+ end
65
+
66
+ context 'when hyphen delimited' do
67
+ it 'is valid' do
68
+ host = FactoryGirl.build(:mdm_host, mac: '1a-2B-3c-4D-5e-6f')
69
+ expect(host).to be_valid
70
+ end
71
+ end
72
+
73
+ context 'when mixed colon-hyphen delimited ' do
74
+ it 'is invalid' do
75
+ host = FactoryGirl.build(:mdm_host, mac: '1a:2B:3c-4D:5e:6f')
76
+ expect(host).to be_invalid
77
+ end
78
+ end
79
+ end
80
+
58
81
  context '#destroy' do
59
82
  it 'should successfully destroy the object and the dependent objects' do
60
83
  host = FactoryGirl.create(:mdm_host)
@@ -10,13 +10,13 @@ FactoryGirl.define do
10
10
  #
11
11
  address { generate :mdm_ipv4_address }
12
12
  name { generate :mdm_host_name }
13
+ mac { generate :mdm_host_mac }
13
14
 
14
15
  factory :full_mdm_host do
15
16
  arch { generate :mdm_host_arch }
16
17
  comm { generate :mdm_host_comm }
17
18
  comments { generate :mdm_host_comments }
18
19
  info { generate :mdm_host_info }
19
- mac { generate :mdm_host_mac }
20
20
  os_flavor { generate :mdm_host_os_flavor }
21
21
  os_lang { generate :mdm_host_os_lang }
22
22
  os_name { generate :mdm_host_os_name }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metasploit_data_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Huckins
@@ -88,7 +88,7 @@ cert_chain:
88
88
  2SpuQH+SWteq3NXkAmFEEqvLJQ4sbptZt8OP8ghL3pVAvZNFmww/YVszSkShSzcg
89
89
  QdihYCSEL2drS2cFd50jBeq71sxUtxbv82DUa2b+
90
90
  -----END CERTIFICATE-----
91
- date: 2016-05-13 00:00:00.000000000 Z
91
+ date: 2016-09-21 00:00:00.000000000 Z
92
92
  dependencies:
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: metasploit-yard
metadata.gz.sig CHANGED
Binary file