Skip to content

Instantly share code, notes, and snippets.

@agustingianni
Created September 19, 2019 10:13
Show Gist options
  • Save agustingianni/dac2a8d708f880ac87433ce024f95491 to your computer and use it in GitHub Desktop.
Save agustingianni/dac2a8d708f880ac87433ce024f95491 to your computer and use it in GitHub Desktop.
from git import *
import time
import sys
import re
import urllib2
from multiprocessing import Pool
import multiprocessing
import cgi
WEBKIT_REPO = "/home/agustin/workspace/WebKit"
HTML5_HEADER = """<!DOCTYPE html>
<html>
<head>
<style>
h3 {
font-family: verdana, arial, helvetica, sans-serif;
color: blue;
}
p {
font-family: verdana, arial, helvetica, sans-serif;
}
.bugzilla {
}
.keywords {
}
.message {
color: grey;
font-family: monospace;
}
</style>
"""
HTML5_FOOTER = """</body>
</html>"""
repo = Repo(WEBKIT_REPO)
interesting_commiters = ["evans", "schuh", "inferno"]
interesting_commit_keywords = ["crash", "security", "use after free", "use-after-free", "uninitialized memory", "buffer overflow"]
def is_interesting_commiter(commiter):
for person in interesting_commiters:
if person in commiter:
return True
return False
def has_interesting_bug_commit(bug_url):
return
if "bugs.webkit.org" in bug_url:
buffer = urllib2.urlopen(bug_url).read()
if "You are not authorized to access bug" in buffer:
return True
return False
def has_interesting_keywords(commit_message):
commit_message = commit_message.lower()
matched_keywords = []
for keyword in interesting_commit_keywords:
if keyword in commit_message:
matched_keywords.append(keyword)
return matched_keywords
print HTML5_HEADER
for c in repo.iter_commits('master'):
# We do not search for commits before 2010
if time.gmtime(c.committed_date).tm_year < 2010:
break
is_interesting = False
# Get all the urls on the commit message
interesting_urls = filter(has_interesting_bug_commit, re.findall(r'https?://\S+', c.message))
interesting_keywords = has_interesting_keywords(c.message)
if is_interesting_commiter(str(c.committer)) or \
len(interesting_keywords) or \
len(interesting_urls) != 0:
print "<h3>" + "Interesting commit by %s on %s" % (c.committer, time.asctime(time.gmtime(c.committed_date))) + "</h3>"
if len(interesting_urls):
print "<p class='bugzilla'>" + "Bugzilla blocked urls" + "</p>"
for interesting_url in interesting_urls:
print "<p>" + "Private bugzilla at %s" % (interesting_url) + "</p>"
if len(interesting_keywords):
print "<p class='keywords'>" + "Interesting keywords matched:" + "</p>"
print "<p>" + "%s" % ",".join(interesting_keywords) + "</p>"
print "<p>" + "Commit message:" + "</p>"
try:
print "<pre class='message'>"
for line in cgi.escape(c.message).split("\n"):
print line
print "</pre>"
except:
print "<p>UNICODE Fail</p>"
print HTML5_FOOTER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment