<?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 Tyrone Wilson on Medium]]></title>
        <description><![CDATA[Stories by Tyrone Wilson on Medium]]></description>
        <link>https://medium.com/@tyrone.wilson?source=rss-5197bbd1d08------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RZ0HPpneKJsWVHdcwihZ_Q.jpeg</url>
            <title>Stories by Tyrone Wilson on Medium</title>
            <link>https://medium.com/@tyrone.wilson?source=rss-5197bbd1d08------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 23:12:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tyrone.wilson/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[Demystifying the CPE Standard — A Layman’s Guide]]></title>
            <link>https://medium.com/@tyrone.wilson/demystifying-the-cpe-standard-a-laymans-guide-cd2ec03168cd?source=rss-5197bbd1d08------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd2ec03168cd</guid>
            <category><![CDATA[sbom]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[cpe]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Tyrone Wilson]]></dc:creator>
            <pubDate>Thu, 25 May 2023 07:03:01 GMT</pubDate>
            <atom:updated>2023-05-25T07:03:01.777Z</atom:updated>
            <content:encoded><![CDATA[<h3>Demystifying the CPE Standard — A Layman’s Guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qAUIHDODMEikBhLQbhKWw.jpeg" /><figcaption>Photo by Markus Spiske: <a href="https://www.pexels.com/photo/green-and-white-line-illustration-225769/">https://www.pexels.com/photo/green-and-white-line-illustration-225769/</a></figcaption></figure><p>If you’ve ever wondered about the standards that govern cyber products and software systems, you’ve probably come across the acronym “CPE.” For those who haven’t, CPE stands for “Common Platform Enumeration.” You might think that sounds technical, but don’t worry — I’m here to break it down.</p><h4>What is CPE?</h4><p>In its simplest form, CPE is a structured naming scheme. It’s a universal language for identifying and categorizing IT systems, software, and packages. Managed by the National Institute of Standards and Technology (NIST), it was developed to help facilitate better vulnerability and threat handling in the IT world. It’s kind of like the ISBN of the tech world. It provides a common language for different systems and security tools to share information about these platforms and software.</p><h4>Why is CPE Important?</h4><p>Imagine being a librarian with thousands of books and no system to organize them. It would be chaos, right? That’s how the IT world would be without CPE. Using CPE, security tools can effectively identify and communicate about specific pieces of software or hardware. This is vital in the ever-growing realm of cybersecurity, where threats must be identified, tracked, and mitigated across diverse systems.</p><h4>CPE in Action</h4><p>Here’s an example: suppose a new vulnerability is discovered in a particular version of a web server software. Once the software and version are given a unique CPE identifier, security tools across different organizations can identify whether they are running that software. If they are, they can then take the appropriate actions to mitigate the threat.</p><h4>CPE Naming Structure</h4><p>At its core, a CPE name is a text string that identifies a type and version of software or hardware. It uses a specific structure, which includes elements like part, vendor, product, version, and others. For instance, a CPE identifier for a particular version of Linux could look something like this: cpe:2.3:o:linux:linux_kernel:2.6.32.</p><p>Here’s what those bits mean:</p><p>- “cpe” is just the identifier to show it’s a CPE name.<br>- “2.3” is the CPE specification version.<br>- “o” stands for ‘operating system’ (it could also be ‘a’ for applications or ‘h’ for hardware).<br>- “linux” is the vendor.<br>- “linux_kernel” is the product.<br>- “2.6.32” is the version.</p><h4>Wrapping Up</h4><p>So there you have it, a simple explanation of the CPE standard! It’s a vital tool in the world of IT security, acting as a common language to identify and manage software and hardware across the cyber realm. It may seem technical, but at its heart, it’s just a system that helps keep our IT systems safer and more secure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd2ec03168cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resolving host identity in a distributed rails application]]></title>
            <link>https://medium.com/@tyrone.wilson/resolving-host-identity-in-a-distributed-rails-application-5cd97ca51028?source=rss-5197bbd1d08------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cd97ca51028</guid>
            <category><![CDATA[mqtt]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Tyrone Wilson]]></dc:creator>
            <pubDate>Tue, 11 Jul 2017 09:22:33 GMT</pubDate>
            <atom:updated>2017-07-11T09:22:33.373Z</atom:updated>
            <content:encoded><![CDATA[<p>Here at Black Swan Data, we are hard at work on a distributed ledger based system which is (in part) made up of remote nodes. In order to facilitate different data being added to the network we have a number of instances of an adaptor application which is used to pull messages onto a block-chain distributed ledger.</p><p>Events are sent to an MQTT broker and the messages are monitored to provide network-wide visibility and real-time debugging capability.</p><p>As part of the framework we set up for logging events and network health we needed to know which host node a message originated from so that we could distinguish and follow given nodes for debugging and general monitoring.</p><p>The application that is running and sending the notifications to the MQTT broker service is intended for use by any 3rd party wishing to use the network. So setting the host name would not always be possible and we had to come up with a solution to provide host identity in a reliable and meaningful way.</p><p>The requirements were established as follows: Provide the FQDN if possible, use the host’s IP as a backup and provide an override for any instance wishing to use something else. In addition, the solution would have to also work from a within a docker container.</p><p>The final solution turned out to be pretty simple and is outlined below.</p><pre>## Purpose<br># Events::MQTT is mostly a namespace but the module itself <br># provides useful MQTT related functionality that is applicable to<br># the whole application.</pre><pre>module Events<br>  module MQTT<br>    class &lt;&lt; self<br>      # Used by other classes that need to mention what node an<br>      # MQTT message comes from in a topic or message. The name can <br>      # be overriden by an ENV variable and preference is given to <br>      # FQDN and lastly the host&#39;s IP as a fallback. <br>      def node_name<br>        ENV[&#39;MQTT_APP_NAME&#39;] ||<br>        resolved_fqdn ||<br>        node_ip<br>      end</pre><pre>      def resolved_fqdn<br>        # Here we make sure we cache the results as the API calls <br>        # are expensive in terms of time<br>        Rails.cache.fetch(&quot;APP_FQDN&quot;, expires_in: 1.day) do<br>          begin<br>            Resolv.getname node_ip<br>          rescue Resolv::ResolvError =&gt; e<br>            puts &quot;unable to resolve #{node_ip} to a hostname&quot;</pre><pre>            # Returns nil so that the preference chain can continue<br>            return nil<br>          end<br>        end<br>      end</pre><pre>      def node_ip<br>        # We use the (now officially awesome) aws service to return<br>        # the true ip of our host instead of some system command so <br>        # that our code doesn&#39;t care if we are running inside a <br>        # docker container or not (which we are in our environment).<br>        Rails.cache.fetch(&quot;APP_REAL_IP&quot;, expires_in: 1.day) do            <br>          # Special thanks to <a href="https://stackoverflow.com/a/42142708/1212371">https://stackoverflow.com/a/42142708/1212371</a> for this bit of code :D Net::HTTP.get(URI.parse(&#39;<a href="http://checkip.amazonaws.com/&#39;)).squish">http://checkip.amazonaws.com/&#39;)).squish</a><br>        end<br>      end<br>    end<br>  end<br>end</pre><p>So far this is working well and has hooked seamlessly into the application.</p><p>Now anywhere that we want to mention the node name we simply do something like the following</p><pre>mqtt_client.publish(“/some/topic/#{Events::MQTT.node_name}/subtopic/”, “A message here”)</pre><p>And the mqtt channel looks like so</p><pre>/some/topic/my-host.com/subtopic A message here</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cd97ca51028" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails FileStore cache per environment]]></title>
            <link>https://medium.com/@tyrone.wilson/rails-filestore-cache-per-environment-ccf0fe1065fd?source=rss-5197bbd1d08------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccf0fe1065fd</guid>
            <category><![CDATA[rails-caching]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Tyrone Wilson]]></dc:creator>
            <pubDate>Fri, 23 Jun 2017 12:35:02 GMT</pubDate>
            <atom:updated>2017-08-01T06:17:32.891Z</atom:updated>
            <content:encoded><![CDATA[<p>I stumbled across and interesting problem today when we were trying to cache the state of login and logout for a CLI in one of our applications. In essence we needed to allow a user to login and maintain login state for subsequent CLI calls and since we were using Thor for our CLI in a rails app the easiest way to do this was using the built in Rails cache.</p><p>In order to facilitate caching in development we changed from the default :null_store for development caching to using :file_store so that we could keep state in development mode (which is when we use this cli)</p><p>However, we soon ran into issues with tests and development CLI caching conflicting. For example if someone logged in via the CLI and then ran the tests which have the following `before block.`</p><pre>before do<br>  Rails.cache.clear<br>end</pre><p>This ensured that the cache was clear for each new test but it also nuked our development cache.</p><p>When using a third party cache store like redis with rails, you can namespace your caches but we weren’t using something like that so what would we do. The solution to namespacing in this context is of course very simple. Just have a different folder for each environment’s cache.</p><p>So we added this to `config/application.rb`</p><pre>config.cache_store = :file_store, Rails.root.join(“tmp/cache/#{Rails.env}”)</pre><p>That was it. Now our caching in test and development are separate and still not using a third party solution. Now of course your use case may be different and in the case of using redis you can use namespacing in a similar fashion but for us this worked for what we needed.</p><h4>Feedback</h4><p>If you have any feedback, questions, queries, threats or suggestions I’d love to hear from you in the comments. Get in touch!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccf0fe1065fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Structuring Rails Modules]]></title>
            <link>https://medium.com/@tyrone.wilson/structuring-rails-modules-8dc85ef6bc74?source=rss-5197bbd1d08------2</link>
            <guid isPermaLink="false">https://medium.com/p/8dc85ef6bc74</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Tyrone Wilson]]></dc:creator>
            <pubDate>Wed, 22 Feb 2017 14:51:42 GMT</pubDate>
            <atom:updated>2017-02-22T15:22:22.335Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first began with Ruby on Rails a few years ago, I was a bit afraid to venture too far from the worn path of Model, Controller, View. Based on a fair bit of code I have read, I am not the only one.</p><p>Back in April 2012 when I first started developing with Ruby on Rails, I had done the <a href="https://www.railstutorial.org/">ruby on rails tutorial</a> and I was ready to rock. I knew about thin controllers, fat models and concerns. I had an idea of “Service Objects” but no matter how hard I tried, my code always ended up with long files and a fairly poor separation of concerns. I was the dreaded “noob” coder.</p><p>I searched for ways in which I could improve the design and layout of the applications I was writing. In doing so I read this <a href="http://www.poodr.com/">excellent book</a> by Sandi Metz on object oriented design. It was a treasure trove of great ideas and principles on generic ruby classes but I was stuck in my perceptions of “The Rails Way”. I understood what Sandi was talking about but wasn’t sure how to apply it to a rails app.</p><blockquote>One day I came to the realisation that most classes in your models directory shouldn’t be ActiveRecord models.</blockquote><p><strong>What I mean is this:</strong></p><p>Only make a class an ActiveRecord model if you absolutely have to and you only have to if it is going to work directly with the database. Need a method that fetches something from an external API? Put it somewhere else. Need a method that performs a few related changes in the database? You guessed it; put it somewhere else!</p><p><strong>Rails autoloading is awesome</strong></p><p>Through the “magic” of rails autoload_paths we are able to create a rich and descriptive set of classes within a module that are much more like the “Single Purpose” classes that Sandi speaks about in her book without worrying about load order.</p><p><strong>Test focus</strong></p><p>In addition to more focused classes, you will get more focused tests as a result of having smaller model classes.</p><p>Your tests will naturally be more granular because the classes being tested will have single responsibility and little to no dependencies enabling you to test each bit of functionality in isolation.</p><h3>Step 1: Create an outline</h3><p>Imagine for a minute that we need to integrate our app with a payment processing provider. We must keep track of the user’s payment methods and perform multiple actions with those payment methods. Imagine we need to have debit, credit, void, and refund routines in place. How would you structure your module? The old me would have created most if not all of those functions on a model defined as BankAccount &lt; ActiveRecord::Base or CreditCard &lt; ActiveRecord::Base and it would have grown to a couple hundred lines of code.</p><p>The new me would rather structure the code something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04e9be0004f1be78f31dc395402f13d1/href">https://medium.com/media/04e9be0004f1be78f31dc395402f13d1/href</a></iframe><p>As you can see in the outline of the app, only 4 files will have ActiveRecord classes in them. The rest encapsulate a single process or purpose.</p><p><strong>Use meaningful Error classes</strong></p><p>In addition to aptly named classes for doing work I also will usually opt to provide meaningful error classes. While this does not generally add any more functionality than a simple raise “Some error explanation&quot; style error, it helps in portraying intent for me and for other developers as well as making debugging far easier.</p><p><strong>Outline before writing code</strong></p><p>Having an outline for a module before actually writing the code; helps me think about the structure of my code and the logical pieces of functionality and get a head start in visualising what will evolve. I like to think in “Units of work” Each unit of work should have its own encapsulating class even if one unit is the sum of more units.</p><p>Now don’t get me wrong. I am not saying you should <em>create</em> all these files yet. Just outline them on paper before you start. Some files will make it some will not, but you will have a far better idea</p><h3>Step 2: Plug it in</h3><p>Regardless of the structure of you module you will always need to plug it in to your existing code in order to use it. In your controllers and similar components you will generally have an ActiveRecord model readily available which you will have fetched using a params[:id] or similar user input.</p><p><strong>Add syntactic sugar to taste</strong></p><p>Many times where you want to have a method on a class that does a unit of work you can provide simple no-fluff proxy methods for convenience but the actual business logic of running transactions of varying kinds no longer resides in your ActiveRecord model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16d964aae02e6a422518363341d61267/href">https://medium.com/media/16d964aae02e6a422518363341d61267/href</a></iframe><p>This approach has not only improved my code readability but it has also enabled the easy switch out of classes to do given tasks. The interface will also remain constant regardless of which utility class is doing the heavy lifting and will remain constant even if you change payment providers for example. This goes a long way towards meeting the mantra of “Open to extension and closed to change” that Sandi outlines in her book.</p><p><strong>Example anatomy of a non-ActiveRecord class</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c9a267ebfe3973b429bd8dead3a2355/href">https://medium.com/media/3c9a267ebfe3973b429bd8dead3a2355/href</a></iframe><h3><strong>Conclusion</strong></h3><p>One could argue that we should put non-rails classes in the lib directory or some such place. I would disagree with this for two main reasons:</p><ul><li>Related code should be kept together as much as possible to ensure proper encapsulation</li><li>When related code is together it is easier to extract if you decide that your module could be refactored into a gem</li></ul><p>I have found that coding rails modules in this style has freed me up to leverage the power of rails and the sanity of vanilla ruby.</p><p>I welcome any questions, queries, threats or suggestions :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8dc85ef6bc74" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>