Subscribe to the MPC blog rss feed feed-icon-14x14
 

RDefensio A Framework Agnostic Ruby Library For Defensio

Posted on 09:15PM on 10/29/2008
Tags: RDefensio, defensio

Yesterday, I posted about switching this blog over to Defensio. Today I'd like to look briefly at how I went about integrating it.

Defensio provides an API against which you can make HTTP posts. This is a pretty straightforward thing. I simply wrote a library that makes it a little less low-level.

The code is on GitHub, here.

The library is designed to be framework agnostic and to have as few dependencies as possible. The specs rely on RSpec, but that's about all that it requires.

Configuration

 

For any app, the first thing that needs to be done to use RDefensio is to configure it. You must have an API key from Defensio. This site is built with Sinatra, so I configure RDefensio within a Sinatra configure block:

The owner url is simply the url you registered with Defensio when you signed up. In my case, it's http://mattpayne.ca/blog

If you're using Rails, this could be done in an initializer.

That's all it takes to configure it.

Usage

 

Well, Defensio exposes several API methods that can be called. RDefensio mirrors them.

All of these methods return an OpenStruct object that represents the result of the post to Defensio.

The get_stats method is particularly useful if you want to display information about your Defensio interactions. It will return values for # of spam comments, # of false positives, # of false negatives and several other nice informational items

That's it for my post about RDefensio. It seems to be working well for me over the past few days.

0 Comments (Show) (Comments are closed for this post)

Keep Your Post Comments Spam Free With Defensio

Posted on 04:15AM on 10/29/2008
Tags: defensio

A few days ago, I talked about adding Akismet functionality to this blog on top of an existing captcha implementation. Ironically, there was a bug in the new code that prevented anyone from commenting! I guess that's one way to reduce comment spam.

The person that let me know about the problem was Carl Mercier, of Karabunga. Karabunga is a Canadian development shop near Montreal that has developed a spam filtering service called Defensio.

First and foremost, let me say that I don't get a lot of spam. I also don't get much traffic, so I guess that makes sense ;) Spam is still a concern to me though. I think it looks ugly and takes away from the real content.

I wasn't overly happy with my Akismet/captcha combination in the first place. The captcha is a bit of a hassle to read and many people dislike entering them. Plus, according to Carl, captchas are not terribly secure anymore as people are beginning to hire humans to solve them. I don't have any real issues with Akismet, but I wasn't entirely happy with my implementation of the two together. I decided that perhaps the entire commenting component of my blog should be rewritten - this time using Defensio.

Why Defensio? I'm not going to do a comparison with Akismet here; several folks have already done that here and here and, I'm sure, in many other places. Suffice it to say that I liked what I saw:

  • Defensio has the ability to learn. The more you work with it, the smarter it gets about you and what you believe to constitute spam.
  • It provides "spaminess" ratings for submitted comments.
  • It promotes transparency in terms of making people aware of how well you, as a blogger, are doing in combination with the Defensio service. I like that.
  • Defensio has a nice API.
  • Defensio is Canadian-made (have be a little patriotic after all).
There are a couple of things to keep in mind:
  • Defensio learns through your interactions with it, so initially it may not be too "smart".
  • There is a bit of comment maintenance to deal with since someone has to handle the ones that may or may not be spam.

Personally, I'd rather have more control than not enough.

It was a slow weekend, so I removed all of the captcha and Akismet functionality and replaced it with the new Defensio functionality.

As a result of this effort, I also created a framework agnostic Ruby library for accessing the Defensio API. I call it RDefensio. Why framework agnostic? I like framework agnostic code and I use Sinatra for this site. For the folks looking to incorporate Defensio into a big established framework like Rails or .NET, I suggest taking a look at Defensio's download page, here.

Anyway, that's it for now. Maybe a few comments would allow me to test the system ... ;)

0 Comments (Show) (Comments are closed for this post)

Please note that I am currently unavailable for any large, long term work.