metasploit-model 0.25.7-java → 0.26.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/metasploit/model/search/operation/association.rb +57 -0
  3. data/app/models/metasploit/model/search/operator/association.rb +24 -14
  4. data/app/models/metasploit/model/search/operator/base.rb +19 -3
  5. data/app/models/metasploit/model/search/operator/single.rb +21 -1
  6. data/app/models/metasploit/model/search/query.rb +20 -1
  7. data/lib/metasploit/model/association/tree.rb +130 -0
  8. data/lib/metasploit/model/search.rb +61 -27
  9. data/lib/metasploit/model/search/association.rb +152 -8
  10. data/lib/metasploit/model/search/attribute.rb +112 -22
  11. data/lib/metasploit/model/search/operator.rb +53 -1
  12. data/lib/metasploit/model/search/operator/help.rb +39 -1
  13. data/lib/metasploit/model/search/with.rb +44 -1
  14. data/lib/metasploit/model/version.rb +2 -2
  15. data/spec/app/models/metasploit/model/search/operation/association_spec.rb +67 -0
  16. data/spec/app/models/metasploit/model/search/operator/association_spec.rb +76 -76
  17. data/spec/app/models/metasploit/model/search/operator/deprecated/author_spec.rb +54 -18
  18. data/spec/app/models/metasploit/model/search/operator/deprecated/authority_spec.rb +20 -8
  19. data/spec/app/models/metasploit/model/search/operator/deprecated/platform_spec.rb +20 -8
  20. data/spec/app/models/metasploit/model/search/operator/deprecated/ref_spec.rb +86 -26
  21. data/spec/app/models/metasploit/model/search/operator/deprecated/text_spec.rb +63 -21
  22. data/spec/lib/metasploit/model/search/association/tree_spec.rb +385 -0
  23. data/spec/lib/metasploit/model/search/association_spec.rb +99 -10
  24. data/spec/lib/metasploit/model/search_spec.rb +48 -107
  25. data/spec/support/shared/examples/search/query/metasploit/model/search/operator/deprecated/authority.rb +19 -7
  26. metadata +8 -2
@@ -5,9 +5,9 @@ module Metasploit
5
5
  # The major version number.
6
6
  MAJOR = 0
7
7
  # The minor version number, scoped to the {MAJOR} version number.
8
- MINOR = 25
8
+ MINOR = 26
9
9
  # The patch number, scoped to the {MINOR} version number.
10
- PATCH = 7
10
+ PATCH = 1
11
11
 
12
12
  # The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
13
13
  # {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metasploit::Model::Search::Operation::Association do
4
+ subject(:operation) {
5
+ described_class.new(
6
+ source_operation: source_operation
7
+ )
8
+ }
9
+
10
+ let(:source_operation) {
11
+ nil
12
+ }
13
+
14
+ context 'validation' do
15
+ before(:each) do
16
+ operation.valid?
17
+ end
18
+
19
+ context 'errors on #source_operation' do
20
+ subject(:source_operation_errors) {
21
+ operation.errors[:source_operation]
22
+ }
23
+
24
+ let(:invalid_error) {
25
+ I18n.translate!('errors.messages.invalid')
26
+ }
27
+
28
+ context 'with #source_operation' do
29
+ let(:source_operation) {
30
+ double('#source_operation', valid?: valid)
31
+ }
32
+
33
+ context 'with valid' do
34
+ let(:valid) {
35
+ true
36
+ }
37
+
38
+ it { should_not include(invalid_error) }
39
+ end
40
+
41
+ context 'without valid' do
42
+ let(:valid) {
43
+ false
44
+ }
45
+
46
+ it { should include(invalid_error) }
47
+ end
48
+ end
49
+
50
+ context 'without #source_operation' do
51
+ let(:blank_error) {
52
+ I18n.translate!('errors.messages.blank')
53
+ }
54
+
55
+ let(:source_operation) {
56
+ nil
57
+ }
58
+
59
+ it { should include(blank_error) }
60
+ it { should_not include(invalid_error) }
61
+ end
62
+ end
63
+ end
64
+
65
+ it { should_not respond_to :value }
66
+ it { should_not respond_to :value= }
67
+ end
@@ -1,108 +1,108 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Metasploit::Model::Search::Operator::Association do
4
- it { should be_a Metasploit::Model::Search::Operator::Single }
4
+ subject(:operator) do
5
+ described_class.new(
6
+ :association => association,
7
+ :source_operator => source_operator
8
+ )
9
+ end
10
+
11
+ let(:association) do
12
+ FactoryGirl.generate :metasploit_model_search_operator_association_association
13
+ end
14
+
15
+ let(:source_operator) do
16
+ double('Metasploit::Model::Search::Operator::Base')
17
+ end
18
+
19
+ it { should be_a Metasploit::Model::Search::Operator::Base }
5
20
 
