Code auditing with Google
October 5th, 2006 by dmitryc, Filed under: Commentary, Google, Web
So, I must have been under a rock for the last few weeks, because I *just* heard about google’s codesearch. Wow. So, I wanted to test some of my regex expressions against public code. Here are a few examples. I could (and will) play with this for days, but I just wanted to post a few links:
User-supplied variable used in an OpenTextFile query
Write unsanitized user input into a browser
If there was one thing that I wish the google interface had, it would have to be the ability to reference a variable within a query. For instance, if I want to look for calls to strncpy where the third argument is sizeof(2nd argument):
strncpy(foo,hoo,sizeof(hoo));
then it would be nice to be able to create a query like
strncpy\s*\(.*,\s*([^\s]+)\s*,\s*sizeof\s*\(.*\)\s*\); sizeof\s*\(\s*\1\s*\)
where the first query set $1 (or \1) to hoo and the second query looks for sizeof(hoo)
And, if there was two things I could wish for, it would be multi-line matching…for instance, it would be nice to look for both private key formatting and private key headers
Peace,
!Dmitry




Pingback: ベイエリア情報局