Skip to main content

php

Nessus XML Validation

Tenable Network Security no longer provides a DTD for Nessus 4.2 reports. I'm working on adding Nessus support to OpenFISMA, and wanted to be able to validate that the XML that I was processing from a user was in fact the correct format. I ended up using Instance2Scehma to generate the RNG schema, and then used Trang to generate other schemas that might be useful to other people.

So, XMLReader in PHP is a little bit weird, and you can't validate the XML until you start reading it. And XMLReader won't throw validation exceptions, so you can't put your reading into a try/catch and stop processing once you find out that there's an error. Bummer. What you can do though, is do your processing, check for errors, and then persist the data after checking to make sure that the XML is valid.

<?php
$xmlReader = new XMLReader();
$xmlReader->open('report.nessus');
$xmlReader->setRelaxNGSchema('schema.rng');

while($xmlReader->read()) {
  // process XML ...
}

if($xmlReader->isValid()) {
  // persist data
} else {
  // handle invalid XML
  throw new Exception('Bad XML.');
}
?>

Schema files are attached in a variety of formats at the bottom of this post.

So, MyPhotoAlbum.com acquired some of the Photrade.com assets ...

So, as most people know, I was one of the developers who worked on Photrade up until we ran out of money, and couldn't find anymore funding. One of the biggest things I did there was build out the YUI based photo management interfaces, and I built out the entire server infrastructure. The site has apparently been limping around with no active development since October.

To my surprise, I received this in my spam folder today:

Dear Photrade Users,

At the end of 2008 you were informed by the owners of Photrade.com that they had lost their funding and would not continue to develop the website. And at some point earlier this year, all of the full sized images that had been uploaded to Photrade were deleted. I hope you kept a backup copy of your images.

Last month, MyPhotoAlbum Inc. acquired some of the Photrade.com assets. We will be adapting some of the Photrade.com technology to enhance the MyPhotoAlbum.com service. Please note that we also own and operate dotPhoto.com.

We invite you to try the MyPhotoAlbum photo service and are pleased to offer you complimentary use of our Club Membership subscription service for one year - FREE. Simply sign up for a FREE MyPhotoAlbum account and then drop a line to our Support Team at <a href="http://support.myphotoalbum.com" title="http://support.myphotoalbum.com">http://support.myphotoalbum.com</a>, quoting reference PHOTRADE to receive your free upgrade.

Please note that we will be announcing the MyPhotoAlbum Pro Service within a month that will include all of the Photrade services and more!

If you have any questions please do not hesitate to contact me at peter@myphotoalbum.com.

Thanks,
Peter Macnee
CEO, MyPhotoAlbum Inc.

Well, isn't that interesting. I've never even heard of MyPhotoAlbum. Oh, and I hold equity in Photrade. But that doesn't really matter, because I'm sure any money that was made from selling off these assets went to the original investors and/or to payoff the enormous amount of debt that Photrade has racked up keeping the site running since October. Those servers at EC2 are expensive, and I was laid off before given a chance to scale back the server infrastructure to keep things afloat longer. Whoops. Brilliant move by the original investors/board of advisors/CEO. Let's lay everybody off to scale back our benefit and salary costs, but not try to scale back any other costs.

Regardless, I'm guessing the reason that MyPhotoAlbum bought "some assets" instead of the whole company, is because Photrade is probably going to file for bankruptcy, to get out of the debt that's been racked up. And nobody wants to buy debt, obviously.

Anyways, there's a particular part of the email that is interesting to me.

And at some point earlier this year, all of the full sized images that had been uploaded to Photrade were deleted. I hope you kept a backup copy of your images.

This, my friends, is completely false. All of those images are STILL there. Half a terrabyte plus of images are still laying around on EC2. They're not lost, the database isn't corrupt, the images aren't corrupt. Either somebody was lied to in this deal, somebody is dumb and doesn't know what they're talking about, or Photrade/MyPhotoAlbum doesn't feel like spending the half hour to build a script to allow Photrade users to download their original photos. Which, by the way, if Peter is reading this, I'd be more than happy to build such a script/page for free. Our users were awesome, it just sucks that the company was so horribly managed, for all parties involved.

Anyways, I sent an e-mail to Peter, no idea if he'll respond or not, letting him know that the images actually still exist at this moment. I'll probably get sued by somebody over this post, I think my NDA still applies for a few more months. But hey, I'm a poor man right now, and I think that Photrade is probably just as poor. If the company wants to sue me for some debt, awesome, I'll give it up, no problem.

How-to: Replace Keys of an Array in PHP

Posted in

I had a need tonight to replace the keys in an array in PHP. I couldn't find a good solution on any mailing lists or other sites, so I thought I'd share the class that I came up with, and it's test.

First up, the test:

<?php
require_once 'PHPUnit/Framework.php';
require_once 'ArrayHelper.class.php';

class ArrayHelperTest extends PHPUnit_Framework_TestCase
{
  public function testRenameKeys()
  {
    $keys   = array('newkey1',
                    'newkey2',
                    'newkey3');
                   
    $array  = array('oldkey1' => 'value1',
                    'oldkey2' => 'value2',
                    'oldkey3' => 'value3');
                   
    ArrayHelper::renameKeys($array,$keys);
   
    $this->assertArrayHasKey($keys[0],$array);
    $this->assertArrayHasKey($keys[1],$array);
    $this->assertArrayHasKey($keys[2],$array);
    $this->assertEquals(3,count($array));
  }
}

Next, the class itself, after the jump.

Removed captcha, added mollom

So, I've decided to try out this mollom thing, created by Drupal's fearless leader, Dries.

We'll see how it works, it sounds cool and useful, in theory.

SalesForce Web Services

Useful for me, maybe not for anybody else. Lots of good sample code here and full API specifications for the Salesforce.com Web Services that are available.

http://wiki.apexdevnet.com/index.php/Web_Services_API

New Book to Review

Posted in

Thanks to APress, I’ve got a copy of PHP Objects, Patterns, and Practice (Second Edition) to review. It’s just happening to sit next to the first edition. Matt Zandstra, I’d appreciate your autograph and personal message on both copies. I’m sure that some day a signed first-edition will be worth something.

Syndicate content