6
21
  context 'validations' do
7
22
  it { should validate_presence_of(:association) }
8
- it { should validate_presence_of(:attribute_operator) }
23
+ it { should validate_presence_of(:source_operator) }
9
24
  end
10
25
 
11
- context 'delegate :to => attribute_operator' do
12
- let(:association) do
13
- FactoryGirl.generate :metasploit_model_search_operator_association_association
26
+ context '#help' do
27
+ subject(:help) do
28
+ operator.help
14
29
  end
15
30
 
16
- let(:association_operator) do
17
- described_class.new(
18
- :association => association,
19
- :attribute_operator => attribute_operator
20
- )
21
- end
31
+ it 'should delegate to #source_operator' do
32
+ expect(source_operator).to receive(:help)
22
33
 
23
- let(:attribute_operator) do
24
- double('Metasploit::Model::Search::Operator::Attribute')
34
+ help
25
35
  end
36
+ end
26
37
 
27
- context '#attribute' do
28
- subject(:attribute) do
29
- association_operator.attribute
30
- end
31
-
32
- it 'should delegate to #attribute_operator' do
33
- attribute_operator.should_receive(:attribute)
34
-
35
- attribute
36
- end
38
+ context '#name' do
39
+ subject(:name) do
40
+ operator.name
37
41
  end
38
42
 
39
- context '#attribute_set' do
40
- subject(:attribute_set) do
41
- association_operator.attribute_set
42
- end
43
-
44
- it 'should delegate to #attribute_operator' do
45
- attribute_operator.should_receive(:attribute_set)
43
+ let(:source_operator) {
44
+ double(
45
+ 'Metasploit::Model::Search::Operator::Base',
46
+ name: source_operator_name
47
+ )
48
+ }
46
49
 
47
- attribute_set
48
- end
49
- end
50
+ let(:source_operator_name) {
51
+ 'source_operator_name'
52
+ }
50
53
 
51
- context '#help' do
52
- subject(:help) do
53
- association_operator.help
54
- end
55
-
56
- it 'should delegate to #attribute_operator' do
57
- attribute_operator.should_receive(:help)
54
+ it { should be_a Symbol }
58
55
 
59
- help
60
- end
56
+ it 'should be <association>.<source_operator.name>' do
57
+ expect(name).to eq :"#{association}.#{source_operator_name}"
61
58
  end
59
+ end
62
60
 
63
- context '#type' do
64
- subject(:type) do
65
- association_operator.type
66
- end
61
+ context '#operate_on' do
62
+ subject(:operate_on) {
63
+ operator.operate_on(formatted_value)
64
+ }
67
65
 
68
- it 'should delegate to #attribute_operator' do
69
- attribute_operator.should_receive(:type)
66
+ #
67
+ # lets
68
+ #
70
69
 
71
- type
72
- end
73
- end
74
- end
70
+ let(:expected_source_operation) {
71
+ double('source operation')
72
+ }
75
73
 
76
- context '#name' do
77
- subject(:name) do
78
- association_operator.name
79
- end
74
+ let(:formatted_value) {
75
+ 'formatted-value'
76
+ }
80
77
 
81
- let(:association) do
82
- FactoryGirl.generate :metasploit_model_search_operator_association_association
83
- end
78
+ let(:source_operator) {
79
+ super().tap { |source_operator|
80
+ expect(source_operator).to receive(:operate_on).with(formatted_value).and_return(expected_source_operation)
81
+ }
82
+ }
84
83
 
