<?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 Madeleine Rose on Medium]]></title>
        <description><![CDATA[Stories by Madeleine Rose on Medium]]></description>
        <link>https://medium.com/@madeleinerose?source=rss-657141be96eb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qrNoRGx2M2nBiwzQ.jpg</url>
            <title>Stories by Madeleine Rose on Medium</title>
            <link>https://medium.com/@madeleinerose?source=rss-657141be96eb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 05:50:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@madeleinerose/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[Honeypots and Rails Forms]]></title>
            <link>https://medium.com/@madeleinerose/what-s-a-honeypot-561dcca6d244?source=rss-657141be96eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/561dcca6d244</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Madeleine Rose]]></dc:creator>
            <pubDate>Tue, 12 Jan 2016 14:39:29 GMT</pubDate>
            <atom:updated>2016-01-12T14:45:15.846Z</atom:updated>
            <content:encoded><![CDATA[<h4>Making things a little less vulnerable</h4><h3>What’s a Honeypot?</h3><p>In espionage, a “<strong><em>honeypot</em></strong>” is a staggeringly attractive agent tasked with recruiting or coercing their counterpart using irresistible seduction techniques.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*oOZMFI9O1jivhAIzlgtFnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*HuTdhJCjH_vhq0v4TbbDGA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*3w8ynuH6s5xyGBITrEUksQ.jpeg" /><figcaption><strong>See Sterling Archer, Tatiana Romanova, &amp;&amp; Vesper Lynd.</strong></figcaption></figure><p>But in information systems, a honeypot is a security mechanism set to detect, deflect, or counteract attempts at any unauthorized use of systems. Usually, a honeypot consists of data that <em>appears</em> to be a legitimate part of the site but is actually isolated and monitored and used to identify and subsequently block hackers.</p><h3>It’s like a sting.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uc_YDbRug5fjMcs187bVYQ.jpeg" /></figure><h3>Er…</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*lC4OY9olqj7SGaNyFCmraA.jpeg" /></figure><p>Those of us behind the scenes for a system or application write honeypots to catch the bad guys by luring them in with easy (but not <em>too</em> easy) and attractive traps.</p><h3>What do honeypots trap?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Fjd_XAzOMuzlN3ethyVwGw.gif" /><figcaption><strong>Beez</strong>.</figcaption></figure><ul><li>Malware</li></ul><p>Small amounts of data are used as bait to detect the attack methods of malware. Example: using small amounts of bitcoin to monitor a possible malware infection.</p><ul><li>Spam</li></ul><p>Spammers abuse vulnerable resources such as <a href="https://en.wikipedia.org/wiki/Open_mail_relay">open mail relays</a> and <a href="https://en.wikipedia.org/wiki/Open_proxy">open proxies</a>. Some system administrators have created honeypot programs that masquerade as these abusable resources to discover spammer activity.</p><ul><li>Database intruders</li></ul><p>SQL injection — the intruder runs against a trap database while the web application remains functional.</p><p>These are the three categories you generally have to worry about. #hackerz</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*cf9w0s7sMTGbPSdYVKnEKQ.gif" /><figcaption><strong>Guys like this.</strong></figcaption></figure><h3>How can I use a Honeypot?</h3><p>Honeypot in Rails Forms:</p><p>Spambots LOVE forms. All those beautiful, fluid, functional forms we’ve been building in our apps are just waiting to be filled in by malicious hackerz. Honeypots are great for mitigating this problem, as they’re less invasive to your program than other anti-hacker options. And, with just the Rails skills we have right now, we can start writing our own honeypots into projects as needed.</p><p>Let’s look at writing our own honeypots.</p><h3>Forms</h3><p>A typical form honeypot is a field that only bots can see. We hide these fields to human users, but a bot will spam information into every field it can find without the confines of visible formatting. So basically, we will know a form submission is spammy if our hidden field has a value.</p><p>In your form, just add the extra field(s) that you’ll use to detect unauthorized submissions. Make sure to name it something normal so spam bots will populate it.</p><pre>fdsa &lt;%= form_tag form_submit_path do %&gt;  <br>&lt;fieldset&gt;    <br>&lt;legend&gt;Contact Info&lt;/legend&gt;<br>     <br>&lt;div class=&quot;form-group&quot;&gt;      <br>&lt;%= label_tag :name %&gt;      <br>&lt;%= text_field_tag :name %&gt;    <br>&lt;/div&gt;     </pre><pre>&lt;div class=&quot;form-group&quot;&gt;      <br>&lt;%= label_tag :email %&gt;      <br>&lt;%= text_field_tag :email %&gt;    <br>&lt;/div&gt;     </pre><pre>&lt;div class=&quot;form-group&quot;&gt;      <br>&lt;%= label_tag :phone %&gt;      <br>&lt;%= text_field_tag :phone %&gt;    <br>&lt;/div&gt;     </pre><pre><strong>&lt;div class=&quot;form-group honeypot&quot;&gt;      <br>&lt;%= label_tag :content %&gt;      <br>&lt;%= text_field_tag :content, nil%&gt;      <br>&lt;span class=&quot;help&quot;&gt;Do not fill in this field. It is an anti-spam measure.&lt;/span&gt; </strong><br>   <br>&lt;/div&gt;  <br>&lt;/fieldset&gt;  <br> <br>&lt;button type=&quot;submit&quot;&gt;Submit&lt;/button&gt;</pre><pre>&lt;%- end -%&gt;</pre><p>Again, this adds a field that a bot will automatically fill in, but a human will know to disregard.</p><p><strong>Add to controller:</strong></p><pre>class FormController &lt; ApplicationController<br><br>def submit<br><strong> SiteMailer.notify(params).deliver unless params[:content].present? </strong><br>   <br> flash[:success] = &quot;Your message has been submitted. Thank you!&quot;<br>    <br> redirect_to root_url<br> end<br><br>end</pre><h3>But what if I don’t like writing forms?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*50tTPF4A6MU3kCuFMxZgXw.gif" /><figcaption><strong>There’s a gem for that.</strong></figcaption></figure><h3>Honeypot Captcha</h3><blockquote><strong>“The simplest way to add honeypot captchas in your Rails forms.”</strong></blockquote><h4>Install and require:</h4><pre>// ♥ gem install honeypot-captcha</pre><pre>Fetching: honeypot-captcha-0.0.3.gem (100%)</pre><pre>Successfully installed honeypot-captcha-0.0.3</pre><pre>1 gem installed</pre><p>Add to your Gemfile:</p><pre>gem &#39;honeypot-captcha&#39;</pre><h4>Use form_for:</h4><p>Simply specify that the form has a honeypot in the HTML options hash:</p><pre>&lt;%= form_for Comment.new, :html =&gt; { :honeypot =&gt; true } do |form| -%&gt;<br>  ...<br>&lt;% end -%&gt;</pre><h4>Optional: Customize the honeypot fields:</h4><p>You can override the honeypot_fields method within ApplicationController to add your own custom field names and values. For example:</p><pre>def honeypot_fields<br>  {<br>    :my_custom_comment_body =&gt; &#39;Do not fill in this field, sucka!&#39;,<br>    :another_thingy =&gt; &#39;Really... do not fill out!&#39;<br>  }<br>end</pre><p>Then override the honeypot_string method within ApplicationController to disguise the string that will be included in the honeypot name. For example:</p><pre>def honeypot_string<br>  &#39;im-not-a-honeypot-at-all&#39;<br>end</pre><h3>While honeypots in and of themselves can’t protect your form against being filled in, they can help you identify and later block malicious users.</h3><p>Resources:</p><ul><li><a href="https://github.com/curtis/honeypot-captcha">curtis/honeypot-captcha</a></li><li><a href="http://nedbatchelder.com/text/stopbots.html">Ned Batchelder: Stopping spambots with hashes and honeypots</a></li><li><a href="http://haacked.com/archive/2007/09/11/honeypot-captcha.aspx/">You&#39;ve Been Haacked</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=561dcca6d244" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Regex Phobia]]></title>
            <link>https://medium.com/@madeleinerose/regular-expressions-breaking-the-phobia-c429663427ba?source=rss-657141be96eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c429663427ba</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Madeleine Rose]]></dc:creator>
            <pubDate>Wed, 09 Dec 2015 13:36:44 GMT</pubDate>
            <atom:updated>2015-12-09T18:11:02.219Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first encountered regular expressions as an undergrad (sort of) studying Python, I vividly remember it being <strong>the moment</strong> I quit. I took one look at the cryptic and scary-looking backslashes and punctuation marks and brackets and threw my hands up — I was done. So done. I was a tech hobbyist looking to add some “diversity” to my transcript, and knew with total certainty I’d never, ever encounter another regular expression in my life. I coasted through the last few weeks of the course and took my ill-deserved B+ with a smug smirk.</p><p>The regex-phobia was a huge hurdle I had to get over within the second week of classes at Flatiron, so I took to the internet to read what I could and try to first, understand what regex are, and second, start working with them and get familiar with their use.</p><p>On every tutorial (seriously, Google it), you’ll first encounter the statement:</p><blockquote>Regular expressions are just <strong>patterns</strong>.</blockquote><p>The conceptual explanation often stops there.</p><p>These benevolent coding gods bestowing their great wisdom upon new pilgrims of Ruby seem content to leave it at that and jump straight into things like match classes and complex functions.</p><p>So let’s take a moment and really break down exactly what we’re doing with regexes:</p><p>A regex is a pattern — a specific set of things in a specific order — that is either found in a string, or isn’t.</p><p>Think of it in terms of DNA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/1*YGOqASATVv2sDm-cePKyTA.gif" /><figcaption>DNA!!</figcaption></figure><p>Our regex is like a particular set of nucleobases — let’s say we’re looking for the pattern CGGT.</p><p>We can use Ruby syntax to quickly sift through a string of DNA and match it to CGGT:</p><pre>/CGGT/ =~ “AACT GATC CGGT GGTT”</pre><p>On the left, we have our regex, and on the right, we have a tiny section of DNA we’re looking through represented as a Ruby string. When we run this snippet of code, we’re asking Ruby if the pattern on the left exists somewhere in the string on the right. It does!</p><p>The expression is pretty flexible. We can also reverse the order of our code and Ruby will still know what we’re trying to do:</p><pre>“AACT GATC CCGT GGTT” =~ /CGGT/</pre><p>For some people, this format reads a little more intuitively. It follows a basic question structure in English: “Does this string contain this piece?” I personally prefer the first format, but remember, they’re both equally functional!</p><p>We can also use simple operators to see if a string does not contain a particular pattern, returning a boolean:</p><pre>/CGGT/ !~ “AACT GATC TTAG GGTT”</pre><p>would return true.</p><p>This is the basic logic behind regular expressions. Nothing cryptic or magical about it!</p><p>Basic matching is pretty cool, and an easy way to grasp the concept of regex in a way that’s unintimidating and easily digestible. But the rabbit hole goes way deeper, and there is some really powerful regex functionality in Ruby. For this blog, I wanted to experiment with some built-in regex that Ruby recognizes and we’ll see if they worked in my code from a previous lab.</p><p>Built-in regex:</p><pre>/[[:alnum:]]/ — Alphabetic and numeric character</pre><pre>/[[:alpha:]]/ — Alphabetic character</pre><pre>/[[:blank:]]/ — Space or tab</pre><pre>/[[:cntrl:]]/ — Control character</pre><pre>/[[:digit:]]/ — Digit</pre><pre>/[[:graph:]]/ — Non-blank character (excludes spaces, control characters, and similar)</pre><pre>/[[:lower:]]/ — Lowercase alphabetical character</pre><pre>/[[:print:]]/ — Like [:graph:], but includes the space character</pre><pre>/[[:punct:]]/ — Punctuation character</pre><pre>/[[:space:]]/ — Whitespace character </pre><pre>/[[:upper:]]/ — Uppercase alphabetical</pre><pre>/[[:xdigit:]]/ — Digit allowed in a hexadecimal number </pre><ul><li>source: <a href="http://ruby-doc.org/core-1.9.3/Regexp.html">http://ruby-doc.org/core-1.9.3/Regexp.html</a></li></ul><p>Looking at /[[:punct:]]/, I used this method in my count_sentences lab:</p><pre>class String<br>attr_accessor :string<br>def initialize<br>@string = string<br>end</pre><pre>def sentence?<br>self.end_with?(“.”)<br>end</pre><pre>def question?<br>self.end_with?(“?”)<br>end</pre><pre>def exclamation?<br>self.end_with?(“!”)<br>end</pre><pre>def count_sentences<br><strong>var = self.scan(/[[:punct:]]/)</strong><br>var2 = var.size<br>var2<br>end<br></pre><pre>end</pre><p>By manipulating with binding.pry in our Terminal, we can see the /[[:punct:]]/ expression selects for punctuation marks.</p><pre><strong>From:</strong> /Users/madeleinerose/Development/code/oo-counting-sentences-web-1115/lib/count_sentences.rb @ line 28 String#count_sentences:</pre><pre>def count_sentences<br>var = self.scan(/[[:punct:]]/)<br>var2 = var.size<br>var2</pre><pre>=&gt; <strong>28: binding.pry<br></strong>end</pre><pre>[1] pry(“one. two. three?”)&gt; var</pre><pre>=&gt; [<strong>“</strong>.<strong>”</strong>, <strong>“</strong>.<strong>”</strong>, <strong>“</strong>?<strong>”</strong>]</pre><pre>[2] pry(“one. two. three?”)&gt; var2</pre><pre>=&gt; <strong>3</strong></pre><pre>[3] pry(“one. two. three?”)&gt;</pre><p>By including our regex (represented in Ruby by the built-in function <strong>:punct:), </strong>we can <strong>scan</strong> each sentence our tests feed into #count_sentences and find periods, exclamations, or other punctuation marks and start working with them individually.</p><p>This is a one cool instance of what regex can do, but the real power comes from creating MatchData objects. MatchData is the object returned by Regexp#match and Regexp.last_match.</p><p>By creating this object, we can call methods upon it. See <a href="http://ruby-doc.org/core-1.9.3/MatchData.html">http://ruby-doc.org/core-1.9.3/MatchData.html</a> for more information.</p><p>In the coming weeks, we’ll dive more deeply into using regex and implementing match object functions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c429663427ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Iteration and Abstraction]]></title>
            <link>https://medium.com/@madeleinerose/iteration-and-abstraction-5537db946374?source=rss-657141be96eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/5537db946374</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Madeleine Rose]]></dc:creator>
            <pubDate>Tue, 08 Dec 2015 14:14:21 GMT</pubDate>
            <atom:updated>2015-12-08T14:14:21.864Z</atom:updated>
            <content:encoded><![CDATA[<p>The concept of iteration as an abstraction of looping took some time to grasp in technical detail. I had an intuitive understanding of what “iteration and abstraction” meant after reading the primer in our pre-work, but for the following few problem sets, I would timidly fall back to literal loop construction and even at the start of the second week knew what I was supposed to do with iterators like .each, .collect, .map., etc., but not why they’re included in Ruby’s framework or why they are subjectively more beautiful and objectively easier to work with when writing code.</p><h3>Literal</h3><pre>bucket <strong>=</strong> [&quot;thing 1&quot;,&quot;thing 2&quot;,&quot;thing 3&quot;,&quot;thing 4&quot;,&quot;thing 5&quot;]<br><br>bucket_of_things <strong>=</strong> bucket.<strong>size</strong> <em># Step 1</em><br>things_removed <strong>=</strong> 0 <em># Step 2</em><br><br><strong>loop</strong> <strong>do</strong> <em># Step 3</em><br>    <strong>if</strong> things_removed <strong>&lt;</strong> things_in_bucket <br>        <em># Step 4</em><br>        puts &quot;Taking out #{bucket[things_removed]}&quot;<br>        things_removed <strong>+=</strong> 1<br>    <strong>else</strong><br>        <em># Step 5</em><br>        <strong>break</strong><br>    <strong>end</strong><br><strong>end</strong></pre><p>The beauty of this method while learning is that each step is explicitly represented in the code; it’s easy to explain, and gives the student opportunity to dive deep and represent exactly what her program is trying to accomplish.</p><p>But this code is inefficient and there is lots of room for error. We also have to keep track of a lot of different variables, and manually enter and break out of our program.</p><h3>While/Until</h3><pre>bucket <strong>=</strong> [&quot;thing 1&quot;,&quot;thing 2&quot;,&quot;thing 3&quot;,&quot;thing 4&quot;,&quot;thing 5&quot;]<br><br>bucket_of_things <strong>=</strong> bucket.<strong>size</strong> <em># Step 1</em><br>things_removed <strong>=</strong> 0 <em># Step 2</em><br><br><em># Step 3 + 4</em><br><strong>while</strong> things_removed <strong>&lt;</strong> bucket_of_things<br>    puts &quot;Taking out #{bucket[things_removed]}&quot;<br>    things_removed <strong>+=</strong> 1<br><strong>end</strong></pre><p>Here, we’ve combined steps 4 and 5 and removed the need to manually break out of our program.</p><h3>Each (Collect, Map, Etc.)</h3><pre>bucket <strong>=</strong> [&quot;thing 1&quot;,&quot;thing 2&quot;,&quot;thing 3&quot;,&quot;thing 4&quot;,&quot;thing 5&quot;]<br><br><em># Step 1,2,3,4,5</em><br>bucket.<strong>each</strong> <strong>do</strong> <strong>|</strong>thing<strong>|</strong><br>    puts &quot;Taking out #{thing}&quot;<br><strong>end</strong></pre><p>The most abstract, yet the simplest! As the writers of our primer say, “Abstraction didn’t make our code less clear, it rather made our code ‘absolutely precise’.”</p><p>Using iterators is critical for two reasons; precision and beauty.</p><p>I’ve often heard it said that you can expect roughly 10 errors for every thousand lines of code. As a beginner, I can reasonably assume that rate is going to be much higher as I learn both the conceptual fundaments of programming, and the syntactically correct way to represent what I want my code to do. Cutting down the lines of code necessarily decreases the potential for errors and allows me to focus on the concepts of what we’re learning.</p><p>Objectively, it’s much easier to work with these iterators; you’re giving explicit instructions to your computer that are already represented in the way Ruby is set up. Furthermore, when collaborating on code, it’s far easier to make changes to few lines, wherein the functions we use are universally understood, than incorporate changes across many more lines and with varying idiosyncratic language.</p><p>Subjectively, brevity is beautiful. I actually disagree with another quote in our pre-work, that “brevity for the sake of brevity is silly.” Brevity is beauty. I’m a minimalist, always looking for the most efficient route. Perhaps that’s a carry-over from my introduction to programming with Python. When I can understand the logic of these iterators, and abstract out what I need my program to do, I can accomplish with two or even one line what had previously taken ten or more.</p><p>Resources: <a href="http://ruby-doc.org/core-2.2.3/Enumerable.html#method-i-collect">http://ruby-doc.org/core-2.2.3/Enumerable.html#method-i-collect</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5537db946374" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>