Files
wpscan/doc_rdoc/CacheFileStore.html
Christian Mehlmauer 99ea17127d docs
2013-07-19 21:49:57 +02:00

564 lines
21 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title>Class: CacheFileStore</title>
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
<script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="./js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
<script src="./js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
<script src="./js/darkfish.js" type="text/javascript" charset="utf-8"></script>
</head>
<body id="top" class="class">
<div id="metadata">
<div id="home-metadata">
<div id="home-section" class="section">
<h3 class="section-header">
<a href="./index.html">Home</a>
<a href="./index.html#classes">Classes</a>
<a href="./index.html#methods">Methods</a>
</h3>
</div>
</div>
<div id="file-metadata">
<div id="file-list-section" class="section">
<h3 class="section-header">In Files</h3>
<div class="section-body">
<ul>
<li><a href="./lib/common/cache_file_store_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
class="thickbox" title="lib/common/cache_file_store.rb">lib/common/cache_file_store.rb</a></li>
</ul>
</div>
</div>
</div>
<div id="class-metadata">
<!-- Parent Class -->
<div id="parent-class-section" class="section">
<h3 class="section-header">Parent</h3>
<p class="link"><a href="Object.html">Object</a></p>
</div>
<!-- Method Quickref -->
<div id="method-list-section" class="section">
<h3 class="section-header">Methods</h3>
<ul class="link-list">
<li><a href="#method-c-new">::new</a></li>
<li><a href="#method-i-clean">#clean</a></li>
<li><a href="#method-i-get_entry_file_path">#get_entry_file_path</a></li>
<li><a href="#method-i-read_entry">#read_entry</a></li>
<li><a href="#method-i-write_entry">#write_entry</a></li>
</ul>
</div>
</div>
<div id="project-metadata">
<div id="fileindex-section" class="section project-section">
<h3 class="section-header">Files</h3>
<ul>
<li class="file"><a href="./CREDITS.html">CREDITS</a></li>
<li class="file"><a href="./Gemfile.html">Gemfile</a></li>
<li class="file"><a href="./LICENSE.html">LICENSE</a></li>
<li class="file"><a href="./README.html">README</a></li>
</ul>
</div>
<div id="classindex-section" class="section project-section">
<h3 class="section-header">Class/Module Index
<span class="search-toggle"><img src="./images/find.png"
height="16" width="16" alt="[+]"
title="show/hide quicksearch" /></span></h3>
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
<fieldset>
<legend>Quicksearch</legend>
<input type="text" name="quicksearch" value=""
class="quicksearch-field" />
</fieldset>
</form>
<ul class="link-list">
<li><a href="./WpTarget.html">WpTarget</a></li>
<li><a href="./WpTarget/InterestingHeaders.html">WpTarget::InterestingHeaders</a></li>
<li><a href="./WpTarget/Malwares.html">WpTarget::Malwares</a></li>
<li><a href="./WpTarget/WpConfigBackup.html">WpTarget::WpConfigBackup</a></li>
<li><a href="./WpTarget/WpCustomDirectories.html">WpTarget::WpCustomDirectories</a></li>
<li><a href="./WpTarget/WpFullPathDisclosure.html">WpTarget::WpFullPathDisclosure</a></li>
<li><a href="./WpTarget/WpLoginProtection.html">WpTarget::WpLoginProtection</a></li>
<li><a href="./WpTarget/WpReadme.html">WpTarget::WpReadme</a></li>
<li><a href="./WpTarget/WpRegistrable.html">WpTarget::WpRegistrable</a></li>
<li><a href="./WpItem.html">WpItem</a></li>
<li><a href="./WpItem/Existable.html">WpItem::Existable</a></li>
<li><a href="./WpItem/Findable.html">WpItem::Findable</a></li>
<li><a href="./WpItem/Infos.html">WpItem::Infos</a></li>
<li><a href="./WpItem/Output.html">WpItem::Output</a></li>
<li><a href="./WpItem/Versionable.html">WpItem::Versionable</a></li>
<li><a href="./WpItem/Vulnerable.html">WpItem::Vulnerable</a></li>
<li><a href="./Typhoeus.html">Typhoeus</a></li>
<li><a href="./Typhoeus/Request.html">Typhoeus::Request</a></li>
<li><a href="./Typhoeus/Request/Cacheable.html">Typhoeus::Request::Cacheable</a></li>
<li><a href="./Typhoeus/Response.html">Typhoeus::Response</a></li>
<li><a href="./WpTheme.html">WpTheme</a></li>
<li><a href="./WpTheme/Findable.html">WpTheme::Findable</a></li>
<li><a href="./WpTheme/Versionable.html">WpTheme::Versionable</a></li>
<li><a href="./WpTheme/Vulnerable.html">WpTheme::Vulnerable</a></li>
<li><a href="./WpTimthumb.html">WpTimthumb</a></li>
<li><a href="./WpTimthumb/Existable.html">WpTimthumb::Existable</a></li>
<li><a href="./WpTimthumb/Output.html">WpTimthumb::Output</a></li>
<li><a href="./WpTimthumb/Versionable.html">WpTimthumb::Versionable</a></li>
<li><a href="./WpUsers.html">WpUsers</a></li>
<li><a href="./WpUsers/BruteForcable.html">WpUsers::BruteForcable</a></li>
<li><a href="./WpUsers/Detectable.html">WpUsers::Detectable</a></li>
<li><a href="./WpUsers/Output.html">WpUsers::Output</a></li>
<li><a href="./WpVersion.html">WpVersion</a></li>
<li><a href="./WpVersion/Findable.html">WpVersion::Findable</a></li>
<li><a href="./WpVersion/Output.html">WpVersion::Output</a></li>
<li><a href="./WpVersion/Vulnerable.html">WpVersion::Vulnerable</a></li>
<li><a href="./Browser.html">Browser</a></li>
<li><a href="./Browser/Actions.html">Browser::Actions</a></li>
<li><a href="./Browser/Options.html">Browser::Options</a></li>
<li><a href="./Terminal.html">Terminal</a></li>
<li><a href="./Terminal/Table.html">Terminal::Table</a></li>
<li><a href="./Terminal/Table/Style.html">Terminal::Table::Style</a></li>
<li><a href="./WpItems.html">WpItems</a></li>
<li><a href="./WpItems/Detectable.html">WpItems::Detectable</a></li>
<li><a href="./WpItems/Output.html">WpItems::Output</a></li>
<li><a href="./WpUser.html">WpUser</a></li>
<li><a href="./WpUser/BruteForcable.html">WpUser::BruteForcable</a></li>
<li><a href="./WpUser/Existable.html">WpUser::Existable</a></li>
<li><a href="./Vulnerabilities.html">Vulnerabilities</a></li>
<li><a href="./Vulnerabilities/Output.html">Vulnerabilities::Output</a></li>
<li><a href="./Vulnerability.html">Vulnerability</a></li>
<li><a href="./Vulnerability/Output.html">Vulnerability::Output</a></li>
<li><a href="./WpPlugin.html">WpPlugin</a></li>
<li><a href="./WpPlugin/Vulnerable.html">WpPlugin::Vulnerable</a></li>
<li><a href="./WpPlugins.html">WpPlugins</a></li>
<li><a href="./WpPlugins/Detectable.html">WpPlugins::Detectable</a></li>
<li><a href="./WpThemes.html">WpThemes</a></li>
<li><a href="./WpThemes/Detectable.html">WpThemes::Detectable</a></li>
<li><a href="./WpTimthumbs.html">WpTimthumbs</a></li>
<li><a href="./WpTimthumbs/Detectable.html">WpTimthumbs::Detectable</a></li>
<li><a href="./Array.html">Array</a></li>
<li><a href="./CacheFileStore.html">CacheFileStore</a></li>
<li><a href="./CheckerPlugin.html">CheckerPlugin</a></li>
<li><a href="./CustomOptionParser.html">CustomOptionParser</a></li>
<li><a href="./File.html">File</a></li>
<li><a href="./GenerateList.html">GenerateList</a></li>
<li><a href="./GitUpdater.html">GitUpdater</a></li>
<li><a href="./ListGeneratorPlugin.html">ListGeneratorPlugin</a></li>
<li><a href="./Object.html">Object</a></li>
<li><a href="./Plugin.html">Plugin</a></li>
<li><a href="./Plugins.html">Plugins</a></li>
<li><a href="./StatsPlugin.html">StatsPlugin</a></li>
<li><a href="./SvnParser.html">SvnParser</a></li>
<li><a href="./SvnUpdater.html">SvnUpdater</a></li>
<li><a href="./TyphoeusCache.html">TyphoeusCache</a></li>
<li><a href="./URI.html">URI</a></li>
<li><a href="./Updater.html">Updater</a></li>
<li><a href="./UpdaterFactory.html">UpdaterFactory</a></li>
<li><a href="./VersionCompare.html">VersionCompare</a></li>
<li><a href="./WebSite.html">WebSite</a></li>
<li><a href="./WpscanOptions.html">WpscanOptions</a></li>
</ul>
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
</div>
</div>
</div>
<div id="documentation">
<h1 class="class">CacheFileStore</h1>
<div id="description" class="description">
</div><!-- description -->
<div id="5Buntitled-5D" class="documentation-section">
<!-- Attributes -->
<div id="attribute-method-details" class="method-section section">
<h3 class="section-header">Attributes</h3>
<div id="serializer-attribute-method" class="method-detail">
<a name="serializer"></a>
<div class="method-heading attribute-method-heading">
<span class="method-name">serializer</span><span
class="attribute-access-type">[R]</span>
</div>
<div class="method-description">
</div>
</div>
<div id="storage_path-attribute-method" class="method-detail">
<a name="storage_path"></a>
<div class="method-heading attribute-method-heading">
<span class="method-name">storage_path</span><span
class="attribute-access-type">[R]</span>
</div>
<div class="method-description">
</div>
</div>
</div><!-- attribute-method-details -->
<!-- Methods -->
<div id="public-class-method-details" class="method-section section">
<h3 class="section-header">Public Class Methods</h3>
<div id="new-method" class="method-detail ">
<a name="method-c-new"></a>
<div class="method-heading">
<span class="method-name">new</span><span
class="method-args">(storage_path, serializer = Marshal)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>The serializer must have the 2 methods .load and .dump</p>
<pre>(Marshal and YAML have them)</pre>
<p>YAML is Human Readable, contrary to Marshal which store in a binary format
Marshal does not need any “require”</p>
<div class="method-source-code" id="new-source">
<pre>
<span class="ruby-comment"># File lib/common/cache_file_store.rb, line 19</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">storage_path</span>, <span class="ruby-identifier">serializer</span> = <span class="ruby-constant">Marshal</span>)
<span class="ruby-ivar">@storage_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">storage_path</span>)
<span class="ruby-ivar">@serializer</span> = <span class="ruby-identifier">serializer</span>
<span class="ruby-comment"># File.directory? for ruby &lt;= 1.9 otherwise,</span>
<span class="ruby-comment"># it makes more sense to do Dir.exist? :/</span>
<span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-ivar">@storage_path</span>)
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-ivar">@storage_path</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- new-source -->
</div>
</div><!-- new-method -->
</div><!-- public-class-method-details -->
<div id="public-instance-method-details" class="method-section section">
<h3 class="section-header">Public Instance Methods</h3>
<div id="clean-method" class="method-detail ">
<a name="method-i-clean"></a>
<div class="method-heading">
<span class="method-name">clean</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="clean-source">
<pre>
<span class="ruby-comment"># File lib/common/cache_file_store.rb, line 30</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">clean</span>
<span class="ruby-constant">Dir</span>[<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@storage_path</span>, <span class="ruby-string">'*'</span>)].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">f</span>) <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-identifier">f</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- clean-source -->
</div>
</div><!-- clean-method -->
<div id="get_entry_file_path-method" class="method-detail ">
<a name="method-i-get_entry_file_path"></a>
<div class="method-heading">
<span class="method-name">get_entry_file_path</span><span
class="method-args">(key)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="get_entry_file_path-source">
<pre>
<span class="ruby-comment"># File lib/common/cache_file_store.rb, line 56</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_entry_file_path</span>(<span class="ruby-identifier">key</span>)
<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-identifier">join</span>(<span class="ruby-ivar">@storage_path</span>, <span class="ruby-identifier">key</span>)
<span class="ruby-keyword">end</span></pre>
</div><!-- get_entry_file_path-source -->
</div>
</div><!-- get_entry_file_path-method -->
<div id="read_entry-method" class="method-detail ">
<a name="method-i-read_entry"></a>
<div class="method-heading">
<span class="method-name">read_entry</span><span
class="method-args">(key)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="read_entry-source">
<pre>
<span class="ruby-comment"># File lib/common/cache_file_store.rb, line 36</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">read_entry</span>(<span class="ruby-identifier">key</span>)
<span class="ruby-identifier">entry_file_path</span> = <span class="ruby-identifier">get_entry_file_path</span>(<span class="ruby-identifier">key</span>)
<span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">entry_file_path</span>)
<span class="ruby-keyword">return</span> <span class="ruby-ivar">@serializer</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">entry_file_path</span>))
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- read_entry-source -->
</div>
</div><!-- read_entry-method -->
<div id="write_entry-method" class="method-detail ">
<a name="method-i-write_entry"></a>
<div class="method-heading">
<span class="method-name">write_entry</span><span
class="method-args">(key, data_to_store, cache_ttl)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="write_entry-source">
<pre>
<span class="ruby-comment"># File lib/common/cache_file_store.rb, line 44</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write_entry</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">data_to_store</span>, <span class="ruby-identifier">cache_ttl</span>)
<span class="ruby-keyword">if</span> <span class="ruby-identifier">cache_ttl</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">get_entry_file_path</span>(<span class="ruby-identifier">key</span>), <span class="ruby-string">'w'</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
<span class="ruby-keyword">begin</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-ivar">@serializer</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-identifier">data_to_store</span>))
<span class="ruby-keyword">rescue</span>
<span class="ruby-keyword">nil</span> <span class="ruby-comment"># spec fix for &quot;can't dump hash with default proc&quot; when stub_request with response headers</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- write_entry-source -->
</div>
</div><!-- write_entry-method -->
</div><!-- public-instance-method-details -->
</div><!-- 5Buntitled-5D -->
</div><!-- documentation -->
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
Rdoc Generator</a> 2</small>.</p>
</div>
</body>
</html>