@@ -350,7 +350,135 @@ def format_stats_dict_as_table(self, stats_dict={}):
350350
351351 lines = ['|' .join ([f'{ val :^{col_width }} ' for val , col_width in zip (item , col_widths )]) for item in zip (* stats_dict .values ())]
352352 return [line_delim , header , line_delim ] + lines + [line_delim ]
353-
353+
354+ def set_prisma_airs_params (self , session , pan_auth_token , airs_profile_name = None , airs_profile_id = None ):
355+ # Update Attacks
356+ prisma_airs_attacks_found = False
357+ try :
358+ attack_profiles = session .config .config .attack_profiles
359+ if not attack_profiles :
360+ raise ValueError ("No attack profiles found in the session configuration." )
361+ for attack in attack_profiles [0 ].attacks :
362+ if "Prisma AIRS" not in attack .name :
363+ continue
364+ for track in attack .tracks :
365+ for action in track .actions :
366+ for param in action .params :
367+ if param .name == "PAN auth token" :
368+ prisma_airs_attacks_found = True
369+ param .value = pan_auth_token
370+ print (f"Updated PAN auth token for attack: { attack .name } " )
371+ elif param .name == "AIRS Profile Name" and airs_profile_name :
372+ param .value = airs_profile_name
373+ print (f"Updated AIRS Profile Name for attack: { attack .name } " )
374+ elif param .name == "AIRS Profile ID" and airs_profile_id :
375+ param .value = airs_profile_id
376+ print (f"Updated AIRS Profile ID for attack: { attack .name } " )
377+ param .update ()
378+ except AttributeError as e :
379+ print (f"Error while setting Prisma AIRS params: { e } " )
380+ except Exception as e :
381+ print (f"Unexpected error while setting Prisma AIRS params: { e } " )
382+ if not prisma_airs_attacks_found :
383+ print ("No Prisma AIRS Attacks found in the provided session." )
384+
385+ # Update Applications
386+ prisma_airs_applications_found = False
387+ try :
388+ traffic_profiles = session .config .config .traffic_profiles
389+ if not traffic_profiles :
390+ raise ValueError ("No application profiles found in the session configuration." )
391+ for application in traffic_profiles [0 ].applications :
392+ if "Prisma AIRS" not in application .name :
393+ continue
394+ for track in application .tracks :
395+ for action in track .actions :
396+ for param in action .params :
397+ if param .name == "PAN Auth Token" :
398+ prisma_airs_applications_found = True
399+ param .value = pan_auth_token
400+ print (f"Updated PAN auth token for Application: { application .name } " )
401+ elif param .name == "AIRS Profile Name" and airs_profile_name :
402+ param .value = airs_profile_name
403+ print (f"Updated AIRS Profile Name for Application: { application .name } " )
404+ elif param .name == "AIRS Profile ID" and airs_profile_id :
405+ param .value = airs_profile_id
406+ print (f"Updated AIRS Profile ID for Application: { application .name } " )
407+ param .update ()
408+ except AttributeError as e :
409+ print (f"Error while setting Prisma AIRS params: { e } " )
410+ except Exception as e :
411+ print (f"Unexpected error while setting Prisma AIRS params: { e } " )
412+ if not prisma_airs_applications_found :
413+ print ("No Prisma AIRS Applications found in the provided session." )
414+
415+ def set_model_armor_params (self , session , template_id , location , project_id , access_token ):
416+ # Update Attacks
417+ model_armor_attacks_found = False
418+ try :
419+ attack_profiles = session .config .config .attack_profiles
420+ if not attack_profiles :
421+ raise ValueError ("No attack profiles found in the session configuration." )
422+ for attack in attack_profiles [0 ].attacks :
423+ if "Model Armor" not in attack .name :
424+ continue
425+ for track in attack .tracks :
426+ for action in track .actions :
427+ params = action .params
428+ for param in params :
429+ if param .name == "Template ID" :
430+ model_armor_attacks_found = True
431+ param .value = template_id
432+ print (f"Updated Template ID for attack: { attack .name } " )
433+ elif param .name == "Project ID" :
434+ param .value = project_id
435+ print (f"Updated Project ID for attack: { attack .name } " )
436+ elif param .name == "Location" :
437+ param .value = location
438+ print (f"Updated Location for attack: { attack .name } " )
439+ elif param .name == "Access Token" :
440+ param .value = access_token
441+ print (f"Updated Access Token for attack: { attack .name } " )
442+ param .update ()
443+ except AttributeError as e :
444+ print (f"Error while setting Model Armor params: { e } " )
445+ except Exception as e :
446+ print (f"Unexpected error while setting Model Armor params: { e } " )
447+ if not model_armor_attacks_found :
448+ print ("No Model Armor Attacks found in the provided session." )
449+
450+ # Update Applications
451+ model_armor_applications_found = False
452+ try :
453+ traffic_profiles = session .config .config .traffic_profiles
454+ if not traffic_profiles :
455+ raise ValueError ("No application profiles found in the session configuration." )
456+ for application in traffic_profiles [0 ].applications :
457+ if "Model Armor" not in application .name :
458+ continue
459+ for track in application .tracks :
460+ for action in track .actions :
461+ for param in action .params :
462+ if param .name == "Template ID" :
463+ model_armor_applications_found = True
464+ param .value = template_id
465+ print (f"Updated Template ID for Application: { application .name } " )
466+ elif param .name == "Project ID" :
467+ param .value = project_id
468+ print (f"Updated Project ID for Application: { application .name } " )
469+ elif param .name == "Location" :
470+ param .value = location
471+ print (f"Updated Location for Application: { application .name } " )
472+ elif param .name == "Access Token" :
473+ param .value = access_token
474+ print (f"Updated Access Token for Application: { application .name } " )
475+ param .update ()
476+ except AttributeError as e :
477+ print (f"Error while setting Model Armor params: { e } " )
478+ except Exception as e :
479+ print (f"Unexpected error while setting Model Armor params: { e } " )
480+ if not model_armor_applications_found :
481+ print ("No Model Armor Applications found in the provided session." )
354482
355483def parse_cli_options (extra_options = []):
356484 """Can be used to get parameters from the CLI or env vars that are broadly useful for CLI tests"""
0 commit comments