def multi_date_number_servers(): ## given a list of gdb's, return number of servers by group and total ## output will be a dictionary (date as key) of dictionaries ## per-date dictionaries will have keys of groups and total ## input is two environmental variables: GDBPATH, DATELIST ## GDBPATH is path to graphdb directory ## DATELIST is ascii text of python list of dates of form yyyy.mm.dd ## initialize from env gdbpath = get_gdbpath() datelist = get_datelist() ## init output dict data = {} ## validate all the files exist ## so don't waste time processing a bunch to then have die filelist = [(d, gdbpath + d + ".gdb") for d in datelist] validate_file_access([f for (d, f) in filelist]) ## now process each file for (d, filename) in filelist: one_day_graph = load_graph(filename) ## init the day in output dictionary data[d] = {} data[d]['total'] = 0 for g in get_groups(one_day_graph): data[d][g] = 0 ## loop thru all the servers for svr in one_day_graph.neighbors("type_server"): data[d]['total'] += 1 ## find group and inc g = intermediate(one_day_graph, 'type_group', svr) data[d][g] += 1 return (data)
## initialize from env gdbpath = get_gdbpath() datelist = get_datelist() if( len(sys.argv) != 2 ): print("There should be one argument, filename for output image") exit() else: outfilename = sys.argv[1] ## validate all the files exist ## so don't waste time processing a bunch to then have die filelist = [ (d, gdbpath + d + ".gdb") for d in datelist ] validate_file_access([f for (d,f) in filelist]) ## dict to hold the data cvebins = {} ## now process each file for (d,filename) in filelist: cvebins[d] = {} graphdata = load_graph(filename) ## First make a list of all cve nodes ## i.e. all nodes connected to "type_cve" cves = graphdata.neighbors("type_cve") ## bin cve's by cvss score
## Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. import sys from load_db import load_graph from load_db import get_groups from load_db import server_by_group from sbom_helpers import get_gdbpath from sbom_helpers import mypprint from sbom_helpers import validate_file_access if( len(sys.argv) != 2 ): print("There should be one argument, date eg 2019.03.16") exit() else: d = sys.argv[1] gfile = get_gdbpath() + d + '.gdb' #validate gdb file exists validate_file_access([gfile]) graphdata = load_graph(gfile) groups = get_groups(graphdata) svr_list = graphdata.neighbors('type_server') svr_grp_dict = server_by_group(svr_list, groups, graphdata) mypprint(svr_grp_dict)
## Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. ## read pyt and make gdb import sys from load_db import load_file, save_graph from sbom_helpers import get_datapath from sbom_helpers import get_gdbpath from sbom_helpers import validate_file_access if( len(sys.argv) != 2 ): print("enter one argument as date eg 2019.03.16") exit() else: d = sys.argv[1] datapath = get_datapath() filename = datapath + 'svr.' + d + '.pyt' ## validate file access validate_file_access([filename]) ## get directory to put gdb in gdbpath = get_gdbpath() gfile = gdbpath + d + '.gdb' one_day_graph = load_file(filename) save_graph(one_day_graph, gfile) print('processed {0} '.format(filename))