metasploit_data_models 0.17.3 → 0.18.0.pre.compatibility
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CONTRIBUTING.md +164 -0
- data/README.md +6 -2
- data/app/models/mdm/host.rb +18 -0
- data/app/models/mdm/service.rb +12 -1
- data/app/models/metasploit_data_models/search/operation/port/number.rb +25 -0
- data/app/models/metasploit_data_models/search/operation/port/range.rb +79 -0
- data/app/models/metasploit_data_models/search/operation/range.rb +56 -0
- data/app/models/metasploit_data_models/search/operator/multitext.rb +73 -0
- data/app/models/metasploit_data_models/search/operator/port/list.rb +67 -0
- data/app/models/metasploit_data_models/search/visitor/attribute.rb +2 -1
- data/app/models/metasploit_data_models/search/visitor/includes.rb +3 -2
- data/app/models/metasploit_data_models/search/visitor/joins.rb +5 -3
- data/app/models/metasploit_data_models/search/visitor/method.rb +3 -2
- data/app/models/metasploit_data_models/search/visitor/where.rb +8 -2
- data/config/locales/en.yml +17 -1
- data/lib/metasploit_data_models.rb +1 -9
- data/lib/metasploit_data_models/version.rb +29 -6
- data/metasploit_data_models.gemspec +2 -2
- data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +41 -0
- data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +140 -0
- data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +235 -0
- data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +162 -0
- data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +164 -0
- data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +48 -26
- data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +10 -7
- data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +44 -30
- data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +16 -0
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +273 -65
- data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +42 -2
- data/spec/factories/mdm/services.rb +1 -2
- data/spec/lib/metasploit_data_models/version_spec.rb +141 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +1 -1
- metadata +27 -11
- data/lib/metasploit_data_models/models.rb +0 -21
- data/lib/metasploit_data_models/validators.rb +0 -19
@@ -30,12 +30,14 @@ describe MetasploitDataModels::Search::Visitor::Where do
|
|
30
30
|
|
31
31
|
arel_class_by_group_class = {
|
32
32
|
Metasploit::Model::Search::Group::Intersection => Arel::Nodes::And,
|
33
|
-
Metasploit::Model::Search::Group::Union => Arel::Nodes::Or
|
33
|
+
Metasploit::Model::Search::Group::Union => Arel::Nodes::Or,
|
34
|
+
Metasploit::Model::Search::Operation::Group::Intersection => Arel::Nodes::And,
|
35
|
+
Metasploit::Model::Search::Operation::Group::Union => Arel::Nodes::Or
|
34
36
|
}
|
35
37
|
|
36
38
|
arel_class_by_group_class.each do |group_class, arel_class|
|
37
39
|
context "with #{group_class}" do
|
38
|
-
it_should_behave_like 'MetasploitDataModels::Search::Visitor::Where#visit with Metasploit::Model::Search
|
40
|
+
it_should_behave_like 'MetasploitDataModels::Search::Visitor::Where#visit with Metasploit::Model::Search*::Group::Base',
|
39
41
|
:arel_class => arel_class do
|
40
42
|
let(:node_class) do
|
41
43
|
group_class
|
@@ -97,6 +99,44 @@ describe MetasploitDataModels::Search::Visitor::Where do
|
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
102
|
+
context 'with MetasploitDataModels::Search::Operation::Port::Range' do
|
103
|
+
let(:node) {
|
104
|
+
MetasploitDataModels::Search::Operation::Port::Range.new(
|
105
|
+
operator: operator,
|
106
|
+
value: value
|
107
|
+
)
|
108
|
+
}
|
109
|
+
|
110
|
+
let(:operator) {
|
111
|
+
MetasploitDataModels::Search::Operator::Port::List.new(
|
112
|
+
klass: Mdm::Service
|
113
|
+
)
|
114
|
+
}
|
115
|
+
|
116
|
+
let(:range) {
|
117
|
+
1..2
|
118
|
+
}
|
119
|
+
|
120
|
+
let(:value) {
|
121
|
+
"#{range.begin}-#{range.end}"
|
122
|
+
}
|
123
|
+
|
124
|
+
it 'should visit operation.operator with attribute_visitor' do
|
125
|
+
expect(visitor.attribute_visitor).to receive(:visit).with(operator).and_call_original
|
126
|
+
|
127
|
+
visit
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should call in on Arel::Attributes::Attribute from attribute_visitor' do
|
131
|
+
attribute = double('Visited Operator')
|
132
|
+
allow(visitor.attribute_visitor).to receive(:visit).with(operator).and_return(attribute)
|
133
|
+
|
134
|
+
expect(attribute).to receive(:in).with(range)
|
135
|
+
|
136
|
+
visit
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
100
140
|
context 'with Metasploit::Model::Search::Query#tree' do
|
101
141
|
let(:node) do
|
102
142
|
query.tree
|
@@ -9,14 +9,13 @@ FactoryGirl.define do
|
|
9
9
|
# Attributes
|
10
10
|
#
|
11
11
|
name { generate :mdm_service_name }
|
12
|
-
port
|
12
|
+
port { generate :port }
|
13
13
|
proto 'snmp'
|
14
14
|
state 'open'
|
15
15
|
|
16
16
|
factory :web_service do
|
17
17
|
proto 'tcp'
|
18
18
|
name { FactoryGirl.generate(:web_service_name) }
|
19
|
-
port { FactoryGirl.generate(:port) }
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MetasploitDataModels::Version do
|
4
|
+
context 'CONSTANTS' do
|
5
|
+
context 'MAJOR' do
|
6
|
+
subject(:major) do
|
7
|
+
described_class::MAJOR
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'is 0 because the API is not locked yet' do
|
11
|
+
expect(major).to eq(0)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'MINOR' do
|
16
|
+
subject(:minor) do
|
17
|
+
described_class::MINOR
|
18
|
+
end
|
19
|
+
|
20
|
+
it { should be_a Integer }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'PATCH' do
|
24
|
+
subject(:patch) do
|
25
|
+
described_class::PATCH
|
26
|
+
end
|
27
|
+
|
28
|
+
it { should be_a Integer }
|
29
|
+
end
|
30
|
+
|
31
|
+
pull_request = ENV['TRAVIS_PULL_REQUEST']
|
32
|
+
|
33
|
+
# a pull request cannot check PRERELEASE because it will be tested in the target branch, but the source itself
|
34
|
+
# is from the source branch and so has the source branch PRERELEASE.
|
35
|
+
#
|
36
|
+
# PRERELEASE can only be set appropriately for a merge by merging to the target branch and then updating PRERELEASE
|
37
|
+
# on the target branch before committing and/or pushing to github and travis-ci.
|
38
|
+
if pull_request.nil? || pull_request == 'false'
|
39
|
+
context 'PREPRELEASE' do
|
40
|
+
subject(:prerelease) do
|
41
|
+
described_class::PRERELEASE
|
42
|
+
end
|
43
|
+
|
44
|
+
branch = ENV['TRAVIS_BRANCH']
|
45
|
+
|
46
|
+
if branch.blank?
|
47
|
+
branch = `git rev-parse --abbrev-ref HEAD`.strip
|
48
|
+
end
|
49
|
+
|
50
|
+
if branch == 'master'
|
51
|
+
it 'does not have a PRERELEASE' do
|
52
|
+
expect(defined? described_class::PRERELEASE).to be_nil
|
53
|
+
end
|
54
|
+
else
|
55
|
+
branch_regex = /\A(?<type>bug|chore|feature|staging)(\/(?<story>[^\/]+))?\/(?<prerelease>[^\/]+)\z/
|
56
|
+
match = branch.match(branch_regex)
|
57
|
+
|
58
|
+
if match
|
59
|
+
it 'matches the branch relative name' do
|
60
|
+
expect(prerelease).to eq(match[:prerelease])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
tag_regex = /\Av(?<major>\d+).(?<minor>\d+).(?<patch>\d+)(\.pre\.(?<prerelease>.*))?\z/
|
64
|
+
# travis-ci sets TRAVIS_BRANCH to the tag name for tag builds
|
65
|
+
match = branch.match(tag_regex)
|
66
|
+
|
67
|
+
if match
|
68
|
+
tag_prerelease = match[:prerelease]
|
69
|
+
|
70
|
+
if tag_prerelease
|
71
|
+
it 'matches the tag prerelease converted from a gem version to a VERSION' do
|
72
|
+
expect(prerelease).to eq(tag_prerelease.gsub('.pre.', '-'))
|
73
|
+
end
|
74
|
+
else
|
75
|
+
it 'does not have a PRERELEASE' do
|
76
|
+
expect(defined? described_class::PRERELEASE).to be_nil
|
77
|
+
end
|
78
|
+
end
|
79
|
+
else
|
80
|
+
it 'has a abbreviated reference that can be parsed for prerelease' do
|
81
|
+
fail "Do not know how to parse #{branch.inspect} for PRERELEASE"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'full' do
|
91
|
+
subject(:full) do
|
92
|
+
described_class.full
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
# lets
|
97
|
+
#
|
98
|
+
|
99
|
+
let(:major) do
|
100
|
+
1
|
101
|
+
end
|
102
|
+
|
103
|
+
let(:minor) do
|
104
|
+
2
|
105
|
+
end
|
106
|
+
|
107
|
+
let(:patch) do
|
108
|
+
3
|
109
|
+
end
|
110
|
+
|
111
|
+
before(:each) do
|
112
|
+
stub_const("#{described_class}::MAJOR", major)
|
113
|
+
stub_const("#{described_class}::MINOR", minor)
|
114
|
+
stub_const("#{described_class}::PATCH", patch)
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'with PRERELEASE' do
|
118
|
+
let(:prerelease) do
|
119
|
+
'prerelease'
|
120
|
+
end
|
121
|
+
|
122
|
+
before(:each) do
|
123
|
+
stub_const("#{described_class}::PRERELEASE", prerelease)
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'is <major>.<minor>.<patch>-<prerelease>' do
|
127
|
+
expect(full).to eq("#{major}.#{minor}.#{patch}-#{prerelease}")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'without PRERELEASE' do
|
132
|
+
before(:each) do
|
133
|
+
hide_const("#{described_class}::PRERELEASE")
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'is <major>.<minor>.<patch>' do
|
137
|
+
expect(full).to eq("#{major}.#{minor}.#{patch}")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
shared_examples_for 'MetasploitDataModels::Search::Visitor::Where#visit with Metasploit::Model::Search
|
1
|
+
shared_examples_for 'MetasploitDataModels::Search::Visitor::Where#visit with Metasploit::Model::Search*::Group::Base' do |options={}|
|
2
2
|
options.assert_valid_keys(:arel_class)
|
3
3
|
|
4
4
|
arel_class = options.fetch(:arel_class)
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metasploit_data_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0.pre.compatibility
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Huckins
|
8
8
|
- Luke Imhoff
|
9
9
|
- David 'thelightcosine' Maloney
|
10
|
-
- Trevor Rosen
|
10
|
+
- Trevor 'burlyscudd' Rosen
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|
@@ -109,20 +109,20 @@ dependencies:
|
|
109
109
|
requirements:
|
110
110
|
- - ! '>='
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.
|
112
|
+
version: 0.25.1
|
113
113
|
- - <
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
version: '0.
|
115
|
+
version: '0.26'
|
116
116
|
type: :runtime
|
117
117
|
prerelease: false
|
118
118
|
version_requirements: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
120
|
- - ! '>='
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: 0.
|
122
|
+
version: 0.25.1
|
123
123
|
- - <
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: '0.
|
125
|
+
version: '0.26'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: redcarpet
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- .simplecov
|
170
170
|
- .travis.yml
|
171
171
|
- .yardopts
|
172
|
+
- CONTRIBUTING.md
|
172
173
|
- Gemfile
|
173
174
|
- LICENSE
|
174
175
|
- README.md
|
@@ -220,6 +221,11 @@ files:
|
|
220
221
|
- app/models/mdm/wmap_request.rb
|
221
222
|
- app/models/mdm/wmap_target.rb
|
222
223
|
- app/models/mdm/workspace.rb
|
224
|
+
- app/models/metasploit_data_models/search/operation/port/number.rb
|
225
|
+
- app/models/metasploit_data_models/search/operation/port/range.rb
|
226
|
+
- app/models/metasploit_data_models/search/operation/range.rb
|
227
|
+
- app/models/metasploit_data_models/search/operator/multitext.rb
|
228
|
+
- app/models/metasploit_data_models/search/operator/port/list.rb
|
223
229
|
- app/models/metasploit_data_models/search/visitor/attribute.rb
|
224
230
|
- app/models/metasploit_data_models/search/visitor/includes.rb
|
225
231
|
- app/models/metasploit_data_models/search/visitor/joins.rb
|
@@ -346,11 +352,9 @@ files:
|
|
346
352
|
- lib/metasploit_data_models/base64_serializer.rb
|
347
353
|
- lib/metasploit_data_models/change_required_columns_to_null_false.rb
|
348
354
|
- lib/metasploit_data_models/engine.rb
|
349
|
-
- lib/metasploit_data_models/models.rb
|
350
355
|
- lib/metasploit_data_models/search.rb
|
351
356
|
- lib/metasploit_data_models/search/visitor.rb
|
352
357
|
- lib/metasploit_data_models/serialized_prefs.rb
|
353
|
-
- lib/metasploit_data_models/validators.rb
|
354
358
|
- lib/metasploit_data_models/version.rb
|
355
359
|
- lib/tasks/yard.rake
|
356
360
|
- metasploit_data_models.gemspec
|
@@ -402,6 +406,11 @@ files:
|
|
402
406
|
- spec/app/models/mdm/wmap_request_spec.rb
|
403
407
|
- spec/app/models/mdm/wmap_target_spec.rb
|
404
408
|
- spec/app/models/mdm/workspace_spec.rb
|
409
|
+
- spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb
|
410
|
+
- spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb
|
411
|
+
- spec/app/models/metasploit_data_models/search/operation/range_spec.rb
|
412
|
+
- spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb
|
413
|
+
- spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb
|
405
414
|
- spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb
|
406
415
|
- spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb
|
407
416
|
- spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb
|
@@ -491,6 +500,7 @@ files:
|
|
491
500
|
- spec/factories/mdm/web_vulns.rb
|
492
501
|
- spec/factories/mdm/workspaces.rb
|
493
502
|
- spec/lib/base64_serializer_spec.rb
|
503
|
+
- spec/lib/metasploit_data_models/version_spec.rb
|
494
504
|
- spec/spec_helper.rb
|
495
505
|
- spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb
|
496
506
|
- spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb
|
@@ -515,9 +525,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
515
525
|
version: '0'
|
516
526
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
517
527
|
requirements:
|
518
|
-
- - ! '
|
528
|
+
- - ! '>'
|
519
529
|
- !ruby/object:Gem::Version
|
520
|
-
version:
|
530
|
+
version: 1.3.1
|
521
531
|
requirements: []
|
522
532
|
rubyforge_project:
|
523
533
|
rubygems_version: 2.2.2
|
@@ -572,6 +582,11 @@ test_files:
|
|
572
582
|
- spec/app/models/mdm/wmap_request_spec.rb
|
573
583
|
- spec/app/models/mdm/wmap_target_spec.rb
|
574
584
|
- spec/app/models/mdm/workspace_spec.rb
|
585
|
+
- spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb
|
586
|
+
- spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb
|
587
|
+
- spec/app/models/metasploit_data_models/search/operation/range_spec.rb
|
588
|
+
- spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb
|
589
|
+
- spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb
|
575
590
|
- spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb
|
576
591
|
- spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb
|
577
592
|
- spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb
|
@@ -661,6 +676,7 @@ test_files:
|
|
661
676
|
- spec/factories/mdm/web_vulns.rb
|
662
677
|
- spec/factories/mdm/workspaces.rb
|
663
678
|
- spec/lib/base64_serializer_spec.rb
|
679
|
+
- spec/lib/metasploit_data_models/version_spec.rb
|
664
680
|
- spec/spec_helper.rb
|
665
681
|
- spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb
|
666
682
|
- spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'metasploit_data_models/validators'
|
2
|
-
|
3
|
-
module MetasploitDataModels
|
4
|
-
module Models
|
5
|
-
include MetasploitDataModels::Validators
|
6
|
-
|
7
|
-
def models_pathname
|
8
|
-
app_pathname.join('models')
|
9
|
-
end
|
10
|
-
|
11
|
-
def require_models
|
12
|
-
autoload_validators
|
13
|
-
|
14
|
-
models_globs = models_pathname.join('**', '*.rb')
|
15
|
-
|
16
|
-
Dir.glob(models_globs) do |model_path|
|
17
|
-
require model_path
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module MetasploitDataModels
|
2
|
-
module Validators
|
3
|
-
# Mimics behavior of `app/validators` in Rails projects by adding it to
|
4
|
-
# `ActiveSupport::Dependencies.autoload_paths` if it is not already in the Array.
|
5
|
-
#
|
6
|
-
# @return [void]
|
7
|
-
def autoload_validators
|
8
|
-
validators_path = validators_pathname.to_s
|
9
|
-
|
10
|
-
unless ActiveSupport::Dependencies.autoload_paths.include? validators_path
|
11
|
-
ActiveSupport::Dependencies.autoload_paths << validators_path
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def validators_pathname
|
16
|
-
app_pathname.join('validators')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|