-
-
Save jasonthomas/efce4ccf549cf640f82e914d7a54ee8f 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].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=1315199' | |
name = 'Revoked intermediates' | |
ffile = '/var/tmp/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