spaces = re.compile('\s+') dots = re.compile('( \.|\.\. )') syndesc = re.compile('( *Synopsis: *| *Description:)') pipe = re.compile('[ ]*\\|[ ]*') # Split Synopsis and Description from "extra" data # Fix a bunch of crappy Plugin descriptions solution= re.compile('(Solution:|Risk factor:|CVSS|Plugin output:|See also:|CVE:|BID:)') gmt = re.compile('GMT(\!|\.)') fix = re.compile('(10287|10330|10662|10863|10919|11011|11033|11153|11936|12053|12245|17975|18528|19506)\\|(1|2|3)') def clean_nbe(data): #### The clean up process. #### Order of operations is important data = data.replace('\\n',' ') data = spaces.sub(' ',data) data = data.replace(' :',':') data = dots.sub('.',data) data = syndesc.sub('',data) data = data.replace('TRACE|TRACK','TRACE[pipe]TRACK') data = data.replace('the the','the') data = data.replace(' interfer ',' interfere ') data = gmt.sub('GMT\\1|Renew the SSL certificate for the remote server.',data,count=1) data = solution.sub('|\\1',data,count=1) data = pipe.sub('|',data) data = data.rstrip(' ') data = data.replace('Security Note','1') data = data.replace('Security Warning','2') data = data.replace('Security Hole','3') data = fix.sub('\\1|\\2|',data) data = data.replace('\\\\','\\') return data