Last active
December 24, 2015 22:39
-
-
Save kf0jvt/6874634 to your computer and use it in GitHub Desktop.
Common stuff that I use in VCDB maintenance
This file contains 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
import json | |
import os | |
from datetime import datetime | |
import uuid | |
# i = getIncident('blahblahblah.json') | |
def getIncident(inString): | |
return json.loads(open(inString).read()) | |
# updateIncident(i, 'blahblahblah.json', True) | |
def updateIncident(i,inFilename,validated=False): | |
i['plus']['modified'] = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ') | |
if validated: | |
i['plus']['analysis_status'] = "Validated" | |
outfile = open(inFilename,'w') | |
outfile.write(json.dumps(i,sort_keys=True, indent=2,separators=(',', ': '))) | |
outfile.close() | |
# putIncident(i, 'blackfist') | |
def putIncident(i, analyst="blackfist"): | |
i['plus']['analyst'] = analyst | |
i['plus']['created'] = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ') | |
identity = str(uuid.uuid4()).upper() | |
i['incident_id'] = identity | |
i['plus']['master_id'] = identity | |
i['source'] = 'vcdb' | |
outfile = open(identity + '.json','w') | |
outfile.write(json.dumps(i,sort_keys=True, indent=2,separators=(',', ': '))) | |
outfile.close() | |
# show(i['some.variable']) | |
def show(inDict): | |
print json.dumps(inDict,sort_keys=True,indent=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment