Category: Blog

  • Security Sadness

    I got this offer in email today.

    security_a

    My wife likes the X-Men, I’m not traveling, and this seemed like a good idea. I clicked and saw this page:

    security_b

    It’s from the Fandango domain, which I’ve used before. I have a United VISA. However I just can’t trust that I can actually enter this data in this form. It’s entirely possible this is a man in the middle attack, and that worries me.

    It’s sad that I can’t trust things like this anymore. It’s the same reason I don’t even talk to telemarketers anymore. Even when it’s a good cause, I just can’t trust any random “offer” that comes to me. I’m sure that I can’t even trust those offers I find myself, but it’s going to be a problem more and more. Whether it impacts commerce, I don’t know. Entirely too many people don’t care about security and $20 in free movie stuff would have them typing in their credit card number.

    I went to the United site and didn’t see the offer. I went to Fandango and same thing.

    Oh well, I guess I’ll buy my own tickets.

  • Secure Coding

    I was looking recently for some sort of guideline that would help me ensure that code was securely written. I stumbled upon the CERT standards, of which there are few, but one that seemed interesting was this one on Oracle and Java. I thought this first standard was a great explanation of good and bad code that you could use for this particular problem.

    I looked for something similar from Microsoft. I found this, which seems more like a random collection of links that don’t teach, or lead, anyone through the ideas of how to write better code.

    In some ways, Microsoft has produced a microcosm of the Internet. A mish mosh of lots of information with no organization applied at all.

  • Filetable–Moving files programmatically

    I’ve been playing with Filetable and I was asked an interesting question. Can I move files to a folder programmatically?

    It’s trivial to do this in Explorer. Just drag and drop, and I’d expect that most people using Filetable from the client side would do this. I’d even expect that lots of programmers might use Powershell and the

    However suppose I loaded a bunch of documents into the Filetable folder and I needed to move or process them. I certainly could handle this easily from the client, but it’s actually simpler to do this from T-SQL.

    The Example

    Let’s say I have a few files in the root of my Filetable as shown in this image. My Filetable is the Explorer table inside this path.

    filetable_c

    If I check this from T-SQL, I see four rows I my table. Two jpgs and two pngs. The jpgs are books and I want to move them into a separate folder.

    filetable_a

    I decide to set up a folder inside of this structure. I can do that, using the technique from another post to create a folder from T-SQL. I create the “Books” folder and now If I look at how this appears in the table, it’s like this:

    filetable_b

    In the share it looks like this:

    filetable_d

    What I want is to now set the parent_path_locator of the jpgs to be that of the Books folder. However I can’t update that field as it’s a computed column. However I can update the path_locator of the two rows and compute a new HierarchyID value that includes the path_locator of the Books folder.

    The way to do this is similar to how I would add a file to a folder. I use this code to computer the new HierarchyID and update the existing rows.

    DECLARE @path HIERARCHYID
    DECLARE @new_path VARCHAR(675)
     
    SELECT  @path = path_locator
    FROM    dbo.Explorer
    WHERE   name = 'Books'
    
    SELECT  @new_path = @path.ToString()
            + CONVERT(VARCHAR(20), CONVERT(BIGINT, SUBSTRING(CONVERT(BINARY(16), NEWID()),
                                                             1, 6))) + '.'
            + CONVERT(VARCHAR(20), CONVERT(BIGINT, SUBSTRING(CONVERT(BINARY(16), NEWID()),
                                                             7, 6))) + '.'
            + CONVERT(VARCHAR(20), CONVERT(BIGINT, SUBSTRING(CONVERT(BINARY(16), NEWID()),
                                                             13, 4))) + '/'
     
    Update dbo.Explorer
          SET path_locator = @new_path
          WHERE name = 'Cleankill.jpg'

    Once this is done I see the share looking like this:

    filetable_f

    Here’s the root of the share, and you can see my file has been moved.

    filetable_e

    I repeat this for the other file, though I could potentially have wrapped this all up into one statement. This easily moves my files to the subdirectory in my Filetable.

  • Friday Fun

    Someone at Red Gate sent around a request for the current version of our logo. I’m not sure why it changes so much, but it certainly has a lot over the years. In any case, while they got a real response, I sent this one as a joke.

    rglogo1

    I got chastised by another employee, who said it was clearly this one

    rglogo2

    If you haven’t seen our DBA Team series, here’s article 2. Worth a read.