def runner(args, mdb=None): token = args.token e_type = args.entity_type mode = args.mode output_type = args.output_type index_min, index_max = get_indexes(args, mdb) print "Getting all IOCs between index times" all_iocs = get_all_iocs(token, e_type, index_min, index_max) print " %s IOCs" % len(all_iocs) iocs_keys = all_iocs.keys() for ioc_chunk in _chunks(iocs_keys, 250): print " Chunk: %s" % len(ioc_chunk) iocs = {} for ioc in ioc_chunk: iocs[ioc] = all_iocs[ioc] enricher = IOCEnricher(token, iocs, e_type, mode) print " Enriching chunked IOCs" enriched_iocs, max_index = enricher.enrich() print " Writing..." if output_type in ("csv", "json"): output_file = args.output_file write_references(enriched_iocs, enricher.get_keys(), output_type, output_file) return None elif output_type == 'mongo': res = write_to_db(enriched_iocs, mdb) write_max_index(mdb, max_index) return res
def runner(args): token = args.token e_type = args.entity_type mode = args.mode output_type = args.output_type output_file = args.output_file iocs = args.ioc enricher = IOCEnricher(token, iocs, e_type, mode) enriched_iocs, max_index = enricher.enrich() write_references(enriched_iocs, enricher.get_keys(), output_type, output_file)