Files
metasploit-gs/api/Msf/ModuleManager/ModulePaths.html
T
jenkins-metasploit c3f5bd3de2 Reboot gh-pages
2026-05-08 17:08:43 +00:00

488 lines
15 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Msf::ModuleManager::ModulePaths
&mdash; Documentation by YARD 0.9.37
</title>
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "Msf::ModuleManager::ModulePaths";
relpath = '../../';
</script>
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="../../class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../../_index.html">Index (M)</a> &raquo;
<span class='title'><span class='object_link'><a href="../../Msf.html" title="Msf (module)">Msf</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../ModuleManager.html" title="Msf::ModuleManager (class)">ModuleManager</a></span></span>
&raquo;
<span class="title">ModulePaths</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Module: Msf::ModuleManager::ModulePaths
</h1>
<div class="box_info">
<dl>
<dt>Extended by:</dt>
<dd>ActiveSupport::Concern</dd>
</dl>
<dl>
<dt>Included in:</dt>
<dd><span class='object_link'><a href="../ModuleManager.html" title="Msf::ModuleManager (class)">Msf::ModuleManager</a></span></dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/msf/core/module_manager/module_paths.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Deals with module paths in the <span class='object_link'><a href="../ModuleManager.html" title="Msf::ModuleManager (class)">Msf::ModuleManager</a></span></p>
</div>
</div>
<div class="tags">
</div>
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
<ul class="summary">
<li class="protected ">
<span class="summary_signature">
<a href="#module_paths-instance_method" title="#module_paths (instance method)">#<strong>module_paths</strong> &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>:nodoc:.</p>
</div></span>
</li>
</ul>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#add_module_path-instance_method" title="#add_module_path (instance method)">#<strong>add_module_path</strong>(path, opts = {}, recalculate: true) &#x21d2; Hash{String =&gt; Integer} </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Adds a path to be searched for new modules.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#remove_module_path-instance_method" title="#remove_module_path (instance method)">#<strong>remove_module_path</strong>(path) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Removes a path from which to search for modules.</p>
</div></span>
</li>
</ul>
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
<span id="module_paths=-instance_method"></span>
<div class="method_details first">
<h3 class="signature first" id="module_paths-instance_method">
#<strong>module_paths</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>:nodoc:</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
63
64
65</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module_manager/module_paths.rb', line 63</span>
<span class='kw'>def</span> <span class='id identifier rubyid_module_paths'>module_paths</span>
<span class='ivar'>@module_paths</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="add_module_path-instance_method">
#<strong>add_module_path</strong>(path, opts = {}, recalculate: true) &#x21d2; <tt>Hash{String =&gt; Integer}</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Adds a path to be searched for new modules.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>path</span>
<span class='type'>(<tt>String</tt>)</span>
</li>
<li>
<span class='name'>opts</span>
<span class='type'>(<tt>Hash</tt>)</span>
<em class="default">(defaults to: <tt>{}</tt>)</em>
</li>
</ul>
<p class="tag_title">Options Hash (<tt>opts</tt>):</p>
<ul class="option">
<li>
<span class="name">whitelist</span>
<span class="type">(<tt>Array</tt>)</span>
<span class="default">
</span>
&mdash; <div class='inline'>
<p>An array of regex patterns to search for specific modules</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Hash{String =&gt; Integer}</tt>)</span>
&mdash;
<div class='inline'>
<p>Maps module type to number of modules loaded</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module_manager/module_paths.rb', line 19</span>
<span class='kw'>def</span> <span class='id identifier rubyid_add_module_path'>add_module_path</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>recalculate:</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='id identifier rubyid_nested_paths'>nested_paths</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='comment'># remove trailing file separator
</span> <span class='id identifier rubyid_path_without_trailing_file_separator'>path_without_trailing_file_separator</span> <span class='op'>=</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_sub'>sub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='embexpr_beg'>#{</span><span class='const'>File</span><span class='op'>::</span><span class='const'>SEPARATOR</span><span class='embexpr_end'>}</span><span class='tstring_content'>$</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># Make the path completely canonical
</span> <span class='id identifier rubyid_pathname'>pathname</span> <span class='op'>=</span> <span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_path_without_trailing_file_separator'>path_without_trailing_file_separator</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span>
<span class='comment'># Make sure the path is a valid directory
</span> <span class='kw'>unless</span> <span class='id identifier rubyid_pathname'>pathname</span><span class='period'>.</span><span class='id identifier rubyid_directory?'>directory?</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>The path supplied is not a valid directory.</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_nested_paths'>nested_paths</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_pathname'>pathname</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
<span class='comment'># Update the module paths appropriately
</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_module_paths'>module_paths</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_module_paths'>module_paths</span> <span class='op'>+</span> <span class='id identifier rubyid_nested_paths'>nested_paths</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
<span class='comment'># Load all of the modules from the nested paths
</span> <span class='id identifier rubyid_count_by_type'>count_by_type</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
<span class='id identifier rubyid_nested_paths'>nested_paths</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_path'>path</span><span class='op'>|</span>
<span class='id identifier rubyid_path_count_by_type'>path_count_by_type</span> <span class='op'>=</span> <span class='id identifier rubyid_load_modules'>load_modules</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='symbol'>:force</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>recalculate:</span> <span class='id identifier rubyid_recalculate'>recalculate</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='comment'># merge hashes
</span> <span class='id identifier rubyid_path_count_by_type'>path_count_by_type</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_path_count'>path_count</span><span class='op'>|</span>
<span class='id identifier rubyid_accumulated_count'>accumulated_count</span> <span class='op'>=</span> <span class='id identifier rubyid_count_by_type'>count_by_type</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='int'>0</span><span class='rparen'>)</span>
<span class='id identifier rubyid_count_by_type'>count_by_type</span><span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_accumulated_count'>accumulated_count</span> <span class='op'>+</span> <span class='id identifier rubyid_path_count'>path_count</span>
<span class='kw'>end</span>
<span class='rbrace'>}</span>
<span class='kw'>return</span> <span class='id identifier rubyid_count_by_type'>count_by_type</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="remove_module_path-instance_method">
#<strong>remove_module_path</strong>(path) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Removes a path from which to search for modules.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
56
57
58
59</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module_manager/module_paths.rb', line 56</span>
<span class='kw'>def</span> <span class='id identifier rubyid_remove_module_path'>remove_module_path</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
<span class='id identifier rubyid_module_paths'>module_paths</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
<span class='id identifier rubyid_module_paths'>module_paths</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Fri May 8 17:02:06 2026 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.1.5).
</div>
</div>
</body>
</html>