summaryrefslogtreecommitdiffstats
path: root/contrib/secbugstats/bin/fillbugtable.py
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-02-13 16:17:20 +0100
committerGitHub <noreply@github.com>2018-02-13 16:17:20 +0100
commit95e5e0588df0057fbefd3a05e6203c7f8e92ab09 (patch)
tree9e659a6608402a73ebdb49ca06c289af9c349e6e /contrib/secbugstats/bin/fillbugtable.py
parent2b916fccae0df60b350369c6fc827c1c9ce1030e (diff)
downloadbugzilla-95e5e0588df0057fbefd3a05e6203c7f8e92ab09.tar.gz
bugzilla-95e5e0588df0057fbefd3a05e6203c7f8e92ab09.tar.xz
Bug 1343248 - Migrate secbugstats scripts to bmo production
Diffstat (limited to 'contrib/secbugstats/bin/fillbugtable.py')
-rwxr-xr-xcontrib/secbugstats/bin/fillbugtable.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/contrib/secbugstats/bin/fillbugtable.py b/contrib/secbugstats/bin/fillbugtable.py
new file mode 100755
index 000000000..7f991a12d
--- /dev/null
+++ b/contrib/secbugstats/bin/fillbugtable.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+# Fill the secbugs_Bugs table
+# Should not be run regularly as it runs bugdata.py (API script) on every
+# bug_id we have stored in the DB.
+import sys, MySQLdb, os
+from settings import *
+
+if "--debug" in sys.argv:
+ DEBUG = True
+else:
+ DEBUG = False
+
+# set up database connection
+db = MySQLdb.connect(host=DB_HOST, user=DB_USER, passwd=DB_PASS, db=DB_NAME)
+db.autocommit(True)
+cur = db.cursor()
+
+severities = ["sg_critical","sg_high","sg_moderate","sg_low"]
+
+for sev in severities:
+ sql = "SELECT d.bug_list FROM secbugs_Details d WHERE d.sid IN (SELECT s.sid FROM secbugs_Stats s WHERE category='%s' and date > '2008-07-01');" % (sev)
+ # complete list of bugs for this severity level
+ complete = []
+ # print "#", sql
+ cur.execute(sql)
+ row = cur.fetchone()
+ while row is not None:
+ # row e.g. ('408736,430127',)
+ # print "# ", row
+ bugs = row[0].split(",")
+ for bug in bugs:
+ if len(bug): complete.append(bug)
+ row = cur.fetchone()
+
+ unique = list(set(complete))
+ print "Going to fetch data for %d %s bugs..." % (len(unique), sev[3:])
+
+ for bug in unique:
+ cmd = "%s/bugdata.py %s" % (SCRIPTS_DIR, bug)
+ print cmd
+ if not DEBUG: os.popen(cmd)