summaryrefslogtreecommitdiffstats
path: root/scripts/ubuntu-usn-desc
blob: c1b07d2cfa5c2936b844c19cb00efbfcf1c01e8d (plain) (blame)
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
#!/usr/bin/env python
# Dumps the Ubuntu-Descriptions in a form suitable for a USN announcement
import sys, deb822

def wrap(text, width):
    """
    A word-wrap function that preserves existing line breaks
    and most spaces in the text. Expects that existing line
    breaks are posix newlines (\n).
    """
    return reduce(lambda line, word, width=width: '%s%s%s' %
                  (line,
                   ' \n'[(len(line)-line.rfind('\n')-1
                         + len(word.split('\n',1)[0]
                              ) >= width)],
                   word),
                  text.split(' ')
                 )

for cve in sys.argv[1:]:
    if cve == "--cve":
        continue
    desc = deb822.deb822(file(cve))['Ubuntu-Description'].strip()
    if len(sys.argv[1:])!=1:
        desc += " (%s)"%cve
        print
    print wrap(desc,75)

© 2014-2024 Faster IT GmbH | imprint | privacy policy