Code auditing with Google

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

Disable warnings

CDONTS, my new leetle Fren

SQL query One

SQL query two

SQL query three

SQL query four

SQL query five

Crypto One

Crypto Two

Old School One

Old School Two

Old School Three

Random injection

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

Share