1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import sys
from subprocess import call
from BeautifulSoup import BeautifulSoup
from os import remove

def print_report( cvelist ):

    for cve in cvelist:

        cve_file = 'CVE-DIR/%s' % cve

        try:
            open( cve_file )
        except IOError:
            call( [
              'wget',
              'https://access.redhat.com/security/cve/%s' % cve,
              '--output-document=%s' % cve_file,
              '-q',
             ] )

        print "\n<h2>%s</h2>\n" % cve

        try:
            f = open( cve_file )
            page = f.read()
            f.close()
        except:
            print "<blockquote class='indent'><br><b>No Vendor Response</b></blockquote>"
            continue

        soup = BeautifulSoup( page )

        #print "\n<h2>%s</h2>\n" % soup.h1.string

        description = soup.blockquote
        print description

        vendor_response =  soup.find( "table", { "class" : "docstable" } )
        if vendor_response:
            print "<blockquote class='indent'>%s</blockquote>" % vendor_response
        else:
            print "<blockquote class='indent'><br><b>No Vendor Response</b></blockquote>"

        print "<br/><br/><hr/>"


if __name__ == '__main__':
    patchweek = sys.argv[1]
    cvelist = sys.argv[2:]
    if not cvelist:
        cvelist = """
        CVE-2012-2136
        CVE-2012-1014
        CVE-2012-1015
        CVE-2012-3437
        CVE-2012-2373
        CVE-2012-2745
        CVE-2012-2652
        CVE-2012-3440
        CVE-2012-3452
        CVE-2012-3450
        CVE-2012-3445
        """.split()

    print "<h1>Linux Vulns</h1>\n <h2>Our next patch cycle is %s</h2> \n\n<br/><br/>" % patchweek
    print_report( cvelist )