time.sleep(rate) r = bps.session.get(r['url']) r = r.json() print(key, ": ", r[key]) print("type :", r['type']) print("state :", r['state']) ######################################## # Login to BPS box bps = BPS(bps_system, bpsuser, bpspass) bps.login() print("Get the a description of the entire chassis:") chassis = bps.topology.get() pp(chassis) print("Get the details on one slot from the chassis:") slot = bps.topology.slot[slot_number].get() # in case the slot is not ready- wait for ports to become availlable retry = 10 while retry > 0 and not slot['port']: retry -= 1 print("The slot " + str(slot_number) + " has no ports - wait 20s (retry left %s)" % retry) time.sleep(20) slot = bps.topology.slot[slot_number].get() pp(slot)
while run_id in runningTests_Ids: run_state = bps.topology.runningTest[run_id].get() #print progress if test started try: print('progress: %s%% , runtime %ss' % (run_state['progress'], run_state['runtime'])) except: print("Starting...") time.sleep(2) #update the current running tests runningTests_Ids = [test['id'] for test in bps.topology.runningTest.get()] print("~The test finished the execution.") results = bps.reports.search(searchString=canned_test_name, limit=10, sort="endTime", sortorder="descending") result = results[0] print("%s execution duration %s ended with status: %s " % (result['name'], result['duration'], result['result'])) #getting 3.4 Section: Synopsys Summary of Results from the Report tabledata = bps.reports.getReportTable(runid=testid, sectionId="3.4") pp(tabledata) print("Unreserving the ports") for p in port_list: bps.topology.unreserve([{'slot': slot_number, 'port': p, 'group': 2}]) bps.logout()
print('Search evasion profile') evasionSearchResult = bps.evasionProfile.search(searchString = "allvariants", limit="", sort="", sortorder="") evasionProfileTemplate = evasionSearchResult[0] print ("Selecting Evasion Profile : %s \n %s" % (evasionProfileTemplate['label'],evasionProfileTemplate['description'] ) ) #configuring evasion profile #loading avasion profile template bps.evasionProfile.load(evasionProfileTemplate['name']) #fidn the options for setting in bps.evasionProfile.StrikeOptions.getStrikeOptions(): if setting['name'] == 'Variations': break print ("Availlable option for Strike Varinat testing are: ") pp (setting['options']) print ("Choosing variant VariantLimit from the available options") variations = { "VariantTesting": True, "TestType": "VariantLimit", "Limit": '100' } #patch varaint option with multiple parameters bps.evasionProfile.StrikeOptions.Variations.patch(variations) #set variant option with multiple parameters bps.evasionProfile.StrikeOptions.Variations.Shuffle.set(True) bps.evasionProfile.saveAs(new_evasion_profile, force = True) print('Configure with strike componenet with the created strikelist and evasions')
######################################## # Login to BPS box bps = BPS(bps_system, bpsuser, bpspass) bps.login() print("Import a test") status = bps.testmodel.importModel(importAsTestName, bpt_filename_to_import, True) print(" %s " % status) print("Search for the imported test") searchResult = bps.testmodel.search(searchString=importAsTestName, limit=5, sort="name", sortorder="ascending") print(searchResult) print("Load a test model") pp(bps.testmodel.load(template=importAsTestName)) name = bps.testmodel.name.get() print("Test Name: %s"%name) ######################################## print("Import a Network Config") status = bps.network.importNetwork(importAsNetworkName, networkfile_to_import, True) print(" %s " % status) print("Search for the imported network config.") nn_list = bps.network.search(searchString=importAsNetworkName, limit=10, sort="name", sortorder="ascending", clazz="", offset=0, userid="admin") pp(nn_list) print("Load the network config.") bps.network.load(template=importAsNetworkName)
print("~Wait for the initialization process ") init_progress = bps.topology.runningTest['TEST-%s' % run_id].initProgress.get() while (int(init_progress) <= 100 and runningTests["progress"] == None): init_progress = bps.topology.runningTest['TEST-%s' % run_id].initProgress.get() runningTests = bps.topology.runningTest['TEST-%s' % run_id].get() time.sleep(1) print("Initialization progress: %s%s" % (init_progress, '%')) print( "~Test is running untill 30% progress. Get l4Stats stats at every 2 seconds." ) progress = bps.topology.runningTest['TEST-%s' % run_id].progress.get() while (type(progress) == str and int(progress) <= 30): pp(bps.testmodel.realTimeStats(int(run_id), " l4Stats", -1)) progress = bps.topology.runningTest['TEST-%s' % run_id].progress.get() time.sleep(2) ######################################## print("~Cancel run") bps.topology.stopRun(run_id) print("~Wait for the stop completion ") while 'TEST-%s' % run_id in bps.topology.runningTest.get(): init_progress = bps.topology.runningTest['TEST-%s' % run_id].initProgress.get() time.sleep(1) print("stop progress: %s%s" % (init_progress, '%')) #getReportContents 1st 'IP Summary' section
######################################## print("Run test and Get Stats:") test_id_json = bps.testmodel.run(modelname=new_testmodel_name, group=2) testid = str( test_id_json["runid"] ) run_id = 'TEST-' + testid print("Test Run Id: %s"%run_id) #get the ids for all tests running on the chassis runningTests_Ids = [test['id'] for test in bps.topology.runningTest.get()] #wait while the test is still running while run_id in runningTests_Ids: run_state = bps.topology.runningTest[run_id].get() #print progress if test started try: #print ('progress: %s%% , runtime %ss' % (run_state['progress'], run_state['runtime'] )) pp(bps.testmodel.realTimeStats(int(testid), "attackStats", -1)) except: print ("Starting...") time.sleep(2) #update the current running tests runningTests_Ids = [test['id'] for test in bps.topology.runningTest.get()] ##################### #Do not allow malware traffic on the test ports - anymore without conmfirmation bps.administration.userSettings.changeUserSetting(name = 'allowMalware' , value = False) ###################### print("~The test finished the execution.") results = bps.reports.search(searchString=new_testmodel_name, limit=10, sort="endTime", sortorder="descending") result = results[0] print ("%s execution duration %s ended with status: %s " % (result['name'], result['duration'], result['result']) ) #getting 3.4 Section: Synopsys Summary of Results from the Report
limit=2, sort="name", sortorder="ascending") print "Search result after save: " print test print "Clone the components: " bps.testmodel.clone('routingrobot_1', 'routingrobot', True) bps.testmodel.clone("appsim_1", 'appsim', True) print "Change name for the cloned componets:" bps.testmodel.component["appsim_2"].set({"label": "App2"}) bps.testmodel.component["routingrobot_2"].set({"label": "RR2"}) print "Components Status: " pp(bps.testmodel.component.get()) print "Disable the RR components: " bps.testmodel.component["routingrobot_1"].active.set(False) bps.testmodel.component["routingrobot_2"].active.set(False) ######################################## print "Save test:" bps.testmodel.save() ######################################## print "Reserve Ports" for p in port_list: bps.topology.reserve([{'slot': slot_number, 'port': p, 'group': 1}]) ########################################
"delete": True }, 'tls_ciphers4': { "delete": True }, 'tls_ciphers5': { "delete": True } } bps.superflow.actions[1].patch(disableParameters) #set action 1 TLS version to TLSv1.2 -> internal name 'TLS_VERSION_3_3' (visible when in UI when mouse hovering over the action parameter value) bps.superflow.actions[1].set({'tls_max_version': 'TLS_VERSION_3_3'}) #display action 1 parameters after being set pp(bps.superflow.actions[1].get()) print("Save the current working superflow under a new name.") bps.superflow.saveAs(new_superflow_name, True) print("Add action 2") bps.superflow.addAction(flowid=1, type="tls_start", actionid=2, source="client") print("Add action 3") bps.superflow.addAction(1, "register_request", 3, "client") print("Save the superflow under the same name") bps.superflow.saveAs(new_superflow_name, force=True)
limit=2, sort="name", sortorder="ascending") print("Search result after save: ") print(test) print("Clone the components: ") bps.testmodel.clone('routingrobot_1', 'routingrobot', True) bps.testmodel.clone("appsim_1", 'appsim', True) print("Change name for the cloned componets:") bps.testmodel.component["appsim_2"].set({"label": "App2"}) bps.testmodel.component["routingrobot_2"].set({"label": "RR2"}) print("Components Status: ") pp(bps.testmodel.component.get()) print("Disable the RR components: ") bps.testmodel.component["routingrobot_1"].active.set(False) bps.testmodel.component["routingrobot_2"].active.set(False) ######################################## print("Save test:") bps.testmodel.save() ######################################## print("Reserve Ports") for p in port_list: bps.topology.reserve([{'slot': slot_number, 'port': p, 'group': 1}]) ########################################