Skip to content

Instantly share code, notes, and snippets.

@eviljeff
Last active January 3, 2017 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eviljeff/d8d7fdb36c1d91e60939625948f8f786 to your computer and use it in GitHub Desktop.
Save eviljeff/d8d7fdb36c1d91e60939625948f8f786 to your computer and use it in GitHub Desktop.
snippet to be run in django-admin shell `./manage.py shell` to bulk add certs from 'certs.txt' file in format [issuer: xx serial: yy].
from olympia.blocklist.models import BlocklistDetail, BlocklistIssuerCert
def addCert(issuer, serial, name, bug):
detail = BlocklistDetail(name=name, why='.', who='.', bug=bug)
detail.save()
cert = BlocklistIssuerCert(issuer=issuer, serial=serial, details=detail)
cert.save()
def handle(*args, **options):
fn = options['file']
name = options['name']
bug = options['bug']
with open(fn, 'r') as input_file:
for line in input_file:
[_, issuer, _, serial] = line.strip().split(' ')
if serial and issuer:
addCert(issuer, serial, name, bug)
bug = 'https://bugzilla.mozilla.org/show_bug.cgi?id=1312150'
name = 'Revoked intermediates'
ffile = 'certs.txt'
handle(bug=bug, name=name, file=ffile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment