File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -150,13 +150,16 @@ def hosts(opts)
150
150
151
151
::ActiveRecord ::Base . connection_pool . with_connection {
152
152
153
+ conditions = { }
154
+ conditions [ :state ] = [ Msf ::HostState ::Alive , Msf ::HostState ::Unknown ] if opts [ :non_dead ]
155
+ conditions [ :address ] = opts [ :addresses ] if opts [ :addresses ]
156
+
153
157
if opts [ :search_term ]
154
- conditions = Msf ::Util ::DBManager . create_all_column_search_conditions ( Mdm ::Host , opts [ :search_term ] )
155
- wspace . hosts . where ( conditions ) . order ( :address )
158
+ column_search_conditions = Msf ::Util ::DBManager . create_all_column_search_conditions ( Mdm ::Host , opts [ :search_term ] )
159
+ tag_conditions = Arel ::Nodes ::Regexp . new ( Mdm ::Tag . arel_table [ :name ] , Arel ::Nodes . build_quoted ( "(?mi)#{ opts [ :search_term ] } " ) )
160
+ search_conditions = column_search_conditions . or ( tag_conditions )
161
+ wspace . hosts . where ( conditions ) . where ( search_conditions ) . includes ( :tags ) . references ( :tags ) . order ( :address )
156
162
else
157
- conditions = { }
158
- conditions [ :state ] = [ Msf ::HostState ::Alive , Msf ::HostState ::Unknown ] if opts [ :non_dead ]
159
- conditions [ :address ] = opts [ :addresses ] if opts [ :addresses ]
160
163
wspace . hosts . where ( conditions ) . order ( :address )
161
164
end
162
165
}
You can’t perform that action at this time.
0 commit comments