metasploit_data_models 0.21.3-java → 0.22.1-java

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: d11998218afd52a63a8d7805857fb8ec4ed0a675
4
- data.tar.gz: cb54f6b261e068f2d98ffcf2021f3e2f762a022c
3
+ metadata.gz: ad658aa19508e799c82bf3ebd6fb07e31faa89ac
4
+ data.tar.gz: 3b2b424d52229202fbada93525a4e51c24a909ef
5
5
  SHA512:
6
- metadata.gz: b422d4bddff84eff324abf564b2ef7aced4eaf33e2ba577afd3ac0da6032e53000bf6fe4a44d3d0a82ca141ce429206a83780ba6ad2406cd5487e618b8c5c51a
7
- data.tar.gz: 66b99190854648ad22caf0ca9c84ce33a1da8f38d4633d202839925bd8d542f2bac442a35772c303d938b96270df8a9fc307a0d58e342d544c190c440d9e17fe
6
+ metadata.gz: 21888e5aaae09007d205ca7c872ab6d119b5bb17f07ca40e464daa589de1478ed73d74fd7a6c2d92049520204ea33f1786acbb6c0d394fe5d0f793cc9efe88c7
7
+ data.tar.gz: b996c42af0964622b11726314feec9ca39a0641723a19f7e097f02b0ad5c4ee72e998dc7cab4c79eab9d74561d4cb8c7cee619cfa6e91327ff4f02714c7ab891
@@ -222,6 +222,15 @@ class Mdm::Service < ActiveRecord::Base
222
222
  in: PROTOS
223
223
  }
224
224
 
225
+ validates :host_id,
226
+ uniqueness: {
227
+ message: 'already has a service with this port and proto',
228
+ scope: [
229
+ :port,
230
+ :proto
231
+ ]
232
+ }
233
+
225
234
  #
226
235
  # Class Methods
227
236
  #
@@ -103,11 +103,7 @@ class Mdm::Task < ActiveRecord::Base
103
103
  has_many :sessions, :through => :task_sessions, :class_name => 'Mdm::Session'
104
104
 
105
105
 
106
- #
107
- # Scopes
108
- #
109
106
 
110
- scope :running, order( "created_at DESC" ).where("completed_at IS NULL")
111
107
 
112
108
  #
113
109
  # Serializations
@@ -0,0 +1,12 @@
1
+ class RemoveDuplicateServices < ActiveRecord::Migration
2
+ def change
3
+ duplicate_keys = Mdm::Service.count(group: [:host_id, :port, :proto]).select { |k,v| v >1 }.keys
4
+ duplicate_keys.each do |keys|
5
+ duplicate_services = Mdm::Service.where(host_id: keys[0], port: keys[1], proto: keys[2]).order(:created_at)
6
+ duplicate_services.pop
7
+ duplicate_services.each(&:destroy)
8
+ end
9
+
10
+ add_index :services, [:host_id, :port, :proto], unique: true
11
+ end
12
+ end
@@ -4,9 +4,9 @@ module MetasploitDataModels
4
4
  # The major version number.
5
5
  MAJOR = 0
6
6
  # The minor version number, scoped to the {MAJOR} version number.
7
- MINOR = 21
7
+ MINOR = 22
8
8
  # The patch number, scoped to the {MINOR} version number.
9
- PATCH = 3
9
+ PATCH = 1
10
10
 
11
11
  # The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the `PRERELEASE` in the
12
12
  # {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
@@ -153,5 +153,13 @@ describe Mdm::Service do
153
153
 
154
154
  it { should validate_numericality_of(:port).only_integer }
155
155
  it { should ensure_inclusion_of(:proto).in_array(described_class::PROTOS) }
156
+
157
+ context 'when a duplicate service already exists' do
158
+ let(:service1) { FactoryGirl.create(:mdm_service)}
159
+ let(:service2) { FactoryGirl.build(:mdm_service, :host => service1.host, :port => service1.port, :proto => service1.proto )}
160
+ it 'is not valid' do
161
+ expect(service2).to_not be_valid
162
+ end
163
+ end
156
164
  end
157
165
  end
@@ -59,15 +59,6 @@ describe Mdm::Task do
59
59
 
60
60
  end
61
61
 
62
- context 'scopes' do
63
- context "running" do
64
- it "should exclude completed tasks" do
65
- task = FactoryGirl.create(:mdm_task, :completed_at => Time.now)
66
- Mdm::Task.running.should_not include(task)
67
- end
68
- end
69
- end
70
-
71
62
  context 'callbacks' do
72
63
  context 'before_destroy' do
73
64
  it 'should call #delete_file' do
@@ -79,4 +70,4 @@ describe Mdm::Task do
79
70
  end
80
71
 
81
72
 
82
- end
73
+ end
@@ -2686,6 +2686,13 @@ CREATE INDEX index_notes_on_ntype ON notes USING btree (ntype);
2686
2686
  CREATE INDEX index_refs_on_name ON refs USING btree (name);
2687
2687
 
2688
2688
 
2689
+ --
2690
+ -- Name: index_services_on_host_id_and_port_and_proto; Type: INDEX; Schema: public; Owner: -; Tablespace:
2691
+ --
2692
+
2693
+ CREATE UNIQUE INDEX index_services_on_host_id_and_port_and_proto ON services USING btree (host_id, port, proto);
2694
+
2695
+
2689
2696
  --
2690
2697
  -- Name: index_services_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace:
2691
2698
  --
@@ -2987,6 +2994,8 @@ INSERT INTO schema_migrations (version) VALUES ('20130717150737');
2987
2994
 
2988
2995
  INSERT INTO schema_migrations (version) VALUES ('20140905031549');
2989
2996
 
2997
+ INSERT INTO schema_migrations (version) VALUES ('20150112203945');
2998
+
2990
2999
  INSERT INTO schema_migrations (version) VALUES ('21');
2991
3000
 
2992
3001
  INSERT INTO schema_migrations (version) VALUES ('22');
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: 0.21.3
4
+ version: 0.22.1
5
5
  platform: java
6
6
  authors:
7
7
  - Samuel Huckins
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-12-20 00:00:00.000000000 Z
14
+ date: 2015-01-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -406,6 +406,7 @@ files:
406
406
  - db/migrate/20130604145732_create_task_sessions.rb
407
407
  - db/migrate/20130717150737_remove_pname_validation.rb
408
408
  - db/migrate/20140905031549_add_detected_arch_to_host.rb
409
+ - db/migrate/20150112203945_remove_duplicate_services.rb
409
410
  - lib/mdm.rb
410
411
  - lib/mdm/host/operating_system_normalization.rb
411
412
  - lib/mdm/module.rb