metasploit_data_models 0.16.7-java → 0.16.8-java
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/app/models/mdm/service.rb +9 -0
- data/app/models/mdm/vuln.rb +1 -0
- data/lib/metasploit_data_models/version.rb +1 -1
- data/spec/app/models/mdm/service_spec.rb +41 -0
- data/spec/app/models/mdm/vuln_spec.rb +13 -0
- metadata +2 -2
data/Gemfile
CHANGED
@@ -14,6 +14,8 @@ group :development, :test do
|
|
14
14
|
# restrict from rails 4.0 as it requires protected_attributes gem and other changes for compatibility
|
15
15
|
# @see https://www.pivotaltracker.com/story/show/52309083
|
16
16
|
gem 'rails', '>= 3.2', '< 4.0.0'
|
17
|
+
# Used to create fake data
|
18
|
+
gem "faker"
|
17
19
|
end
|
18
20
|
|
19
21
|
group :test do
|
data/app/models/mdm/service.rb
CHANGED
@@ -131,6 +131,15 @@ class Mdm::Service < ActiveRecord::Base
|
|
131
131
|
])
|
132
132
|
}
|
133
133
|
|
134
|
+
#
|
135
|
+
# Validations
|
136
|
+
#
|
137
|
+
validates :port,
|
138
|
+
numericality: {
|
139
|
+
only_integer: true
|
140
|
+
}
|
141
|
+
validates :proto, presence: true
|
142
|
+
|
134
143
|
# {Mdm::Host::OperatingSystemNormalization#normalize_os Normalizes the host operating system} whenever {#info} has
|
135
144
|
# changed.
|
136
145
|
#
|
data/app/models/mdm/vuln.rb
CHANGED
@@ -4,5 +4,5 @@ module MetasploitDataModels
|
|
4
4
|
# metasploit-framework/data/sql/migrate to db/migrate in this project, not all models have specs that verify the
|
5
5
|
# migrations (with have_db_column and have_db_index) and certain models may not be shared between metasploit-framework
|
6
6
|
# and pro, so models may be removed in the future. Because of the unstable API the version should remain below 1.0.0
|
7
|
-
VERSION = '0.16.
|
7
|
+
VERSION = '0.16.8'
|
8
8
|
end
|
@@ -96,4 +96,45 @@ describe Mdm::Service do
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
+
context "validations" do
|
100
|
+
let(:mdm_service) do
|
101
|
+
mdm_service = FactoryGirl.build(:mdm_service)
|
102
|
+
mdm_service.valid?
|
103
|
+
mdm_service
|
104
|
+
end
|
105
|
+
|
106
|
+
context "invalid" do
|
107
|
+
it "should validate presence of :port" do
|
108
|
+
mdm_service.port = nil
|
109
|
+
mdm_service.valid?
|
110
|
+
mdm_service.errors[:port][0].should include "is not a number"
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should validate presence of :proto" do
|
114
|
+
mdm_service.proto = nil
|
115
|
+
mdm_service.valid?
|
116
|
+
mdm_service.errors[:proto][0].should include "can't be blank"
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should not allow non-numeric value for port" do
|
120
|
+
mdm_service.port = Faker::Lorem.characters(4)
|
121
|
+
mdm_service.valid?
|
122
|
+
mdm_service.errors[:port][0].should include "is not a number"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "valid" do
|
127
|
+
it "should allow numeric value for port" do
|
128
|
+
mdm_service.port = Faker::Number.number(4)
|
129
|
+
mdm_service.valid?
|
130
|
+
mdm_service.should have(0).errors_on(:port)
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should allow proto" do
|
134
|
+
mdm_service.proto = "tcp"
|
135
|
+
mdm_service.valid?
|
136
|
+
mdm_service.should have(0).errors_on(:proto)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
99
140
|
end
|
@@ -258,5 +258,18 @@ describe Mdm::Vuln do
|
|
258
258
|
|
259
259
|
context 'validations' do
|
260
260
|
it { should validate_presence_of :name }
|
261
|
+
|
262
|
+
context "invalid" do
|
263
|
+
let(:mdm_vuln) do
|
264
|
+
FactoryGirl.build(:mdm_vuln)
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should not allow :name over 255 characters" do
|
268
|
+
str = Faker::Lorem.characters(256)
|
269
|
+
mdm_vuln.name = str
|
270
|
+
mdm_vuln.valid?
|
271
|
+
mdm_vuln.errors[:name][0].should include "is too long"
|
272
|
+
end
|
273
|
+
end
|
261
274
|
end
|
262
275
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: metasploit_data_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.16.
|
5
|
+
version: 0.16.8
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Samuel Huckins
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-
|
15
|
+
date: 2013-12-12 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|