Skip to content

Commit 486f8cd

Browse files
committed
adding arch to search
1 parent f669499 commit 486f8cd

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

lib/msf/core/db_manager/module_cache.rb

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -199,28 +199,19 @@ def search_modules(search_string)
199199
ActiveRecord::Base.connection_pool.with_connection do
200200
@query = Mdm::Module::Detail.all
201201

202-
@authors = Set.new
203-
@names = Set.new
204-
@os = Set.new
205-
@text = Set.new
206-
@types = Set.new
207-
@stances = Set.new
208-
@refs = Set.new
202+
@archs = Set.new
203+
@authors = Set.new
204+
@names = Set.new
205+
@os = Set.new
206+
@refs = Set.new
207+
@stances = Set.new
208+
@text = Set.new
209+
@types = Set.new
209210

210211
value_set_by_keyword.each do |keyword, value_set|
211212
formatted_values = match_values(value_set)
212213

213214
case keyword
214-
when 'author'
215-
@authors << formatted_values
216-
when 'name'
217-
@names << formatted_values
218-
when 'os', 'platform'
219-
@os << formatted_values
220-
when 'text'
221-
@text << formatted_values
222-
when 'type'
223-
@types << formatted_values
224215
when 'app'
225216
formatted_values = value_set.collect { |value|
226217
formatted_value = 'aggressive'
@@ -230,13 +221,26 @@ def search_modules(search_string)
230221
formatted_value
231222
}
232223
@stances << formatted_values
224+
when 'arch'
225+
@archs << formatted_values
226+
when 'author'
227+
@authors << formatted_values
228+
when 'name'
229+
@names << formatted_values
230+
when 'os', 'platform'
231+
@os << formatted_values
233232
when 'ref'
234233
@refs << formatted_values
235234
when 'cve', 'bid', 'edb'
236235
formatted_values = value_set.collect { |value|
237236
prefix = keyword.upcase
238237
"#{prefix}-%#{value}%"
239238
}
239+
@refs << formatted_values
240+
when 'text'
241+
@text << formatted_values
242+
when 'type'
243+
@types << formatted_values
240244
end
241245
end
242246

@@ -246,13 +250,14 @@ def search_modules(search_string)
246250
#
247251
# @query = @query.where(unioned_conditions).to_a.uniq { |m| m.fullname }
248252
end
249-
253+
254+
@query = @query.module_arch( @archs.to_a.flatten ) if @archs.any?
250255
@query = @query.module_author( @authors.to_a.flatten ) if @authors.any?
251256
@query = @query.module_name( @names.to_a.flatten ) if @names.any?
252257
@query = @query.module_os_or_platform( @os.to_a.flatten ) if @os.any?
253258
@query = @query.module_text( @text.to_a.flatten ) if @text.any?
254259
@query = @query.module_type( @types.to_a.flatten ) if @types.any?
255-
@query = @query.module_app( @stances.to_a.flatten ) if @stances.any?
260+
@query = @query.module_stance( @stances.to_a.flatten ) if @stances.any?
256261
@query = @query.module_ref( @refs.to_a.flatten ) if @refs.any?
257262

258263
@query.uniq

0 commit comments

Comments
 (0)