![]() |
![]() |
|
December 30, 2003Security Testing with csUnitRecently I have been wrestling with the idea of providing unit testing within our codebase. Wim has put up some good info pointers in his Miniwiki about automated unit testing, which included a link to csUnit, a C# unit testing framework. Nick Smith wrote a good article on how to Write Unit Tests for C#, although he uses dotUnit, which is a .NET branch of JUnit, a unit testing framework for Java. It seems clean enough, but for some reason I like csUnit better. No real intellectual basis for this... just a feeling. Not sure why. This DOES have me thinking about security tests in my .NET code though. There is no reason that these test harnesses cannot be retrofitted to supply security testing per method. I just am not sure I like how the 'extreme programming' community approach unit testing in this regard. I don't know how practical it is to write the tests BEFORE the code. I think it would be easier to write the initial security tests for each method once the method is written, so you know what to test for, and more importantly what the resiliency reaction should be in the face parameter validation, tainted data injection, state manipulation etc. Another important tangent to this is trying to make this integrate across the project scope and build scripts. Unlike C, C# did not appear to have clear preprocessor directives, to ensure the tests are not compiled into the IL for production release builds. Scott originally thought using ConditionalAttributes would work out, and later found that there are tonnes of #if#else conditions and other C# preprocessor directives. Seems no one knows about them... but they ARE there. I love learning something new every day. Now if/when I implement this I can go write tonnes of C style DEBUG blocks around the testing framework. What are other peoples experience with this? Anyone out there doing C# unit testing? Any focused on security testing? Posted by SilverStr at December 30, 2003 08:14 AM | TrackBackComments
I haven't used C#, but I have programmed test first for several years and find test-driven design as described in Kent Beck's books to be the most powerful of all the XP practices. Writing the unit tests first not only helps you design the interfaces to your classes, but also forces you to consider the possible types of dangerous inputs before writing your code. However, it's worth noting that in XP you don't write all your tests first, then write your code. Instead, you write tests for a feature, implement the feature, check your tests, then realize you want to make some changes and so write more tests for your changes in an iterative process. If you realize that you need more tests after writing the code, XP practices readily accepts that fact too, but by requiring you to test first, XP gets you to think in depth about the problems your code might have before you write it. While you hopefully already think like this during the design process, putting that thought into test code makes it more concrete and precise, and thus better able to detect problems in your code. Also, by integrating testing so closely with coding, XP ensures that you have your tests early in the development process when they're most useful to you. Posted by: jwalden at December 31, 2003 08:07 AM |
![]() ![]()
My 5 Favorite Books
Writing Secure Code
Secure Programming Cookbook Security Engineering Secure Coding Principles & Practice Inside the Security Mind ![]()
My 5 Favorite Papers
Smashing the Stack
Penetration Studies Covert Channel Analysis of Trusted Systems DoD Trusted Computer System Evaluation Criteria NSA Security Recommendation Guides ![]()
Archives
January 2007
December 2006 November 2006 October 2006 September 2006 August 2006 July 2006 June 2006 May 2006 April 2006 March 2006 February 2006 January 2006 December 2005 November 2005 October 2005 September 2005 August 2005 July 2005 June 2005 May 2005 April 2005 March 2005 February 2005 January 2005 December 2004 November 2004 October 2004 September 2004 August 2004 July 2004 June 2004 May 2004 April 2004 March 2004 February 2004 January 2004 December 2003 November 2003 October 2003 September 2003 August 2003 July 2003 June 2003 May 2003 April 2003 March 2003 February 2003 January 2003 December 2002 November 2002 October 2002 September 2002 August 2002 July 2002 ![]() |
|