Files
metasploit-gs/api/Metasploit/Framework/Database.html
T

714 lines
21 KiB
HTML
Raw Normal View History

2026-05-08 17:08:43 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Metasploit::Framework::Database
&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 = "Metasploit::Framework::Database";
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 (D)</a> &raquo;
<span class='title'><span class='object_link'><a href="../../Metasploit.html" title="Metasploit (module)">Metasploit</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Framework.html" title="Metasploit::Framework (module)">Framework</a></span></span>
&raquo;
<span class="title">Database</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: Metasploit::Framework::Database
</h1>
<div class="box_info">
<dl>
<dt>Defined in:</dt>
<dd>lib/metasploit/framework/database.rb</dd>
</dl>
</div>
<h2>
Constant Summary
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
</h2>
<dl class="constants">
<dt id="CONFIGURATIONS_PATHNAME_PRECEDENCE-constant" class="">CONFIGURATIONS_PATHNAME_PRECEDENCE =
<div class="docstring">
<div class="discussion">
<p>CONSTANTS</p>
</div>
</div>
<div class="tags">
</div>
</dt>
<dd><pre class="code"><span class='lbracket'>[</span>
<span class='symbol'>:environment_configurations_pathname</span><span class='comma'>,</span>
<span class='symbol'>:user_configurations_pathname</span><span class='comma'>,</span>
<span class='symbol'>:project_configurations_pathname</span>
<span class='rbracket'>]</span></pre></dd>
</dl>
<h2>
Class Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#configurations_pathname-class_method" title="configurations_pathname (class method)">.<strong>configurations_pathname</strong>(options = {}) &#x21d2; Pathname<sup>?</sup> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns first configuration pathname from configuration_pathnames or the overriding :path`.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#configurations_pathnames-class_method" title="configurations_pathnames (class method)">.<strong>configurations_pathnames</strong> &#x21d2; Array&lt;Pathname&gt; </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Return configuration pathnames that exist.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#environment_configurations_pathname-class_method" title="environment_configurations_pathname (class method)">.<strong>environment_configurations_pathname</strong> &#x21d2; Pathname<sup>?</sup> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Pathname to database.yml` pointed to by `MSF_DATABASE_CONFIG` environment variable.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#project_configurations_pathname-class_method" title="project_configurations_pathname (class method)">.<strong>project_configurations_pathname</strong> &#x21d2; Pathname </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Pathname to database.yml` for the metasploit-framework project in `config/database.yml`.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#user_configurations_pathname-class_method" title="user_configurations_pathname (class method)">.<strong>user_configurations_pathname</strong> &#x21d2; Pathname<sup>?</sup> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Pathname to database.yml` in the users config directory.</p>
</div></span>
</li>
</ul>
<div id="class_method_details" class="method_details_list">
<h2>Class Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="configurations_pathname-class_method">
.<strong>configurations_pathname</strong>(options = {}) &#x21d2; <tt>Pathname</tt><sup>?</sup>
</h3><div class="docstring">
<div class="discussion">
<p>Returns first configuration pathname from configuration_pathnames or the overriding :path`.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>options</span>
<span class='type'>(<tt>Hash{Symbol=&gt;String}</tt>)</span>
<em class="default">(defaults to: <tt>{}</tt>)</em>
</li>
</ul>
<p class="tag_title">Options Hash (<tt>options</tt>):</p>
<ul class="option">
<li>
<span class="name">:path</span>
<span class="type">(<tt>String</tt>)</span>
<span class="default">
</span>
&mdash; <div class='inline'>
<p>Path to use instead of first element of configurations_pathnames</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Pathname</tt>)</span>
&mdash;
<div class='inline'>
<p>if configuration pathname exists.</p>
</div>
</li>
<li>
<span class='type'>(<tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>if configuration pathname does not exist.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/database.rb', line 26</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_configurations_pathname'>configurations_pathname</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_assert_valid_keys'>assert_valid_keys</span><span class='lparen'>(</span><span class='symbol'>:path</span><span class='rparen'>)</span>
<span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:path</span><span class='rbracket'>]</span>
<span class='kw'>if</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</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'>path</span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_pathname'>pathname</span> <span class='op'>=</span> <span class='id identifier rubyid_configurations_pathnames'>configurations_pathnames</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
<span class='kw'>end</span>
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_pathname'>pathname</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_pathname'>pathname</span><span class='period'>.</span><span class='id identifier rubyid_exist?'>exist?</span>
<span class='id identifier rubyid_pathname'>pathname</span>
<span class='kw'>else</span>
<span class='kw'>nil</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="configurations_pathnames-class_method">
.<strong>configurations_pathnames</strong> &#x21d2; <tt>Array&lt;Pathname&gt;</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Return configuration pathnames that exist.</p>
<p>Returns Pathnames` in order of precedence</p>
<ol><li>
<p><span class='object_link'><a href="#environment_configurations_pathname-class_method" title="Metasploit::Framework::Database.environment_configurations_pathname (method)">environment_configurations_pathname</a></span></p>
</li><li>
<p><span class='object_link'><a href="#user_configurations_pathname-class_method" title="Metasploit::Framework::Database.user_configurations_pathname (method)">user_configurations_pathname</a></span></p>
</li><li>
<p><span class='object_link'><a href="#project_configurations_pathname-class_method" title="Metasploit::Framework::Database.project_configurations_pathname (method)">project_configurations_pathname</a></span></p>
</li></ol>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array&lt;Pathname&gt;</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
53
54
55
56
57
58
59
60
61
62
63
64
65</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/database.rb', line 53</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_configurations_pathnames'>configurations_pathnames</span>
<span class='id identifier rubyid_configurations_pathnames'>configurations_pathnames</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='const'><span class='object_link'><a href="#CONFIGURATIONS_PATHNAME_PRECEDENCE-constant" title="Metasploit::Framework::Database::CONFIGURATIONS_PATHNAME_PRECEDENCE (constant)">CONFIGURATIONS_PATHNAME_PRECEDENCE</a></span></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_configurations_pathname_message'>configurations_pathname_message</span><span class='op'>|</span>
<span class='id identifier rubyid_configurations_pathname'>configurations_pathname</span> <span class='op'>=</span> <span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='id identifier rubyid_configurations_pathname_message'>configurations_pathname_message</span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_configurations_pathname'>configurations_pathname</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_configurations_pathname'>configurations_pathname</span><span class='period'>.</span><span class='id identifier rubyid_exist?'>exist?</span>
<span class='id identifier rubyid_configurations_pathnames'>configurations_pathnames</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_configurations_pathname'>configurations_pathname</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_configurations_pathnames'>configurations_pathnames</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="environment_configurations_pathname-class_method">
.<strong>environment_configurations_pathname</strong> &#x21d2; <tt>Pathname</tt><sup>?</sup>
</h3><div class="docstring">
<div class="discussion">
<p>Pathname to database.yml` pointed to by `MSF_DATABASE_CONFIG` environment variable.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Pathname</tt>)</span>
&mdash;
<div class='inline'>
<p>if MSF_DATABASE_CONFIG` is not blank.</p>
</div>
</li>
<li>
<span class='type'>(<tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>otherwise</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
71
72
73
74
75
76
77
78
79
80
81</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/database.rb', line 71</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_environment_configurations_pathname'>environment_configurations_pathname</span>
<span class='id identifier rubyid_msf_database_config'>msf_database_config</span> <span class='op'>=</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>MSF_DATABASE_CONFIG</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
<span class='kw'>if</span> <span class='id identifier rubyid_msf_database_config'>msf_database_config</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
<span class='id identifier rubyid_msf_database_config'>msf_database_config</span> <span class='op'>=</span> <span class='kw'>nil</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_msf_database_config'>msf_database_config</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_msf_database_config'>msf_database_config</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_msf_database_config'>msf_database_config</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="project_configurations_pathname-class_method">
.<strong>project_configurations_pathname</strong> &#x21d2; <tt>Pathname</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Pathname to database.yml` for the metasploit-framework project in `config/database.yml`.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Pathname</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
86
87
88
89</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/database.rb', line 86</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_project_configurations_pathname'>project_configurations_pathname</span>
<span class='id identifier rubyid_root'><span class='object_link'><a href="../../top-level-namespace.html" title="Top Level Namespace (root)">root</a></span></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='kw'>__FILE__</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_realpath'>realpath</span><span class='period'>.</span><span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_parent'>parent</span>
<span class='id identifier rubyid_root'><span class='object_link'><a href="../../top-level-namespace.html" title="Top Level Namespace (root)">root</a></span></span><span class='period'>.</span><span class='id identifier rubyid_join'><span class='object_link'><a href="../../top-level-namespace.html#join-instance_method" title="#join (method)">join</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>config</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>database.yml</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="user_configurations_pathname-class_method">
.<strong>user_configurations_pathname</strong> &#x21d2; <tt>Pathname</tt><sup>?</sup>
</h3><div class="docstring">
<div class="discussion">
<p>Pathname to database.yml` in the users config directory.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Pathname</tt>)</span>
&mdash;
<div class='inline'>
<p>if the user has a database.yml` in their config directory (`~/.msf4` by default).</p>
</div>
</li>
<li>
<span class='type'>(<tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>if the user does not have a database.yml` in their config directory.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
95
96
97</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/database.rb', line 95</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_user_configurations_pathname'>user_configurations_pathname</span>
<span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../Msf.html" title="Msf (module)">Msf</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Msf/Config.html" title="Msf::Config (class)">Config</a></span></span><span class='period'>.</span><span class='id identifier rubyid_config_directory'><span class='object_link'><a href="../../Msf/Config.html#config_directory-class_method" title="Msf::Config.config_directory (method)">config_directory</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_join'><span class='object_link'><a href="../../top-level-namespace.html#join-instance_method" title="#join (method)">join</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>database.yml</span><span class='tstring_end'>&#39;</span></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:52 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>