import os from scrubber import Scrubber import BeautifulSoup #import BeautifulSoup # initialise the scrubber! all this stuff is overriding scrubber defaults so hack it to bits if you want! scrubber = Scrubber(autolink=False) scrubber.allowed_tags = set(( 'a', 'abbr', 'acronym', 'b', 'bdo', 'big', 'blockquote', 'br', 'center', 'cite', 'code', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5',
# # Web frontend for CVE -> RHSA report generator. # # Requires CherryPy, Mako, Scrubber, Python <= 2.7 import rhsac import cherrypy import os import re import sqlite3 from mako.template import Template from mako.lookup import TemplateLookup from scrubber import Scrubber tlu = TemplateLookup(directories=['templates']) scrubber = Scrubber(autolink=True) curdir = os.path.join(os.getcwd(), os.path.dirname(__file__)) cherrypy.config.update({ 'tools.staticdir.root': curdir, 'server.environment': 'production' }) fixemph = re.compile('!!FIX!!') class RHSAGenWeb: @cherrypy.expose def index(self, snmp=False): return tlu.get_template("index.html").render(snmp=snmp)
import gzip import os.path from scrubber import Scrubber s = Scrubber(.025) file = './all.tsv.gz' # Make sure we've got the data file locally if not os.path.exists(file): print 'Missing GPS data:', file else: gps = gzip.open(file, 'r').readlines() # secondary j iterator used to prevent doulbe testing / dropping of points j = 0 for i in xrange(1, len(gps)): j = i if j == len(gps) else j p1 = gps[j - 1].strip().split('\t') p2 = gps[j].strip().split('\t') if (p1[0] == p2[0]): keep = s.keep([float(p1[2]), float(p1[3])], [float(p2[2]), float(p2[3])]) if not keep: j += 1 print 'Dropping point:', p2 #i, keep, p1, p2 j += 1
def setUp(self): self.scrubber = Scrubber()
from django import template from django.utils.safestring import mark_safe import markdown from scrubber import Scrubber register = template.Library() scrubber = Scrubber( autolink=False, nofollow=False) # Scrubber's autolink doesn't handle ftp:// md = markdown.Markdown(extensions=['nl2br', 'autolink']) @register.filter(is_safe=True) def safe_markdown(value, arg=''): return mark_safe(scrubber.scrub(md.reset().convert(value)))