def devtree_exaples(): print('DEVTREE #1 : Simple devtree printing') devtree = DevTree() print(devtree) print(devtree.get_text(format='csv')) print( devtree.get_text(format='prettytable', fields=[ 'ds_ip', 'client', 'last_time', 'model', 'name', 'parent_name', 'vendor' ])) print('len : {}'.format(len(devtree))) print('__iter__ print') [print(str(f)[:80] + '.[..]') for f in devtree] # print('repr : {}'.format(repr(devtree))) print('DEVTREE #2 : Add a DataSource') # Find the first device that's a receiver to use as the DataSource parent ds_config = {} for ds in devtree: if ds['desc_id'] in ['2', '13']: ds_config['parent_id'] = ds['ds_id'] ds_config['name'] = 'msiempy_test_datasource_delete_me' ds_config['ds_ip'] = '0.20.5.5' ds_config['type_id'] = '65' print('Adding datasource...') print('Result ID: ', devtree.add(ds_config)) print('DEVTREE #2.1 : DataSource details...') ds = devtree.search('msiempy_test_datasource_delete_me') if ds: ds.load_details() else: print('New datasource not found. Waiting 15 seconds and rechecking...') time.sleep(15) devtree.refresh() ds = devtree.search('msiempy_test_datasource_delete_me') if ds: ds.load_details() print('DETAILS: {}'.format(ds.json)) print('DEVTREE #3 : Deleting DataSource') for ds in devtree: if ds['name'] == 'msiempy_test_datasource_delete_me': print('Test datasource found. Deleting...') ds = devtree[ds['idx']] ds.delete() continue print('DEVTREE #3.1 : Verifying the datasource is gone') for ds in devtree: assert ds[ 'name'] != 'msiempy_test_datasource_delete_me', "Looks like the datasource is still here :/"
def print_devtree(self): print('DEVTREE #1 : Simple devtree printing') devtree = DevTree() print(devtree) #print(list(devtree)) print(devtree.get_text(format='csv')) print( devtree.get_text(format='prettytable', fields=[ 'ds_ip', 'client', 'last_time', 'model', 'name', 'parent_name', 'vendor' ]))
def print_devtree(self): print("DEVTREE #1 : Simple devtree printing") devtree = DevTree() print(devtree) # print(list(devtree)) print(devtree.get_text(format="csv")) print( devtree.get_text( format="prettytable", fields=[ "ds_ip", "client", "last_time", "model", "name", "parent_name", "vendor", ], ))
""" Quick python code to list all McAfee SIEM Datasources """ import pandas from msiempy.device import DevTree devtree = DevTree() print("All Datasources") print(devtree.get_text(fields=["parent_name", "name", "ds_id"])) df = pandas.DataFrame(devtree) print("Datasources grouped by parent") print( df.groupby("parent_name")["name"] .apply(lambda x: ", ".join(x)) .reset_index() .to_string(index=False) )
""" Quick python code to list all McAfee SIEM Datasources """ import pandas from msiempy.device import DevTree devtree = DevTree() print("All Datasources") print(devtree.get_text(fields=['parent_name', 'name'])) df = pandas.DataFrame(devtree) print("Datasources grouped by parent") print(df.groupby("parent_name")['name'].apply(lambda x: ', '.join(x)).reset_index().to_string(index=False))
def devtree_exaples(): print("DEVTREE #1 : Simple devtree printing") devtree = DevTree() print(devtree) print(devtree.get_text(format="csv")) print( devtree.get_text( format="prettytable", fields=[ "ds_ip", "client", "last_time", "model", "name", "parent_name", "vendor", ], )) print("len : {}".format(len(devtree))) print("__iter__ print") [print(str(f)[:80] + ".[..]") for f in devtree] # print('repr : {}'.format(repr(devtree))) print("DEVTREE #2 : Add a DataSource") # Find the first device that's a receiver to use as the DataSource parent ds_config = {} for ds in devtree: if ds["desc_id"] in ["2", "13"]: ds_config["parent_id"] = ds["ds_id"] ds_config["name"] = "msiempy_test_datasource_delete_me" ds_config["ds_ip"] = "0.20.5.5" ds_config["type_id"] = "65" print("Adding datasource...") print("Result ID: ", devtree.add(ds_config)) print("DEVTREE #2.1 : DataSource details...") ds = devtree.search("msiempy_test_datasource_delete_me") if ds: ds.load_details() else: print("New datasource not found. Waiting 15 seconds and rechecking...") time.sleep(15) devtree.refresh() ds = devtree.search("msiempy_test_datasource_delete_me") if ds: ds.load_details() print("DETAILS: {}".format(ds.json)) print("DEVTREE #3 : Deleting DataSource") for ds in devtree: if ds["name"] == "msiempy_test_datasource_delete_me": print("Test datasource found. Deleting...") ds = devtree[ds["idx"]] ds.delete() continue print("DEVTREE #3.1 : Verifying the datasource is gone") for ds in devtree: assert (ds["name"] != "msiempy_test_datasource_delete_me" ), "Looks like the datasource is still here :/"