@@ -1845,7 +1845,6 @@ def check_cache_contains(self, key, value, append):
18451845 ## subkey = "hi", value = "test3", overwrite=False
18461846 ## {"subkey": "hi", "value": ["test2", "test3"]}
18471847
1848- #def set_cache_value(self, key, value):
18491848 def change_cache_subkey (self , key , subkey , value , overwrite ):
18501849 org_id = self .full_execution ["workflow" ]["execution_org" ]["id" ]
18511850 url = "%s/api/v1/orgs/%s/set_cache" % (self .url , org_id )
@@ -1925,7 +1924,6 @@ def get_cache_value(self, key):
19251924 self .logger .info ("Value couldn't be parsed, or json dump of value failed" )
19261925 return value .text
19271926
1928- # FIXME: Add option for org only & sensitive data (not to be listed)
19291927 def set_cache_value (self , key , value ):
19301928 org_id = self .full_execution ["workflow" ]["execution_org" ]["id" ]
19311929 url = "%s/api/v1/orgs/%s/set_cache" % (self .url , org_id )
@@ -2020,7 +2018,7 @@ def cidr_ip_match(self, ip, networks):
20202018
20212019 try :
20222020 ip_networks = list (map (ipaddress .ip_network , networks ))
2023- ip_address = ipaddress .ip_address (ip )
2021+ ip_address = ipaddress .ip_address (ip , False )
20242022 except ValueError as e :
20252023 return "IP or some networks are not in valid format.\n Error: {}" .format (e )
20262024
@@ -2577,6 +2575,69 @@ def parse_ioc_new(self, input_string, input_type="all"):
25772575
25782576 return newarray
25792577
2578+ def merge_incoming_branches (self , input_type = "list" ):
2579+ wf = self .full_execution ["workflow" ]
2580+ if "branches" not in wf or not wf ["branches" ]:
2581+ return {
2582+ "success" : False ,
2583+ "reason" : "No branches found"
2584+ }
2585+
2586+ if "results" not in self .full_execution or not self .full_execution ["results" ]:
2587+ return {
2588+ "success" : False ,
2589+ "reason" : "No results for previous actions not found"
2590+ }
2591+
2592+ if not input_type :
2593+ input_type = "list"
2594+
2595+ branches = wf ["branches" ]
2596+ cur_action = self .action
2597+ #print("Found %d branches" % len(branches))
2598+
2599+ results = []
2600+ for branch in branches :
2601+ if branch ["destination_id" ] != cur_action ["id" ]:
2602+ continue
2603+
2604+ # Find result for the source
2605+ source_id = branch ["source_id" ]
2606+
2607+ for res in self .full_execution ["results" ]:
2608+ if res ["action" ]["id" ] != source_id :
2609+ continue
2610+
2611+ try :
2612+ parsed = json .loads (res ["result" ])
2613+ results .append (parsed )
2614+ except Exception as e :
2615+ results .append (res ["result" ])
2616+
2617+ break
2618+
2619+ if input_type == "list" :
2620+ newlist = []
2621+ for item in results :
2622+ if not isinstance (item , list ):
2623+ continue
2624+
2625+ for subitem in item :
2626+ if subitem in newlist :
2627+ continue
2628+
2629+ newlist .append (subitem )
2630+ #newlist.append(item)
2631+
2632+ results = newlist
2633+ else :
2634+ return {
2635+ "success" : False ,
2636+ "reason" : "No results from source branches with type %s" % input_type
2637+ }
2638+
2639+ return results
2640+
25802641 def list_cidr_ips (self , cidr ):
25812642 defaultreturn = {
25822643 "success" : False ,
0 commit comments