chg: [importer] parent option added - to reference an parent CyCAT OID

main
Alexandre Dulaunoy 2021-05-24 17:04:03 +02:00
parent c2bb0c4989
commit 52dd1c4a67
No known key found for this signature in database
GPG Key ID: 09E2CD4944E6CBCD
1 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import os
parser = argparse.ArgumentParser(description='JSON importer for CyCAT backend')
parser.add_argument('-f', '--file', help='JSON file to import')
parser.add_argument('-t', '--type', help='CyCAT backend type', default=1)
parser.add_argument('-p', '--parent', help='Parent reference to add for the JSON imported', default=None)
args = parser.parse_args()
r = redis.Redis(host='127.0.0.1', port='3033')
@ -32,5 +33,8 @@ elif int(args.type) == 2:
k = "t:{}".format(args.type)
r.zadd(k, d, nx=False)
r.hmset("{}:{}".format(args.type, uuid), record)
if args.parent is not None:
r.sadd("parent:{}".format(uuid), args.parent)
r.sadd("child:{}".format(args.parent), uuid)
else:
pass