<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ryan Plas on Medium]]></title>
        <description><![CDATA[Stories by Ryan Plas on Medium]]></description>
        <link>https://medium.com/@ryanplasma?source=rss-2cec41ee7185------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*28JD3cgza2rlIhYc.jpeg</url>
            <title>Stories by Ryan Plas on Medium</title>
            <link>https://medium.com/@ryanplasma?source=rss-2cec41ee7185------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 03:23:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ryanplasma/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating Custom Apps for Phantom: Part 1]]></title>
            <link>https://medium.com/@ryanplasma/creating-custom-apps-for-phantom-part-1-f4f3c891d415?source=rss-2cec41ee7185------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4f3c891d415</guid>
            <dc:creator><![CDATA[Ryan Plas]]></dc:creator>
            <pubDate>Thu, 06 Dec 2018 11:45:37 GMT</pubDate>
            <atom:updated>2018-12-13T03:52:48.842Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*46yyh79vHLF7nvgM.jpg" /></figure><h4><strong>Introduction</strong></h4><p>Welcome! If you’re here and wondering what Phantom is, I plan to have an introductory blog post at some point, but in the meantime head over <a href="https://www.splunk.com/en_us/software/splunk-security-orchestration-and-automation.html">here</a> for more info and to sign up for a community account.</p><p>In this series of blog posts, I’ll be going over how to write custom applications for the Phantom security automation and orchestration platform.</p><p>Custom apps are a great way to add new functionality to playbooks in Phantom by interfacing with third-party services and APIs. For this tutorial, we’ll be making a custom app for the <a href="https://wpvulndb.com/">WPScan Vulnerability Database.</a></p><p>The WPScan Vulnerability Database is a catalog of vulnerabilities that affect WordPress core, plugins, and themes. We are going to build an app using their <a href="https://wpvulndb.com/api">API</a> to display those vulnerabilities based on a passed in version number, plugin slug, or theme slug.</p><p>Disclaimer: if you want to use this app in your Phantom environment, please contact the WPScan team to enquire about a commercial license.</p><h4>Getting Started</h4><p>The first step to creating a custom app for Phantom is to use Phantom’s built-in app wizard. This can be found by navigating to /apps and selecting App Wizard in the top right navigation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*32PH6iCjz5wJ0zwO.png" /></figure><p>This drops us off on the Basic Details section of the App Wizard. Here we can fill in basic information about what our app will be called, what it will do, and what logos it will use in the interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sJstb4ryZbyfarcJ.png" /></figure><p>For the <strong>App Name</strong>, we’re going to use “WPScan Vulnerability Database API”.</p><p>For the <strong>App Description</strong>, we’re going to use “The WPScan Vulnerability Database is a database of WordPress Core, Plugin and Theme vulnerabilities.” from <a href="https://wpvulndb.com/about">https://wpvulndb.com/about.</a></p><p>For the <strong>Product Vendor,</strong> we’ll use “WPScan”.</p><p>For the <strong>Product Name</strong>, we’ll use “Vulnerability Database API”.</p><p>For the App Publisher, I&#39;ll use my name - you use yours.</p><p>For this app, let’s check the Distribute With Source checkbox. This will put our code in the distributable tarball when we compile the app. This will make it easier to share the code and for others to see how it works.</p><p>For the logos, I’m just going to copy the logo from the wpvulndb.com website for both light and dark. You would want to use a different logo if the logo you want to use is similar to either the light or dark theme’s backgrounds.</p><p>When we’re done, our Basic details tab should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/0*F7ouFA5DdqwgKeZO" /></figure><p>Now we can move on to the Asset Configuration tab.</p><h4>Asset Configuration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*JvYGw-8tREJGxyqk" /></figure><p>Here we’re going to set up any global app configuration options. This is useful for things like an API base url or API keys or other things that can change per asset, but apply to all actions.</p><p>For this app, we’ll be setting up a base url option and an API key option. set up one configuration option</p><p>Let’s add the base url option first. For the name we’ll follow Phatom’s pereferd naming schema and use base_urlas the name, a data type of string, <strong>&quot;WPVulnDB API Base URL&quot;</strong> as the description, and leave it marked as not required. Next, let&#39;s click on the <strong>More</strong> icon and add a default base_url value of <strong>&quot;https://wpvulndb.com/api/v3/&quot;</strong>. We&#39;re setting a default value since this will be the base url for 99.9% of users, but we want to make it customizable just in case.</p><p>Now, let’s do the same for the API key. For the name we’ll use api_key. This time we&#39;ll use password for the data type. This encrypts the value in the database, which is a good idea for api keys and passwords. We&#39;ll use <strong>&quot;WPVulnDB API Key&quot; </strong>as the description and mark this option as required and not set a default value since this will be different for everyone.</p><p>When we’re done, it’ll look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QSUCqum2UohIj0zW" /></figure><p>Now we can head over to the app actions tab.</p><h4>App Actions</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*wCCD_AY01QhZIHkr" /></figure><p>There’s not much for us to do here since our actions are a bit non-standard for this app, but let’s pick information from the drop down so we get the test connectivity action that all Phantom apps have. Also, we&#39;ll pick lookup ip from the available information actions and add it to the selected actions as Phantom doesn&#39;t allow you to continue without picking at least one default action, but we&#39;ll be removing it later.</p><p>After we do that, it should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*esSagXElKGT8oE_F.png" /></figure><p>Now we can head to the last tab — Custom Actions.</p><h4>Custom Actions</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eT7tuiHtodecxsAo" /></figure><p>This tab start out blank, but here we’ll be adding the custom actions we’ll be using to interface with the WPVulnDB API.</p><p>Let’s review the actions available to us from the WPVuln DB API. There are API endpoints for each of the following action: list WordPress core vulnerabilities for a version number (/wordpresses/{version}), list plugin vulnerabilities for a plugin slug ( /plugins/{slug}), and list theme vulnerabilities for a theme slug (/themes/{slug}). We&#39;re going to want to add an action for each of these.</p><p>So, back in the <strong>Custom Actions</strong> tab, let’s create three actions. Their names will be lookup wordpress, lookup plugin, and lookup theme. They will all have the type Investigate as they are actions we&#39;d use in the investigation phase and they will all be <strong>&quot;Read Only&quot;</strong> as the API calls don&#39;t change anything on a system.</p><p>lookup wordpress will have a parameter of wordpress_version, lookup plugin will have a parameter of plugin_slug, and lookup theme will have a parameter of theme_slug. All of these parameters will be of type string, be required, and be primary. Setting a parameter as primary will affect how it is displayed in the widget are of an event/case which is something we&#39;ll look at more later in this series, but let&#39;s just leave it as primary for now.</p><p>After we fill out the remaining descriptions, our page should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/0*OkLihurw0sH4AZSU" /></figure><p>Now we can finally hit submit!</p><h4>Files</h4><p>Upon clicking submit, if everything was filled out correctly, we will get a tarball of files to help us get started on our app.</p><p>If something didn’t go right, you should get a nice bit of red text up at the top of the wizard area telling you what is missing/incorrect.</p><p>In the next part of the series, we’ll dig into the files we just received and start implementing our actions.</p><p><em>Originally published at </em><a href="https://wordplas.com/2018/12/06/creating-custom-apps-phantom-part-1/"><em>WordPlas</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4f3c891d415" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using WordPress Transients for Speed and Profit]]></title>
            <link>https://medium.com/wordplas/using-wordpress-transients-for-speed-and-profit-3b6ea37a2725?source=rss-2cec41ee7185------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b6ea37a2725</guid>
            <dc:creator><![CDATA[Ryan Plas]]></dc:creator>
            <pubDate>Tue, 25 Oct 2016 02:13:44 GMT</pubDate>
            <atom:updated>2016-11-28T16:48:03.180Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*78NEHPaQ8wCxMTiY.jpg" /></figure><p>In this post, I’ll be going over what transients are, how to use them, and why you should use them.</p><h4>What are Transients?</h4><p>Transients are a way to cache information in WordPress. They are very similar to WordPress Options with one key difference: Transients include a lifespan. We’ll get into what that means in the next section.</p><h4>How do I use Transients?</h4><p>The Transient API in WordPress is pretty straightforward. If you’ve ever used the Options API, this will look very similar.</p><h4>Setting a Transient</h4><p>To set a transient, you use:</p><p>set_transient($transient, $value, $expiration);</p><p>$transient is a string you want to use as the unique identifier for this transient.</p><p>$value is the data you want to store in the transient.</p><p>$expiration is the <em>maximum</em> amount of seconds to keep the data. We’ll come back to why maximum is important in a bit.</p><p>WordPress comes with some useful helper constants that you can use to set the expiration time:</p><p>MINUTE_IN_SECONDS = 60 (seconds)<br> HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS<br> DAY_IN_SECONDS = 24 * HOUR_IN_SECONDS<br> WEEK_IN_SECONDS = 7 * DAY_IN_SECONDS<br> YEAR_IN_SECONDS = 365 * DAY_IN_SECONDS</p><p>So if you wanted the transient to expire in 3 hours, you would use 3 * HOUR_IN_SECONDS</p><h4>Getting a Transient</h4><p>To retrieve the value of a transient, you use:</p><p>get_transient( $transient );</p><p>$transient is the unique identifier you used in set_transient() above.</p><p>This function returns false if the transient isn’t set, so a common pattern to use looks something like this:</p><pre>if ( false === ($value = get_transient( &#39;value&#39; ))) {<br>  //do stuff to set the transient<br>}</pre><h4>Deleting a Transient</h4><p>To delete a transient, you use:</p><p>delete_transient( $transient );</p><p>$transient is again the unique identifier for the the transient</p><p>Use this function when you want to unset a transient before its expiration time.</p><h4>Other Methods</h4><p>If you are using WordPress Multisite, you can take advantage of these functions to set network wide transients that can be used on any site.</p><p>set_site_transient()<br> get_site_transient()<br> delete_site_transient()</p><h4>Why should I use Transients?</h4><p>Transients are useful for caching the results of complicated queries or queries that take a long time to run. For example, if you have a page on your site where you are making lots of API requests for data from something like the Github API, then you could use transients to store the results of those requests and only refresh them once a day or so instead of on every page load. I’ll show you an example of this in the next section.</p><h4>Code</h4><p>Let’s write some code so we can see exactly how transients work. If you want to follow along, run this command in your wp-content/plugins directory:</p><p>git clone -b 00-initial-widget <a href="https://github.com/ryanplasma/transient-demo-widget.git">https://github.com/ryanplasma/transient-demo-widget.git</a></p><p>That will pull down the initial widget code we’ll be working with.</p><h4>Initial Widget Code</h4><p>What we’re going to build is a quick sidebar widget that displays our Github repos. Here’s what we have stubbed out so far:</p><pre>public function widget( $args, $instance ) {<br>    $output = &#39;&#39;;<br>    $output .= &#39;&lt;h1&gt;Github Repos&lt;/h1&gt;&#39;;<br>    $output .= &#39;&lt;ul&gt;&#39;;<br>    $output .= &#39;&lt;li&gt;&lt;a href=#&gt;Repo 1&lt;/a&gt;&lt;/li&gt;&#39;;<br>    $output .= &#39;&lt;li&gt;&lt;a href=#&gt;Repo 2&lt;/a&gt;&lt;/li&gt;&#39;;<br>    $output .= &#39;&lt;li&gt;&lt;a href=#&gt;Repo 3&lt;/a&gt;&lt;/li&gt;&#39;;<br>    $output .= &#39;&lt;/ul&gt;&#39;;<br><br>    echo $output;<br>}</pre><p>If we enable the plugin and add the widget to the sidebar, we get something that looks like this (I’m using the stock Twenty Sixteen theme):</p><figure><img alt="screen-shot-2016-10-20-at-1-48-46-pm" src="https://cdn-images-1.medium.com/max/303/0*DDrQQnlqgfyO7gHU.png" /></figure><p>This looks alright, but it would be nice if we could pull in our data from github so we have a real list of our repos.</p><h4>Getting the data from the API</h4><p>Since it’s a bit outside the scope of this post, I’ll just quickly explain the code used to get the data from the Github API. It’s going to look something like this:</p><pre>$url = &quot;https://api.github.com/users/ryanplasma/repos&quot;;<br>$response = wp_remote_get( $url );<br>$body = wp_remote_retrieve_body( $response );<br>$repos = json_decode( $body );</pre><p>$repos will then contain an array of repo data.</p><p>There are many pieces of information that come with that request, but the ones we’re looking for are the name of the repo and the link. The properties names for these are name and html_url respectively.</p><p>Knowing this, we can edit the output to show our actual repos. Our full widget output method will look something like this:</p><pre>public function widget( $args, $instance ) {<br>  $url = &quot;https://api.github.com/users/ryanplasma/repos&quot;;<br>  $response = wp_remote_get( $url );<br>  $body = wp_remote_retrieve_body( $response );<br>  $repos = json_decode( $body );<br><br>  $output = &#39;&#39;;<br>  $output .= &#39;&lt;h1&gt;Github Repos&lt;/h1&gt;&#39;;<br>  $output .= &#39;&lt;ul&gt;&#39;;<br><br>  foreach ($repos as $repo) {<br>    $output .= &#39;&lt;li&gt;&#39;;<br>    $output .= &#39;&lt;a href=&#39; . $repo-&gt;html_url . &#39;&gt;&#39;;<br>    $output .= $repo-&gt;name;<br>    $output .= &#39;&lt;/a&gt;&#39;;<br>    $output .= &#39;&lt;/li&gt;&#39;;<br>  }<br><br>  $output .= &#39;&lt;/ul&gt;&#39;;<br><br>  echo $output;<br>}</pre><p>and when we save it, our widget now looks something like this:</p><figure><img alt="screen-shot-2016-10-20-at-2-58-52-pm" src="https://cdn-images-1.medium.com/max/229/0*R-A7xfbprk-iiytV.png" /></figure><p>Much better! However, we have a few problems:</p><ol><li>If you’ve been following along, point your browser at <a href="https://api.github.com/rate_limit">https://api.github.com/rate_limit</a> and you’ll see that we’ve made a dent in our rate limit for the Github API. Your site may not get much traffic, but you’ll run into issues if you refresh the page more than 60 times in an hour, which really isn’t that much.</li><li>It’s may be negligible at this point, but making the request to the github API adds 200 or so milliseconds to our page load time. Imagine if we started adding features to this widget that required more API calls like getting links to the 5 most recent issues for each repo. That time adds up quick.</li></ol><h4>Using Transients</h4><p>Let’s negate those issues by using what we learned about transients above. If you’ve gotten lost, here’s where we’re at so far: <a href="https://github.com/ryanplasma/transient-demo-widget/tree/01-data-from-API">https://github.com/ryanplasma/transient-demo-widget/tree/01-data-from-API</a></p><p>First let’s keep track of how long getting the repo data takes, so we have a benchmark for when we start using transients. That’s going to look like this:</p><pre>public function widget( $args, $instance ) {<br>  $time1 = microtime();<br><br>  $url = &quot;https://api.github.com/users/ryanplasma/repos&quot;;<br>  $response = wp_remote_get( $url );<br>  $body = wp_remote_retrieve_body( $response );<br>  $repos = json_decode( $body );<br><br>  $time2 = microtime();<br><br>  $output = &#39;&#39;;<br>  $output .= &#39;&lt;h1&gt;Github Repos&lt;/h1&gt;&#39;;<br>  $output .= &#39;&lt;ul&gt;&#39;;<br><br>  foreach ($repos as $repo) {<br>    $output .= &#39;&lt;li&gt;&#39;;<br>    $output .= &#39;&lt;a href=&#39; . $repo-&gt;html_url . &#39;&gt;&#39;;<br>    $output .= $repo-&gt;name;<br>    $output .= &#39;&lt;/a&gt;&#39;;<br>    $output .= &#39;&lt;/li&gt;&#39;;<br>  }<br><br>  $output .= &#39;&lt;/ul&gt;&#39;;<br><br>  $benchmark = $time2 - $time1;<br>  $output .= &#39;&lt;p&gt;Time: &#39; . $benchmark . &#39; seconds&#39;;<br><br>  echo $output;<br>}</pre><p>I’ve added 2 microtime() functions to time how long getting the data takes and then I have it output to the bottom of the widget. I’m consistently getting about .2 seconds</p><figure><img alt="screen-shot-2016-10-20-at-3-24-56-pm" src="https://cdn-images-1.medium.com/max/261/0*3oCrTCixM28Mf8MH.png" /></figure><p>Let’s now take advantage of the pattern for seeing if a transient is set that we looked at earlier.</p><pre>if ( false === ($value = get_transient( &#39;value&#39; ))) {<br>  //do stuff to set the transient<br>}</pre><p>This is going to end up looking something like this:</p><pre>if ( false === ($repos = get_transient( &#39;github_repos&#39; ))) {<br>    $url = &quot;https://api.github.com/users/ryanplasma/repos&quot;;<br>    $response = wp_remote_get( $url );<br>    $body = wp_remote_retrieve_body( $response );<br>    $repos = json_decode( $body );<br><br>    set_transient( &#39;github_repos&#39;, $repos, DAY_IN_SECONDS);<br>}</pre><p>After this runs, $repos will either be retrieved from the API or from the transient if it is set.</p><p>The first time we refresh the page, the content is still coming from the api and still takes about 200 miliseconds to fetch:</p><figure><img alt="screen-shot-2016-10-21-at-11-16-45-pm" src="https://cdn-images-1.medium.com/max/634/0*ypQ2XC18drYEgTJx.png" /></figure><p>but after refreshing again, we see a considerable speed difference:</p><figure><img alt="screen-shot-2016-10-21-at-11-17-07-pm" src="https://cdn-images-1.medium.com/max/626/0*DeOPiqYE4yTpHHCw.png" /></figure><p>This is .3 milliseconds, which is practically a 100% decrease in time to fetch the repo data — almost instantaneous.</p><h4>Other Resources:</h4><p>If you want to learn more about transients, here are some helpful resources:</p><ul><li><a href="https://codex.wordpress.org/Transients_API">Transients in the Codex</a></li><li><a href="https://css-tricks.com/the-deal-with-wordpress-transients/">Transients on CSS Tricks</a></li><li><a href="http://bryanapperson.com/blog/using-a-redis-object-cache-for-wordpress/">Use Redis for WordPress Object Caching</a> (Extra performance boost for transients)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b6ea37a2725" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wordplas/using-wordpress-transients-for-speed-and-profit-3b6ea37a2725">Using WordPress Transients for Speed and Profit</a> was originally published in <a href="https://medium.com/wordplas">WordPlas</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>