File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -370,13 +370,14 @@ def create_namespace_module(namespace_module_names)
370
370
# @return [Module] module that wraps the previously loaded content from {#read_module_content}.
371
371
# @return [nil] if any module name along the chain does not exist.
372
372
def current_module ( module_names )
373
- # don't look at ancestors for constant
374
- inherit = false
375
-
376
373
# Don't want to trigger ActiveSupport's const_missing, so can't use constantize.
377
374
named_module = module_names . inject ( Object ) { |parent , module_name |
378
- if parent . const_defined? ( module_name , inherit )
379
- parent . const_get ( module_name , inherit )
375
+ # Since we're searching parent namespaces first anyway, this is
376
+ # semantically equivalent to providing false for the 1.9-only
377
+ # "inherit" parameter to const_defined?. If we ever drop 1.8
378
+ # support, we can save a few cycles here by adding it back.
379
+ if parent . const_defined? ( module_name )
380
+ parent . const_get ( module_name )
380
381
else
381
382
break
382
383
end
@@ -617,4 +618,4 @@ def usable?(metasploit_class)
617
618
618
619
usable
619
620
end
620
- end
621
+ end
Original file line number Diff line number Diff line change @@ -11,10 +11,15 @@ module Msf::Modules::Namespace
11
11
def metasploit_class
12
12
metasploit_class = nil
13
13
# don't search ancestors for the metasploit_class
14
- inherit = false
14
+ # inherit = false
15
15
16
16
::Msf ::Framework ::Major . downto ( 1 ) do |major |
17
- if const_defined? ( "Metasploit#{ major } " , inherit )
17
+ # Since we really only care about the deepest namespace, we don't
18
+ # need to look for parents' constants. However, the "inherit"
19
+ # parameter for const_defined? only exists after 1.9. If we ever
20
+ # drop 1.8 support, we can save a few cycles here by passing false
21
+ # here.
22
+ if const_defined? ( "Metasploit#{ major } " )
18
23
metasploit_class = const_get ( "Metasploit#{ major } " )
19
24
20
25
break
@@ -52,4 +57,4 @@ def version_compatible!(module_path, module_reference_name)
52
57
end
53
58
end
54
59
end
55
- end
60
+ end
You can’t perform that action at this time.
0 commit comments