Look, I get it, audits and auditors are a necessary evil. But the sheer volume of crappy code, hack-y scripts, man-hours, and alcohol, dedicated to meeting the often arbitrary, sometimes ridiculous, and possibly even downright obscene requirements, of said auditors, is staggering. There are entire product suites dedicate to help you “report on” or “meet/pass” audits of various kinds. And thank god for those. Because without them, we’d all be slightly more insane than we already are.
I’m not crazy; my mother had me tested. And my rubber duck agrees.
Here’s an example.
In one of our main applications, at the database level (
SQL), we’ve implemented poor-man’s data-change-tracking via table triggers. In a past audit, there was a “flag” on an unauthorized data change. As a result, an “exception report” was created, which basically produces a daily
CSV dump of those changes and emails it to a few managers. Now, because the tracking table includes “who” as well as “when” & “what”, and there are certain privileged accounts that can be ignored for auditing, and because there are dozens of application users whose app-controlled changes are also logged in said tracking table (and need to be ignored), the “report” writer at the time decided it was a wonderful (read: terrible) idea to hard-code a list of usernames into the query that produces this data-dump.
That is horrible. Never do that!
This query, the job that scheduled it, the data that it produced, and the emails that it sent, were subsequently filed away and silently forgotten about. Until we did some environment cleanup and discovered “Oh look, here’s a thing that’s not doing anything” (because the hard-coded list of users was now woefully out of date), and the same managers who received the reports for years past, gave the OK to disable the job!
What could possibly go wrong?
Then the next audit season comes around. And guess who comes running back to the DBA having changed his mind? Why yes, that very same manager!
So I tell him what we need to do to fix it — remove the hard-coded list, replace it with an AD group or at least a look-up table that can be periodically updated with “current” users in the desired departments/teams. We do that, and the CSV dump goes from zero to huge. As in, too huge for email. So we try to pare it down. We get it to a manageable size. Then we get ready to deploy the changes and confirm the desired email recipients.
- Boss: “Oh it doesn’t really matter, we just ignore the emails anyway… it’s just to satisfy an audit requirement.”
- Me: “So why did we even bother fixing it?”
- Boss: “Well, it was broken!”
- Me: “…”
I’d like the last hour of my life back please.
Here’s another fun one.
The ERP system has a rickety tack-on audit-trail system involving some SQL Agent Jobs and an obscenely large data repository for storing all the changes that the ERP system users make every hour of every day. Thankfully, somebody along the way was prescient enough to
partition those storage tables using a partitioned view scheme. But apparently there were NOT smart enough to realize that the clustered index needs to be the
datetime column. Yes, it was in the
primary key, but that PK was not clustered (nor should it have been, since the actual unique keys were
GUIDs, but this is a prime example of making the clustering key different and separate from the PK.
Obviously enough, in a
date-driven partitioned view scheme, that
date does need to be involved in the PK also. But again, the best
clustered index is just that
date, because A) it’s the partition divider, and B) it’s always your queries’ main filter-predicate (which is a fancy way of saying “the thing in your JOIN/WHERE clauses”).
Once again, audit season comes around, and someone needs those reports driven by these audit-trail repos. And guess what? They’re slow as molasses.
So we get to spend another few hours applying the correct
clustered indexes, waiting for them to rebuild, testing the queries for the report, and finally running the report itself. Oh and don’t forget the down-time of the jobs, and having to “catch up” with all the changes that were made in the ERP system while we were working on all this.
Is it 5 o’clock yet?
Audits suck. But please, stop producing crappy code in response. It just makes the next guy/gal that comes after you even more frustrated than he/she already is with the whole process. Practice the “boy scout principle” — leave things at least a little better than you found them. And if you’re forced to produce a ridiculous “exception report” that nobody will ever read, spend as little time on it as possible while still making it less heinous than the last terribly designed monstrosity.