85
- let(:association_operator) do
86
- described_class.new(
87
- :association => association,
88
- :attribute_operator => attribute_operator
89
- )
90
- end
84
+ it { should be_a Metasploit::Model::Search::Operation::Association }
91
85
 
92
- let(:attribute) do
93
- FactoryGirl.generate :metasploit_model_search_operator_attribute_attribute
94
- end
86
+ context 'Metasploit::Model::Search::Operation::Association' do
87
+ context '#operator' do
88
+ subject(:operation_operator) {
89
+ operate_on.operator
90
+ }
95
91
 
96
- let(:attribute_operator) do
97
- Metasploit::Model::Search::Operator::Attribute.new(
98
- :attribute => attribute
99
- )
100
- end
92
+ it 'is this association operator' do
93
+ expect(operation_operator).to eq(operator)
94
+ end
95
+ end
101
96
 
102
- it { should be_a Symbol }
97
+ context '#source_operation' do
98
+ subject(:source_operation) {
99
+ operate_on.source_operation
100
+ }
103
101
 
104
- it 'should be <association>.<attribute>' do
105
- name.to_s.should == "#{association}.#{attribute}"
102
+ it 'is operation from Metasploit::Model::Search::Operator::Association#source_operator' do
103
+ expect(source_operation).to eq(expected_source_operation)
104
+ end
105
+ end
106
106
  end
107
107
  end
108
108
  end
@@ -23,8 +23,8 @@ describe Metasploit::Model::Search::Operator::Deprecated::Author do
23
23
  let(:authors_name_operator) do
24
24
  Metasploit::Model::Search::Operator::Association.new(
25
25
  :association => :authors,
26
- :attribute_operator => name_operator,
27
- :klass => klass
26
+ :klass => klass,
27
+ :source_operator => name_operator
28
28
  )
29
29
  end
30
30
 
@@ -43,16 +43,16 @@ describe Metasploit::Model::Search::Operator::Deprecated::Author do
43
43
  let(:email_addresses_domain_operator) do
44
44
  Metasploit::Model::Search::Operator::Association.new(
45
45
  :association => :email_addresses,
46
- :attribute_operator => domain_operator,
47
- :klass => klass
46
+ :klass => klass,
47
+ :source_operator => domain_operator
48
48
  )
49
49
  end
50
50
 
51
51
  let(:email_addresses_local_operator) do
52
52
  Metasploit::Model::Search::Operator::Association.new(
53
53
  :association => :email_addresses,
54
- :attribute_operator => local_operator,
55
- :klass => klass
54
+ :klass => klass,
55
+ :source_operator => local_operator
56
56
  )
57
57
  end
58
58
 
@@ -96,8 +96,14 @@ describe Metasploit::Model::Search::Operator::Deprecated::Author do
96
96
  child('authors.name')
97
97
  end
98
98
 
99
- it 'should use entire formatted value' do
100
- operation.value.should == formatted_value
99
+ context 'Metasploit::Model::Search::Operation::Association#source_operation' do
100
+ subject(:source_operation) {
101
+ operation.source_operation
102
+ }
103
+
104
+ it 'uses entire formatted value' do
105
+ expect(source_operation.value).to eq(formatted_value)
106
+ end
101
107
  end
102
108
  end
103
109
 
@@ -106,8 +112,14 @@ describe Metasploit::Model::Search::Operator::Deprecated::Author do
106
112
  child('email_addresses.domain')
107
113
  end
108
114
 
109
- it "should use portion of formatted value after '@'" do
110
- operation.value.should == domain
115
+ context 'Metasploit::Model::Search::Operation::Association#source_operation' do
116
+ subject(:source_operation) {
117
+ operation.source_operation
118
+ }
119
+
120
+ it "uses portion of formatted value after '@'" do
121
+ expect(source_operation.value).to eq(domain)
122
+ end
111
123
  end
112
124
  end
113
125
 
@@ -116,8 +128,14 @@ describe Metasploit::Model::Search::Operator::Deprecated::Author do
116
128
  child('email_addresses.local')
117
129
  end
118
130
 
119
- it "should use portion of formated value before '@'" do
120
- operation.value.should == local
131
+ context 'Metasploit::Model::Search::Operation::Association#source_operation' do
132
+ subject(:source_operation) {
133
+ operation.source_operation
134
+ }
135
+
136
+ it "uses portion of formated value before '@'" do
137
+ expect(source_operation.value).to eq(local)
138
+ end
121
139
  end
