Friday, August 19, 2005

Script to detect a modified file

Some times it is necessary to detect whether a file has been modified before performing a number of activities. These activities could be defensive in nature if the file was not to be changed for security reasons, for example, or it could be routine in nature such as archiving the file. Here is an example script that will identify a file change.

The script simply runs a infinite loop that checks whether the fingerprint of the file (the md5 checksum) has been modified. If it detects a change the script will notify the administrator via an email.

#!/bin/sh
target=target.txt
baseline=/tmp/passwd.base
timer=60
md5sum $target > $baseline
while [ 1 = 1 ] ; do
if [ "`md5sum $target`" != "`cat $baseline`" ] ; then
echo File $target was changed at `date` mail -s "$target changed!" root
exit
fi
sleep $timer
done

However, the reader should note that the above file will not detect changes if the intruder made an attempt to cover his tracks. One way of detecting whether someone has changed files and then covered his tracks is to use the suditing facilities provided within the operating system kernel. For example is Solaris, the reader could use the BSM audit facility to determine who did what to the file under consideration.

The applications every java developer needs in his/her portfolio

Other Tools
XDoclet - This tool will save you lots of time. It generates code based of metatags added by the developer to his code.
JBrowser - Helps you peek into a library to determine what its interfaces look like. There are a number of situations where you may not be able to decompile a library but will be allowed to inspect it for its interfaces. Hey its a little better than code without any documentation.
InstallAnywhere - If you ahve installed an application by yourself, chances are that you ahve used installAnywhere. It supports the installation of software onto virtually any platform.
JavaDoc - FOr God's sake and the love of a fellow java developer who will come after document your code. With a tool like javadoc, the only excuse you really have to not writing well documented code is your own laziness.
WinZip - I do not need to add much, when it comes to this tool. It can help you peek into libraries, move compressed code via email (remember that time when CVS just did not work) and much much more.
APT - The annotation processing tool is new with the latest release of Java. It works the same wonders by enabling the use of metatags. Might signal the end of XDoclet.
ExtCheck - This tool helps resolve conflicts within java libraries.
Ant - Like its real world counterpart, this tool lifts ten times its weight. Its flexibility allows a developer to create utilities on the fly if needed.

Decompilers
Jad - If you have ever had to maintain Java code for which no documentation was available, then you understand how miserable life can be. This decompiler, does a decent job of unpackaging archives and generating the source code. Now tie this in with any reverse engineering tool that ships with most commercial grade design application and voila, you have a object model that can help keep suicidal thoughts at bay.

Debuggers
Assure - If threads are what you love then this tool will assuredly help you fly. It helps walk through some of the grittiest thread contention problems.

Text Editors
Notepad - A standard utility that is shipe with every Windows install. It is very handy for viewing content of files and eliminating garbage characters
EditPlus - A step above notepad but not yet a full fleged IDE. Allows for multiple syntax, text highlighting and ftp.


IDE
Eclipse - This freeware version is rapidly becoming the IDE of choice in the Open Source world. It is built on an open framework, has tons of plugins that make most tasks like ORM mapping a breeze.

Continuous Integration
Cruise Control - Another open source application that allows for running test scripts and prescheduled times. Perfect for moving most of the automated testing to off peak hours when developers are not around.

Unit Testing
Junit - 'Never has so much been owed to so little code' - Martin Fowler. Need I say more. If you believe in test oriented development then this is a must have.
JCover - If you need to ensure that your testing covers the code adequately, then JCover will help you go a long way. The great thing aobut it are the metrics it generates. THe fluff guys on the team really like those.

Bug Tracking
In house - no hooks to source control

Profiling
Jprofiler and Jprobe

Source Code Control
CVS - With this in place your programmer cannot use the "Computer ate my homework" excuse.

Build Tools
JAR and WAR Files (not sure what they are thinking here?)


Application Framework
Spring

Grid Computing Framework
DataSynapse

Logging
Jakarta commons logging

XML
javax.xml

Web Front-end
Struts
Spring/Tiles

ORM/Database
Hibernate
TOAD - This tool is definitely the best on the market. It is a pity that it now comes with a license and one has to pony up quite a penny for it. But the time and effort that are saved are invaluable.

Messaging
Joram

Reporting
JFreeChart - THis utility allows you to create nifty charts and integrate them into your reports. Worth a try