Import old talks from 2010 and 2011 (Boston).
[libguestfs-talks.git] / 2011-boston / handout / vulnerable.py
1 #!/usr/bin/python
2
3 import libxml2, re, sys
4 from distutils import version
5
6 doc = libxml2.readFd (sys.stdin.fileno(), None, None, 0)
7 ctx = doc.xpathNewContext()
8 res = ctx.xpathEval ("//application")
9 for node in res:
10     ctx.setContextNode(node)
11     name = ctx.xpathEval ("./name//text()")[0]
12     ver = ctx.xpathEval ("./version//text()")[0]
13     ver = version.StrictVersion (str(ver).split(' ')[0])
14     if re.search ("Mozilla Firefox", str(name)) and \
15             ver < version.StrictVersion ("3.6.16"):
16         print "Vulnerable version of Firefox found (%s)!" % ver