@@ -196,7 +196,7 @@ def connect(opts={})
196
196
197
197
# Prefer the config file's pool setting
198
198
nopts [ 'pool' ] ||= 75
199
-
199
+
200
200
# Prefer the config file's wait_timeout setting too
201
201
nopts [ 'wait_timeout' ] ||= 300
202
202
@@ -342,11 +342,13 @@ def update_all_module_details
342
342
return if not self . migrated
343
343
return if self . modules_caching
344
344
345
+ self . framework . cache_thread = Thread . current
346
+
345
347
self . modules_cached = false
346
348
self . modules_caching = true
347
349
348
350
::ActiveRecord ::Base . connection_pool . with_connection {
349
-
351
+
350
352
refresh = [ ]
351
353
skipped = [ ]
352
354
@@ -394,6 +396,9 @@ def update_all_module_details
394
396
end
395
397
end
396
398
399
+ self . framework . cache_initialized = true
400
+ self . framework . cache_thread = nil
401
+
397
402
self . modules_cached = true
398
403
self . modules_caching = false
399
404
@@ -460,16 +465,16 @@ def module_to_details_hash(m)
460
465
461
466
res [ :description ] = m . description . to_s . strip
462
467
463
- m . arch . map { |x |
464
- bits << [ :arch , { :name => x . to_s } ]
468
+ m . arch . map { |x |
469
+ bits << [ :arch , { :name => x . to_s } ]
465
470
}
466
471
467
- m . platform . platforms . map { |x |
468
- bits << [ :platform , { :name => x . to_s . split ( '::' ) . last . downcase } ]
472
+ m . platform . platforms . map { |x |
473
+ bits << [ :platform , { :name => x . to_s . split ( '::' ) . last . downcase } ]
469
474
}
470
475
471
- m . author . map { |x |
472
- bits << [ :author , { :name => x . to_s } ]
476
+ m . author . map { |x |
477
+ bits << [ :author , { :name => x . to_s } ]
473
478
}
474
479
475
480
m . references . map do |r |
@@ -500,14 +505,14 @@ def module_to_details_hash(m)
500
505
# Some modules are a combination, which means they are actually aggressive
501
506
res [ :stance ] = m . stance . to_s . index ( "aggressive" ) ? "aggressive" : "passive"
502
507
503
-
508
+
504
509
m . class . mixins . each do |x |
505
510
bits << [ :mixin , { :name => x . to_s } ]
506
511
end
507
512
end
508
513
509
514
if ( m . type == "auxiliary" )
510
-
515
+
511
516
m . actions . each_index do |i |
512
517
bits << [ :action , { :name => m . actions [ i ] . name . to_s } ]
513
518
end
@@ -523,9 +528,9 @@ def module_to_details_hash(m)
523
528
524
529
res
525
530
end
526
-
527
-
528
-
531
+
532
+
533
+
529
534
#
530
535
# This provides a standard set of search filters for every module.
531
536
# The search terms are in the form of:
@@ -562,7 +567,7 @@ def search_modules(search_string, inclusive=false)
562
567
end
563
568
564
569
::ActiveRecord ::Base . connection_pool . with_connection {
565
-
570
+
566
571
where_q = [ ]
567
572
where_v = [ ]
568
573
@@ -572,12 +577,12 @@ def search_modules(search_string, inclusive=false)
572
577
case kt
573
578
when 'text'
574
579
xv = "%#{ kv } %"
575
- where_q << ' ( ' +
580
+ where_q << ' ( ' +
576
581
'module_details.fullname ILIKE ? OR module_details.name ILIKE ? OR module_details.description ILIKE ? OR ' +
577
582
'module_authors.name ILIKE ? OR module_actions.name ILIKE ? OR module_archs.name ILIKE ? OR ' +
578
- 'module_targets.name ILIKE ? OR module_platforms.name ILIKE ? ' +
583
+ 'module_targets.name ILIKE ? OR module_platforms.name ILIKE ? OR module_refs.name ILIKE ? ' +
579
584
') '
580
- where_v << [ xv , xv , xv , xv , xv , xv , xv , xv ]
585
+ where_v << [ xv , xv , xv , xv , xv , xv , xv , xv , xv ]
581
586
when 'name'
582
587
xv = "%#{ kv } %"
583
588
where_q << ' ( module_details.fullname ILIKE ? OR module_details.name ILIKE ? ) '
@@ -594,7 +599,7 @@ def search_modules(search_string, inclusive=false)
594
599
# TODO
595
600
when 'type'
596
601
where_q << ' ( module_details.mtype = ? ) '
597
- where_v << [ kv ]
602
+ where_v << [ kv ]
598
603
when 'app'
599
604
where_q << ' ( module_details.stance = ? )'
600
605
where_v << [ ( kv == "client" ) ? "passive" : "active" ]
@@ -604,11 +609,11 @@ def search_modules(search_string, inclusive=false)
604
609
when 'cve' , 'bid' , 'osvdb' , 'edb'
605
610
where_q << ' ( module_refs.name = ? )'
606
611
where_v << [ kt . upcase + '-' + kv ]
607
-
612
+
608
613
end
609
614
end
610
615
end
611
-
616
+
612
617
qry = Mdm ::ModuleDetail . select ( "DISTINCT(module_details.*)" ) .
613
618
joins (
614
619
"LEFT OUTER JOIN module_authors ON module_details.id = module_authors.module_detail_id " +
@@ -629,4 +634,3 @@ def search_modules(search_string, inclusive=false)
629
634
630
635
end
631
636
end
632
-
0 commit comments