Untitled
unknown
plain_text
6 days ago
1.3 kB
5
Indexable
def get_rules(using): command_response = demisto.executeCommand(f"pan-os-list-rules", {'pre_post': 'pre-rulebase', 'using': using}) return itertools.chain(command_response[0]['EntryContext'].values()) if command_response[0][ 'EntryContext'] else [] if __name__ in ('__main__', '__builtin__', 'builtins'): command_response = demisto.executeCommand(f"getList", {"listName": "PanoramaMapping"}) panorama_mapping = json.loads(command_response[0]['Contents']) existing_rules = [] existing_device_groups = set("Shared", "AZUSE-PA-EDGE-01", "AZUSE-PA-EDGE-01") for device_group, panorama_mapping_item in panorama_mapping.items(): # if device_group not in existing_device_groups: # continue _rules = get_rules(panorama_mapping_item) if _rules: existing_rules.extend(*_rules) existing_rules_mapping = list({(r['Name'], r['DeviceGroup']) for r in existing_rules}) entry = { 'Type': EntryType.NOTE, 'Contents': existing_rules_mapping, 'ContentsFormat': EntryFormat.JSON, 'ReadableContentsFormat': EntryFormat.MARKDOWN, 'HumanReadable': f"Completed", 'EntryContext': { "Results": existing_rules_mapping, }, 'IgnoreAutoExtract': True } return_results(entry)
Editor is loading...
Leave a Comment