122
140
  end
123
141
  end
@@ -132,8 +150,14 @@ describe Metasploit::Model::Search::Operator::Deprecated::Author do
132
150
  child('authors.name')
133
151
  end
134
152
 
135
- it 'should use entire formatted value' do
136
- operation.value.should == formatted_value
153
+ context 'Metasploit::Model::Search::Operation::Association#source_operation' do
154
+ subject(:source_operation) {
155
+ operation.source_operation
156
+ }
157
+
158
+ it 'uses entire formatted value' do
159
+ expect(source_operation.value).to eq(formatted_value)
160
+ end
137
161
  end
138
162
  end
139
163
 
@@ -142,8 +166,14 @@ describe Metasploit::Model::Search::Operator::Deprecated::Author do
142
166
  child('email_addresses.domain')
143
167
  end
144
168
 
145
- it 'should use entire formatted value' do
146
- operation.value.should == formatted_value
169
+ context 'Metasploit::Model::Search::Operation::Association#source_operation' do
170
+ subject(:source_operation) {
171
+ operation.source_operation
172
+ }
173
+
174
+ it 'uses entire formatted value' do
175
+ expect(source_operation.value).to eq(formatted_value)
176
+ end
147
177
  end
148
178
  end
149
179
 
@@ -152,8 +182,14 @@ describe Metasploit::Model::Search::Operator::Deprecated::Author do
152
182
  child('email_addresses.local')
153
183
  end
154
184
 
155
- it 'should use entire formatted value' do
156
- operation.value.should == formatted_value
185
+ context 'Metasploit::Model::Search::Operation::Association#source_operation' do
186
+ subject(:source_operation) {
187
+ operation.source_operation
188
+ }
189
+
190
+ it 'uses entire formatted value' do
191
+ expect(source_operation.value).to eq(formatted_value)
192
+ end
157
193
  end
158
194
  end
159
195
  end
@@ -66,8 +66,8 @@ describe Metasploit::Model::Search::Operator::Deprecated::Authority do
66
66
  let(:authorities_abbreviation_operator) do
67
67
  Metasploit::Model::Search::Operator::Association.new(
68
68
  :association => :authorities,
69
- :attribute_operator => abbreviation_operator,
70
- :klass => klass
69
+ :klass => klass,
70
+ :source_operator => abbreviation_operator
71
71
  )
72
72
  end
73
73
 
@@ -90,8 +90,8 @@ describe Metasploit::Model::Search::Operator::Deprecated::Authority do
90
90
  let(:references_designation_operator) do
91
91
  Metasploit::Model::Search::Operator::Association.new(
92
92
  :association => :references,
93
- :attribute_operator => designation_operator,
94
- :klass => klass
93
+ :klass => klass,
94
+ :source_operator => designation_operator
95
95
  )
96
96
  end
97
97
 
@@ -105,8 +105,14 @@ describe Metasploit::Model::Search::Operator::Deprecated::Authority do
105
105
  operation_named('authorities.abbreviation')
106
106
  end
107
107
 
108
- it 'should use #abbrevation for value' do
109
- operation.value.should == abbreviation
108
+ context 'Metasploit::Model::Search::Operation::Association#source_operation' do
109
+ subject(:source_operation) {
110
+ operation.source_operation
111
+ }
112
+
113
+ it 'uses #abbreviation for value' do
114
+ expect(source_operation.value).to eq(abbreviation)
115
+ end
110
116
  end
111
117
  end
112
118
 
@@ -115,8 +121,14 @@ describe Metasploit::Model::Search::Operator::Deprecated::Authority do
115
121
  operation_named('references.designation')
116
122
  end
117
123
 
118
- it 'should use formatted value for value' do
119
- operation.value.should == formatted_value
124
+ context 'Metasploit::Model::Search::Operation::Association#source_operation' do
125
+ subject(:source_operation) {
126
+ operation.source_operation
127
+ }
128
+
129
+ it 'uses formatted value for value' do
130
+ expect(source_operation.value).to eq(formatted_value)
131
+ end
120
132
  end
121
133
  end
122
134
  end