Skip to main content

Ralsina.Me — Roberto Alsina's website

SPF test suite on RASPF

Here are the re­sults as of right now:

  • Give the ex­pec­t­ed re­­sult­s: 82 tests

  • Give the wrong re­­sult: 48 tests

  • Give a cor­rect but not pre­­ferred re­­sult (most­­ly be­­cause of SPF records and IPv6): 6 tests

  • Fail (crash): 9 tests

So, de­pend­ing on how you look at it, RASPF pass­es be­tween 61% and 56% of the test­s.

Not bad so far :-)

Up­date: As of 20:52 ART, it's 105/0/35/5 and 72-76%. The bad news is that that was all the low hang­ing fruit, and now it gets much hard­er.

My SPF library kinda works

RaSPF, my at­tempt­ed port of PySPF to C is now at a very spe­cial point in its life:

The pro­vid­ed CLI ap­pli­ca­tion can check SPF records and tell you what you should do with them!

Here's an ex­am­ple:

[ralsina@monty build]$ ./raspfquery --ip=192.0.2.1 --sender=03.spf1-test.mailzone.com --helo=03.spf1-test.mailzone.com
Checking SPF with:

sender: 03.spf1-test.mailzone.com
helo:   03.spf1-test.mailzone.com
ip:     192.0.2.1


response:       softfail
code:           250
explanation:    domain owner discourages use of this host

Is that cor­rec­t? Ap­par­ent­ly yes!

[ralsina@monty pyspf-2.0.2]$ python spf.py 192.0.2.1 03.spf1-test.mailzone.com 03.spf1-test.mailzone.com
('softfail', 250, 'domain owner discourages use of this host')

Is it use­ful? Sure­ly you jest!

There are still the fol­low­ing prob­lem­s:

  • The mem­o­ry man­age­­ment is un­ex­is­­tant

  • I need to hack a way to run the of­­fi­­cial SPF test suite so I can see how well it work­s and that it works ex­ac­t­­ly as PySPF

  • It prob­a­bly will seg­­fault on many places

  • I am chang­ing the er­ror han­dling to be ex­­cep­­tion-based, thanks to EX­CC

  • The IPv6 sup­­port is be­tween iffy and not there

  • There is no sup­­port for SPF (type 99) DNS record­s, on­­ly TXT records (need to hack the udns li­brary)

But re­al­ly, this should be about 60% of the work, and it does work for some cas­es, which is more than I re­al­ly ex­pect­ed at the be­gin­ning.

Here's the whole source code of the sam­ple ap­pli­ca­tion (ex­cept for CLI op­tion pro­cess­ing):

spf_init();
spf_response r=spf_check(ip,sender,helo,0,0);
printf ("\nresponse:\t%s\ncode:\t\t%d\nexplanation:\t\t%s\n",
        r.response,r.code,r.explanation);

Some kind of landmark

As of right now, my cus­tomers owe me more than I billed in the sec­ond half of last year, and more comes due each month.

I sup­pose that's bad be­cause I am suck­ing at col­lect­ing. On the oth­er hand, it al­so means I am not suck­ing at billing. Or maybe yes, but much less than last year.

New look for this blog.

Af­ter many years, this is the first rad­i­cal change of look.

It's not very nice, be­cause my HTML skil­lz sux0rz, but hey, it's dark­er!

There are many lit­tle things wrong (like the col­or of vis­it­ed links) but I like it.

It's al­so a bit sim­pler, and I did the ban­ner us­ing inkscape (I had it done much nicer us­ing Kar­bon, but then I could­n't fig­ure out how to do the gra­di­en­t. Oh, well).

Up­date1: It looks in­cred­i­bly aw­ful on IE6, from the un­trans­par­ente PNG to the un­sup­port­ed over­flow:au­to I think I caught ev­ery damn thing that does­n't work :-)

Update2: Both IE and Konqueror will not use overflow: auto if the object is inside a table. In a blog that posts code and logs, and so on, that's a big problem.

So, to make this kin­da work, I had to get rid of (al­most) all ta­bles.

It looks ok now, ex­cept on IE the side­bar is at the bot­tom right, which is prob­a­bly be­cause it cal­cu­lates el­e­ment widths dif­fer­ent­ly.

My SPF lib improving

It now can do a bunch of things like ex­pand­ing macros and (in some cas­es) val­i­dat­ing mech­a­nism­s.

I am mak­ing very heavy use of unit test­ing, be­cause it's a pret­ty com­plex piece and each ­func­tion needs to do ex­act­ly the right thing or ev­ery­thing else fails (it's pret­ty hard to fig­ure out where it will fail ;-)

You can check the 947 LOC thing at http://­code.­google.­com/p/raspf (the Code tab).

If you do check it, jeep in mind the fol­low­ing:

  • It us­es a few lib­s, and they are in­­­clud­ed in the source code for sim­­plic­i­­ty.

  • I do some­­times com­mit code that does­n't com­pile

  • I do some­­times com­mit code that fails tests

  • You need cmake

  • I am not giv­ing a damn about mem­o­ry man­age­­ment right now, so don't both­­er wor­ry­ing about leak­s: ev­ery­thing leaks in this code. I want to make it func­­tion­al first, then I can plug it one func­­tion at a time (sim­­ply by run­n­ing the unit test­ing code with a mem­o­ry check­­er).

En­joy (although it's not pre­cise­ly en­joy­able code right now ;-)