metasploit_data_models 6.0.8 → 6.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edadba0a0b450002d8aa039191ec2afcd6dce324359d6c1f2d4c26cb22e0fbd8
4
- data.tar.gz: 2b7dfd16ff232695a305baab6da43cc9e491357c14b26b3869da3304a6326d91
3
+ metadata.gz: 74538eeddece124d46bfbc8b75ed8cfbdff4e3817d2d043ce378277085a84be4
4
+ data.tar.gz: 8bdb64d936ab097ed960eafb3e6a4681d8e456ed87a6aa1c6bde7054754590ca
5
5
  SHA512:
6
- metadata.gz: 5c37530d3bae08e462d4d19f9dd90917e9deb9d0498e88386c4f08359d4494dc4f6bc0efa56124c6bb311d3b383a7d439f7cd7b0751dfb7cb2d884295e8bf2d3
7
- data.tar.gz: 5f596df8353893eb8c7cdac0f0176738c05aa8e8156b424b9d79fbd8712526672fce2acad76e915e3ef571d4c2d7301702c8005e246a85ca0c0a0329bde282e3
6
+ metadata.gz: 3155ae51fcf684a115ca902c96987ee867bde52f0017cf790f92e352039e5ab4bceefb300af00c79b068871542527e153ded49699b93493d3ca92d23e8f725c1
7
+ data.tar.gz: '0678de3dff2f00feb24b6b3a0be2adeaa89e716bdcad744a62efb6bca4a521e16767058fc4e14e7b5851c60c5eedf50e6410887d672ed93234d20149a15de7f9'
@@ -49,6 +49,25 @@ class MetasploitDataModels::Search::Visitor::Where
49
49
  attribute.matches(match_value)
50
50
  end
51
51
 
52
+ visit 'Metasploit::Model::Search::Operation::Jsonb' do |operation|
53
+ attribute = attribute_visitor.visit operation.operator
54
+
55
+ begin
56
+ operation_hash = JSON.parse(operation.value)
57
+ left = Arel::Nodes::InfixOperation.new(
58
+ '->>',
59
+ Arel::Nodes.build_quoted(attribute),
60
+ Arel::Nodes.build_quoted(operation_hash.keys[0])
61
+ )
62
+ right ="%#{operation_hash.values[0]}%"
63
+ rescue JSON::ParserError
64
+ left = Arel::Nodes::NamedFunction.new("cast", [attribute.as('text')])
65
+ right ="%#{operation.value}%"
66
+ end
67
+
68
+ left.matches(right)
69
+ end
70
+
52
71
  visit 'MetasploitDataModels::IPAddress::CIDR' do |cidr|
53
72
  cast_to_inet "#{cidr.address}/#{cidr.prefix_length}"
54
73
  end
@@ -1,6 +1,6 @@
1
1
  module MetasploitDataModels
2
2
  # VERSION is managed by GemRelease
3
- VERSION = '6.0.8'
3
+ VERSION = '6.0.9'
4
4
 
5
5
  # @return [String]
6
6
  #
@@ -183,5 +183,49 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Where, type: :model do
183
183
  end
184
184
  end
185
185
  end
186
+
187
+ context 'with MetasploitDataModels::Search::Operation::Jsonb' do
188
+ let(:klass) do
189
+ klass = Class.new(ApplicationRecord)
190
+ Object.const_set('Jsonb', klass)
191
+ klass
192
+ end
193
+
194
+ let(:node) do
195
+ Metasploit::Model::Search::Operation::Jsonb.new(
196
+ :operator => operator,
197
+ :value => value
198
+ )
199
+ end
200
+
201
+ let(:operator) do
202
+ Metasploit::Model::Search::Operator::Attribute.new(
203
+ :klass => klass,
204
+ :attribute => :metadata
205
+ )
206
+ end
207
+
208
+ let(:value) do
209
+ 'adcs_ca:myCA'
210
+ end
211
+
212
+ it 'should visit operation.operator with attribute_visitor' do
213
+ expect(visitor.attribute_visitor).to receive(:visit).with(operator).and_call_original
214
+
215
+ visit
216
+ end
217
+
218
+ it 'should return the expected Arel::Nodes::Matches' do
219
+ attribute = Arel::Attributes::Attribute.new(
220
+ Arel::Table.new(:metasploit_credential_privates),
221
+ 'metadata'
222
+ )
223
+ allow(visitor.attribute_visitor).to receive(:visit).with(operator).and_return(attribute)
224
+
225
+ results = visit
226
+ expect(results).to be_a(Arel::Nodes::Matches)
227
+ expect(results.to_sql).to eq("\"metasploit_credential_privates\".\"metadata\" ->> 'adcs_ca' ILIKE '%myCA%'")
228
+ end
229
+ end
186
230
  end
187
231
  end
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: 6.0.8
4
+ version: 6.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers