def createGenericreportobject(self): #ReportModule=CustomObject() with open(self.filename, "rb") as binary_file: self.file_ref = bytearray(binary_file.read()) index = self.filename.rfind('\\') self.name = self.filename[index + 1:] if self.filename.endswith(".csv"): with open(self.filename) as csvfile: readCSV = csv.reader(csvfile) for row in readCSV: ReportModule = CustomObject() self.saveObject(ReportModule, row[0] + "." + row[1], "GenericReport", self.file, self.filename, "GenericReport_" + row[0] + row[1]) ReportModule.save() #self.saveObject(ReportModule,self.name,"GenericReport",self.file,self.filename,"GenericReport_"+self.filename) #ReportModule.save() else: ReportModule = CustomObject() #Print.debug("Other than CSV file-----------") self.saveObject(ReportModule, self.name, "GenericReport", self.file, self.filename, "GenericReport_" + self.filename) ReportModule.save() checksum = self.getcrc(self.file_ref) Print.debug("checksum == " + str(checksum)) ReportModule.save_property('checksum.CodeOnlyChecksum', checksum) Print.debug("End of Analysis!!!")
def start_file(self, file): # we create one object under each file... o = CustomObject() o.set_type('MyLanguage_Object1') o.set_name('name1') o.set_parent(file) o.save()
def start_file(self, file): # we create one object under each file... o = CustomObject() o.set_type('MyLanguage_Object1') o.set_name('name1') o.set_parent(file) o.save()
def save(self, file): """ Save the symbol """ self.kb_symbol = CustomObject() self.kb_symbol.set_name(self.name) self.kb_symbol.set_type(self.type) self.kb_symbol.set_parent(self.parent.kb_symbol if self.parent else file) self.kb_symbol.save() self.kb_symbol.save_position(Bookmark(file, *self.position))
class Symbol: def __init__(self, name, parent=None): self.name = name self.parent = parent self.position = None self.kb_symbol= None def save(self, file): """ Save the symbol """ self.kb_symbol = CustomObject() self.kb_symbol.set_name(self.name) self.kb_symbol.set_type(self.type) self.kb_symbol.set_parent(self.parent.kb_symbol if self.parent else file) self.kb_symbol.save() self.kb_symbol.save_position(Bookmark(file, *self.position))
def start_file(self, file): filename = file.get_path() #X.debug(filename) if filename.endswith('.xml'): tree = ET.parse(filename) root = tree.getroot() count = 0 for k in list(root.iter()): data1 = re.sub('{.*?}', '', str(k.tag)) if data1 == "from": try: X.debug(k.attrib['uri']) fromObj = CustomObject() self.saveObject( fromObj, data1 + "." + k.attrib['uri'], filename + '.' + data1, "Sender", file, filename + "." + data1 + '.' + str(count)) count = count + 1 fromObj.save_position(Bookmark(file, 1, 1, -1, -1)) fromRef[fromObj] = [fromObj, k.attrib['uri']] except (RuntimeError, TypeError, NameError): pass elif data1 == "to": try: X.debug(k.attrib['uri']) toObj = CustomObject() self.saveObject( toObj, data1 + "." + k.attrib['uri'], filename + '.' + data1, "Receiver", file, filename + "." + data1 + '.' + str(count)) count = count + 1 toObj.save_position(Bookmark(file, 1, 1, -1, -1)) toRef[toObj] = [toObj, k.attrib['uri']] except (RuntimeError, TypeError, NameError): pass elif filename.endswith('.java'): X.debug("")
def checkOnmessage(self, bpel_invoke, operation_type, namespace_port, onmessage_count): flag_link = 0 for reference in bpel_onmessage_data: for data in bpel_onmessage_data[reference]: onmessage_data = str(data) onmessage_data = re.sub('(\[)|(\])|(\')|(\s+)', '', onmessage_data) onmessage_port_type = "" onmessage_operation_type = "" onmessage_namespace_port = "" process_data = "" for ele in list(onmessage_data.split(',')): if "portType:" in ele: onmessage_port_type = ele[ele.find(':') + 1:] elif "operation:" in ele: onmessage_operation_type = ele[ele.find(':') + 1:] if ':' in onmessage_port_type: onmessage_namespace_port = onmessage_port_type[: onmessage_port_type .find(':') + 1] process_data = str(bpel_process_data[reference]) process_data = re.sub('(\[)|(\])|(\')|(\s+)', '', process_data) process_data = process_data.replace('xmlns:map:', '') for ele in list(process_data.split(',')): if onmessage_namespace_port in ele: onmessage_namespace_port = ele[ele.find(':') + 1:] onmessage_namespace_port = onmessage_namespace_port + onmessage_port_type[ onmessage_port_type.find(':') + 1:] break if operation_type == onmessage_operation_type and namespace_port == onmessage_namespace_port: if reference in wsdl_obj_reference: #CAST.debug(onmessage_operation_type) file_name = wsdl_obj_reference[ reference].parent.get_path() wsdl_operation = CustomObject() onmessage_count = onmessage_count + 1 self.saveObject( wsdl_operation, onmessage_operation_type, file_name + onmessage_operation_type, "WSDL_Operation", wsdl_obj_reference[reference].parent, file_name + "WSDL_Operation" + str(onmessage_count)) wsdl_operation.save() wsdl_operation.save_position( Bookmark(reference.parent, 1, 1, -1, -1)) create_link('callLink', bpel_invoke, wsdl_operation, Bookmark(reference.parent, 1, 1, -1, -1)) create_link('callLink', wsdl_operation, wsdl_obj_reference[reference], Bookmark(reference.parent, 1, 1, -1, -1)) flag_link = 1 break else: pass else: pass if flag_link == 1: break return onmessage_count pass
def start_file(self, file): self.filename = file.get_path() CAST.debug(self.filename) file_ref = open(self.filename, 'r') file_data = [] for child in file_ref: child = child.replace("\n", "") file_data.append(child) parser = CastOperation() if self.filename.endswith(".wsdl"): try: index = self.filename.rfind('\\') self.name = self.filename[index + 1:] except: index = -1 wsdl_process = CustomObject() self.saveObject(wsdl_process, self.name, self.filename, "WSDL_Process", file, self.filename + "WSDL_Process") wsdl_process.save() wsdl_process.save_position(Bookmark(file, 1, 1, -1, -1)) wsdl_file_data[wsdl_process] = parser.castParserWsdl(self.filename) #CAST.debug(self.name) else: self.invokeList = parser.getInvokeJavaCode(self.filename) for child in self.invokeList: self.intermediate_file.write(str(child) + '\n') bpel_data = parser.castParserBpel(file, self.filename) #CAST.debug(str(bpel_data["link"])) for child in bpel_data: #attrib_data = re.sub('(\[)|(\])|(\')','',str(bpel_file_data[child])) if "process" in child and not "bookmark" in child: for subchild in bpel_data[child]: if "name" in subchild: self.name = subchild[subchild.find(':') + 1:] break bpel_process = CustomObject() self.saveObject(bpel_process, self.name, self.filename, "BPEL_Process", file, self.filename + "BPEL_Process") bpel_process.save() if bpel_data["process.bookmark"]: bpel_process.save_position(bpel_data["process.bookmark"][0]) else: bpel_process.save_position(Bookmark(file, 1, 1, -1, -1)) bpel_process_data[bpel_process] = bpel_data["process"] bpel_bookmark_data[ str(bpel_process) + "invoke.bookmark"] = bpel_data["invoke.bookmark"] bpel_invoke_data[bpel_process] = bpel_data["invoke"] bpel_bookmark_data[ str(bpel_process) + "receive.bookmark"] = bpel_data["receive.bookmark"] bpel_receive_data[bpel_process] = bpel_data["receive"] bpel_bookmark_data[ str(bpel_process) + "onMessage.bookmark"] = bpel_data["onMessage.bookmark"] bpel_onmessage_data[bpel_process] = bpel_data["onMessage"] self.file_loc_data = parser.fileLoc(self.filename) self.file_checksum_data = parser.fileChecksum(self.filename) qr_reference = QualityRule() qr_reference.BpelQrImplementation(file, bpel_process, bpel_data, file_data) pass
def end_analysis(self): for child in bpel_process_data: bpel_target_name = "" bpel_name = "" for ele in bpel_process_data[child]: if "targetNamespace:" in ele: bpel_target_name = ele[ele.find(':') + 1:] elif "name:" in ele: bpel_name = ele[ele.find(':') + 1:] for ele in wsdl_file_data: wsdl_target_name = "" wsdl_name = "" for subele in wsdl_file_data[ele]["definitions"]: if "targetNamespace:" in subele: wsdl_target_name = subele[subele.find(':') + 1:] elif "name:" in subele: wsdl_name = subele[subele.find(':') + 1:] #CAST.debug(wsdl_name) if wsdl_target_name == bpel_target_name: create_link('callLink', ele, child, Bookmark(child.parent, 1, 1, -1, -1)) wsdl_obj_reference[child] = ele elif wsdl_name == bpel_name and len(wsdl_name) != 0 and len( bpel_name) != 0: #CAST.debug(bpel_name+wsdl_name) create_link('callLink', ele, child, Bookmark(child.parent, 1, 1, -1, -1)) wsdl_obj_reference[child] = ele invoke_count = 0 operation_count = 0 onmessage_count = 0 for child in bpel_invoke_data: invoke_index = 0 for ele in bpel_invoke_data[child]: port_type = "" operation_type = "" namespace_port = "" invoke_name = "null" patnerlink_name = "" ele_data = str(ele) ele_data = re.sub('(\[)|(\])|(\')|(\s+)', '', ele_data) bpel_invoke_list = [] bpel_invoke_list = ele_data.split(',') for subele in bpel_invoke_list: if 'portType:' in subele: port_type = subele[subele.find(':') + 1:] elif 'operation:' in subele: operation_type = subele[subele.find(':') + 1:] elif 'name:' in subele: invoke_name = subele[subele.find(':') + 1:] elif 'partnerLink:' in subele: patnerlink_name = subele[subele.find(':') + 1:] filename = child.parent.get_path() invoke_fullname = '' if invoke_name == "null": invoke_name = patnerlink_name invoke_fullname = filename + '--null' else: invoke_fullname = filename + '--' + invoke_name bpel_invoke = CustomObject() invoke_count = invoke_count + 1 self.saveObject(bpel_invoke, invoke_name, invoke_fullname, "BPEL_Invoke", child.parent, filename + "BPEL_Invoke" + str(invoke_count)) bpel_invoke.save() try: bpel_invoke.save_position( bpel_bookmark_data[str(child) + "invoke.bookmark"][invoke_index]) except: bpel_invoke.save_position( Bookmark(child.parent, 1, 1, -1, -1)) invoke_index = invoke_index + 1 create_link('callLink', child, bpel_invoke, Bookmark(child.parent, 1, 1, -1, -1)) if not ("null" in port_type and "null" in operation_type): if ':' in port_type: namespace_port = port_type[:port_type.find(':') + 1] ele_data = str(bpel_process_data[child]) ele_data = re.sub('(\[)|(\])|(\')|(\s+)', '', ele_data) ele_data = ele_data.replace('xmlns:map:', '') #CAST.debug(ele_data) for invoke_data in list(ele_data.split(',')): if namespace_port in invoke_data: namespace_port = invoke_data[invoke_data. find(':') + 1:] namespace_port = namespace_port + port_type[ port_type.find(':') + 1:] break flag_link = 0 ''' CAST.debug(ele_data) CAST.debug(operation_type+"--"+namespace_port) CAST.debug('--XD') ''' for subele in bpel_receive_data: for bpel_ele in bpel_receive_data[subele]: ele_data = str(bpel_ele) ele_data = re.sub('(\[)|(\])|(\')|(\s+)', '', ele_data) bpel_receive_list = [] bpel_receive_list = ele_data.split(',') receive_port_type = "" receive_operation_type = "" receive_namespace_port = "" for receive_data in bpel_receive_list: if 'portType:' in receive_data: receive_port_type = receive_data[ receive_data.find(':') + 1:] elif 'operation:' in receive_data: receive_operation_type = receive_data[ receive_data.find(':') + 1:] if ':' in receive_port_type: receive_namespace_port = receive_port_type[: receive_port_type . find( ':' ) + 1] ele_data = str(bpel_process_data[subele]) ele_data = re.sub('(\[)|(\])|(\')|(\s+)', '', ele_data) ele_data = ele_data.replace('xmlns:map:', '') for receive_data in list(ele_data.split(',')): if receive_namespace_port in receive_data: receive_namespace_port = receive_data[ receive_data.find(':') + 1:] receive_namespace_port = receive_namespace_port + receive_port_type[ receive_port_type.find(':') + 1:] break ''' for process_data in bpel_process_data[subele].split(','): CAST.debug(str(process_data)) ''' if namespace_port == receive_namespace_port and operation_type == receive_operation_type: if subele in wsdl_obj_reference: CAST.debug('Object linking.....') ''' CAST.debug('XC') CAST.debug(filename) CAST.debug(invoke_name) CAST.debug(receive_namespace_operation+"--"+receive_namespace_port) ''' file_name = wsdl_obj_reference[ subele].parent.get_path() wsdl_operation = CustomObject() operation_count = operation_count + 1 self.saveObject( wsdl_operation, receive_operation_type, file_name + receive_operation_type, "WSDL_Operation", wsdl_obj_reference[subele].parent, file_name + "WSDL_Operation" + str(operation_count)) wsdl_operation.save() wsdl_operation.save_position( Bookmark(subele.parent, 1, 1, -1, -1)) create_link( 'callLink', bpel_invoke, wsdl_operation, Bookmark(subele.parent, 1, 1, -1, -1)) create_link( 'callLink', wsdl_operation, wsdl_obj_reference[subele], Bookmark(subele.parent, 1, 1, -1, -1)) flag_link = 1 break else: pass else: pass if flag_link == 1: break if flag_link != 1: onmessage_count = self.checkOnmessage( bpel_invoke, operation_type, namespace_port, onmessage_count) else: pass CAST.debug('End!!') ''' for child in bpel_file_data: for subchild in bpel_file_data[child]: CAST.debug(subchild+"->") for j in bpel_file_data[child][subchild]: CAST.debug(str(j)) #for child in wsdl_file_data: #for subchild in wsdl_file_data[child]: # CAST.debug(str(wsdl_file_data[child])) ''' pass
def add_sqlnamedquery(sqltable, sql_queries, resultMaps, typeAliases, file, namespace): for sqlid, node in sqltable.items(): log.info('NEW Named Query - %s' % sqlid) sqlquery = CustomObject() sqlquery.set_name(sqlid) sqlquery.set_type('CAST_SQL_NamedQuery') sqlquery.set_parent(file) sqlquery.save() #Get SQL from node sql = node.text for sub_node in node: if 'refid' in sub_node.attrib and sub_node.attrib[ 'refid'] in sql_queries: sql += sql_queries[sub_node.attrib['refid']].text.strip() if sub_node.tail: sql += sub_node.tail #log.info('SQL: %s' % sql) sqlquery.save_property('CAST_SQL_MetricableQuery.sqlQuery', sql) log.info(' - creating links...') for embedded in external_link.analyse_embedded(sql): for t in embedded.types: #log.info(' - link to : %s' % embedded.callee.get_name()) link = create_link(t, sqlquery, embedded.callee) link.mark_as_not_sure() #Save all potential properties for later use CommonParsing.add_property(sqlquery, node, 'parameterClass', typeAliases) CommonParsing.add_property(sqlquery, node, 'parameterType', typeAliases) CommonParsing.add_property(sqlquery, node, 'resultClass', typeAliases) CommonParsing.add_property(sqlquery, node, 'listClass', typeAliases) CommonParsing.add_property(sqlquery, node, 'resultMap', typeAliases) CommonParsing.add_property(sqlquery, node, 'resultType', typeAliases) CommonParsing.add_property(sqlquery, node, 'parameterMap', typeAliases) if (namespace != ''): log.debug('Habemus namespacus!') sqlquery.save_property('iBatisProperties.namespace', namespace) for mapId, mapClass in resultMaps.items(): if 'resultMap' in node.attrib and node.attrib[ 'resultMap'] == mapId: log.debug(' - class: %s' % mapClass) sqlquery.save_property('iBatisProperties.class', mapClass)
def end_type(self, _type): class_bookmark = _type.get_positions() name=str(_type.get_name()) # fetching name of class or interface path = _type. get_position().get_file().get_path() # fetching path of required file CAST.debug("-----"+str(path)+"-----") self.object_names=[] self.objects = [] method_range = [[x,y[0].get_begin_line(),y[0].get_end_line()] for x,y in self.bookmarks.items()] CAST.debug("Method_range: "+str(method_range)+" Class Bookmark: "+str(class_bookmark[0])) Result= parser(path,method_range,class_bookmark[0]) if Result: CAST.debug(" Creating Objects: ") # Creating objects for producer, consumer variables and queue name for key in Result.keys(): if "MessageProducer" in Result[key][0] or "JMSProducer" in Result[key][0] or "QueueSender" in Result[key][0] or "TopicPublisher" in Result[key][0]: o = CustomObject() Object_created = True parent_link = list(filter(lambda x: Result[key][1] in range(x[1],x[2]),method_range)) if parent_link: self.createObj(o,name+"_"+str(key),parent_link[0][0],"obj"+str(key),"MOM_Producer") elif Result[key][1] in range(class_bookmark[0].get_begin_line(),class_bookmark[0].get_end_line()): self.createObj(o,name+"_"+str(key),_type,"obj"+str(key),"MOM_Producer") else: Object_created = False if Object_created: self.object_names.append(key) self.objects.append(o) elif "TopicSubscriber" in Result[key][0] or "JMSConsumer" in Result[key][0] or "MessageConsumer" in Result[key][0] or "QueueReceiver" in Result[key][0]: o = CustomObject() Object_created = True parent_link = list(filter(lambda x: Result[key][1] in range(x[1],x[2]),method_range)) if parent_link: self.createObj(o,name+"_"+str(key),parent_link[0][0],"obj"+str(key),"MOM_Consumer") elif Result[key][1] in range(class_bookmark[0].get_begin_line(),class_bookmark[0].get_end_line()): self.createObj(o,name+"_"+str(key),_type,"obj"+str(key),"MOM_Consumer") else: Object_created = False if Object_created: self.object_names.append(key) self.objects.append(o) if Result[key][-1] not in self.object_names: p = CustomObject() Object_created = True parent_link = list(filter(lambda x: Result[key][1] in range(x[1],x[2]),method_range)) if parent_link: self.createObj(p,name+"_"+str(Result[key][-1]),parent_link[0][0],"obj"+str(key),"MOM_Queue") elif Result[key][1] in range(class_bookmark[0].get_begin_line(),class_bookmark[0].get_end_line()): self.createObj(p,name+"_"+str(Result[key][-1]),_type,"obj"+str(key),"MOM_Queue") else: Object_created = False if Object_created: self.object_names.append(str(Result[key][-1])) self.objects.append(p) CAST.debug(" Creating Links: ") if self.objects: for key in Result.keys(): class_variable = True for bk in self.bookmarks.keys(): # for linking Method objects with producer and consumer objects x,y = self.bookmarks[bk][0].get_begin_line() , self.bookmarks[bk][0].get_end_line() if Result[key][1] in range(x,y+1): obj1 = bk obj2 = self.objects[self.object_names.index(key)] create_link('useLink',obj1,obj2) class_variable = False CAST.debug(str(obj1)+" --links with-- "+obj2.name) if class_variable == True: obj1 = _type obj2 = self.objects[self.object_names.index(key)] create_link('useLink',obj1,obj2) CAST.debug(str(obj1)+" --links with-- "+obj2.name) for key in Result.keys(): # for linking producer or consumer objects with queue object obj1 = self.objects[self.object_names.index(key)] obj2 = self.objects[self.object_names.index(Result[key][-1])] if "MessageProducer" in Result[key][0] or "QueueSender" in Result[key][0] or "JMSProducer" in Result[key][0] or "TopicPublisher" in Result[key][0]: create_link('useLink', obj1, obj2) CAST.debug(obj1.name+" --linked with-- "+obj2.name) else: create_link('useLink', obj2, obj1) CAST.debug(obj2.name+" --linked with-- "+obj1.name) self.bookmarks={}
def start_file(self, file): self.filename = file.get_path() #CAST.debug("File Name:---- %s" %self.filename) file_ref = open(self.filename, encoding='ISO_8859_1') #file_ref = open(self.filename,'r') file_data = [] for child in file_ref: try: child = child.replace("\n", "") file_data.append(child) except Exception as e: import traceback e = traceback.format_exc(e) parser = CastOperation() if self.filename.endswith(".wsdl"): try: index = self.filename.rfind('\\') self.name = self.filename[index + 1:] except: index = -1 wsdl_process = CustomObject() #CAST.debug("Checking file extension---"+self.name) self.saveObject(wsdl_process, self.name, self.filename, "WSDL_Process", file, self.filename + "WSDL_Process") wsdl_process.save() wsdl_process.save_position(Bookmark(file, 1, 1, -1, -1)) wsdl_file_data[wsdl_process] = parser.castParserWsdl(self.filename) #CAST.debug(str(wsdl_file_data[wsdl_process])) #CAST.debug("Check Name-----"+self.filename) else: #CAST.debug("************************** else") #CAST.debug (self.filename) self.invokeList = parser.getInvokeJavaCode(self.filename) for child in self.invokeList: #CAST.debug("Check Java object-------"+str(child)) self.intermediate_file.write(str(child) + '\n') bpel_data = parser.castParserBpel(file, self.filename) #CAST.debug(str(bpel_data["link"])) for child in bpel_data: #CAST.debug("Check BPEL object-------"+str(child)) #break #attrib_data = re.sub('(\[)|(\])|(\')','',str(bpel_file_data[child])) #CAST.debug("Atrribute is true-----"+str(attrib_data)) if "process" in child and not "bookmark" in child: #CAST.debug("Condition is true-----") #CAST.debug(str(bpel_data)) #CAST.debug(str(child)) #CAST.debug("Condition is true-----"+str(bpel_data)) for subchild in bpel_data[child]: #CAST.debug("Condition is true-----"+subchild) if "name" in subchild: self.name = subchild[subchild.find(':') + 1:] #CAST.debug("Checking Name-----"+self.name) break bpel_process = CustomObject() self.saveObject(bpel_process, self.name, self.filename, "BPEL_Process", file, self.filename + "BPEL_Process") bpel_process.save() if bpel_data["process.bookmark"]: bpel_process.save_position(bpel_data["process.bookmark"][0]) else: bpel_process.save_position(Bookmark(file, 1, 1, -1, -1)) bpel_process_data[bpel_process] = bpel_data["process"] bpel_bookmark_data[ str(bpel_process) + "invoke.bookmark"] = bpel_data["invoke.bookmark"] bpel_invoke_data[bpel_process] = bpel_data["invoke"] bpel_bookmark_data[ str(bpel_process) + "receive.bookmark"] = bpel_data["receive.bookmark"] bpel_receive_data[bpel_process] = bpel_data["receive"] bpel_bookmark_data[ str(bpel_process) + "onMessage.bookmark"] = bpel_data["onMessage.bookmark"] bpel_onmessage_data[bpel_process] = bpel_data["onMessage"] #//Creating new object #bpel_bookmark_data[str(bpel_process)+"partnerLink.bookmark"] = bpel_data["partnerLink.bookmark"] #bpel_PartnerLink_data[bpel_process] = bpel_data["partnerLink"] ''' bpel_bookmark_data[str(bpel_process)+"assign.bookmark"] = bpel_data["assign.bookmark"] bpel_assign_data[bpel_process] = bpel_data["assign"] bpel_bookmark_data[str(bpel_process)+"catch.bookmark"] = bpel_data["catch.bookmark"] bpel_catch_data[bpel_process] = bpel_data["catch"] bpel_bookmark_data[str(bpel_process)+"catchAll.bookmark"] = bpel_data["catchAll.bookmark"] bpel_catchAll_data[bpel_process] = bpel_data["catchAll"] bpel_bookmark_data[str(bpel_process)+"sequence.bookmark"] = bpel_data["sequence.bookmark"] bpel_sequence_data[bpel_process] = bpel_data["sequence"] bpel_bookmark_data[str(bpel_process)+"switch.bookmark"] = bpel_data["switch.bookmark"] bpel_switch_data[bpel_process] = bpel_data["switch"] bpel_bookmark_data[str(bpel_process)+"case.bookmark"] = bpel_data["case.bookmark"] bpel_case_data[bpel_process] = bpel_data["case"] bpel_bookmark_data[str(bpel_process)+"extension.bookmark"] = bpel_data["extension.bookmark"] bpel_extension_data[bpel_process] = bpel_data["extension"] bpel_bookmark_data[str(bpel_process)+"copy.bookmark"] = bpel_data["copy.bookmark"] bpel_copy_data[bpel_process] = bpel_data["copy"] ''' self.file_loc_data = parser.fileLoc(self.filename) self.file_checksum_data = parser.fileChecksum(self.filename) qr_reference = QualityRule() qr_reference.BpelQrImplementation(file, bpel_process, bpel_data, file_data) pass
def start_file(self, file): log.debug ('In start_file ... ' + str(file)) log.info ('In start_file ... ' + str(file)) self.file_obj = file self.file_path = self.file_obj.get_path() log.debug("File lists.." + self.file_path) omnxtObj = CustomObject() omnxtObj.set_name("module") omnxtObj.set_fullname("C:\\Users\\MKU\\Desktop\\kamal") omnxtObj.set_type("OMNEXT_module") omnxtObj.set_parent(file) omnxtObj.set_guid(str(uuid.uuid4())) omnxtObj.save() log.debug ('Object created ... ' + str(omnxtObj)) log.info ('Object created ... ' + str(omnxtObj))
def start_file(self, file): Print.info("Start f!"+str(file)) contentList = [] fList=[] # self.file = file # self.filename = "D:/CASTTOOL/RuleDevelopment/Tibco/com.castsoftware.uc.tibco/com.castsoftware.uc.tibco/TibcoTest/TibcoSample/AdapterQueueStarter.process"; self.filename = file.get_path(); self.file = file; Print.info("###############printing file name############") Print.info("FileName--" + str(self.filename)) file_ref = open(self.filename, encoding='UTF_8') # contentList=[]; for i in file_ref: contentList.append(str(i)); Print.info("contentList >> "+ str(contentList)) fList=contentList ''' for i in file_ref: fList.append(str(i).strip().lower()) ''' Print.info("Flist >> " + str(fList)) Tibco_Process = CustomObject(); self.saveObject(Tibco_Process, str(self.filename), self.filename + str(self.filename), "Tibco_Process", self.file, self.filename + "Tibco_Process") Tibco_Process.save(); # Tibco_Process.save_position(Bookmark(self.file, indexOfClass + 1, 1, indexOfClass + 1, -1)); Print.info("object saved" + self.filename) Print.info(str(fList)) for line in range(0, len(fList)): if ("<pd:conditiontype" in fList[line]): # print(fList[line]) if any(s in fList[line] for s in CondType_Rule): Print.info("valid condition type>>" + fList[line] + " Line #" + str(line + 1)) else: Print.info("invalid condition type>>" + fList[line] + " Line #" + str(line + 1)) if ("<pd:transition" in fList[line]): Print.info(fList[line]) Act_invalid=self.masterdata() Print.info("Act_invalid >> "+str(Act_invalid)) if any(s in fList[line + 1] for s in Act_invalid): Print.info("activity type cannot be migrated>>" + fList[line + 1] + " Line #"+ str(line + 1)) Tibco_Process.save_position(Bookmark(self.file, line + 1, 1, line + 1, -1)); Tibco_Process.save_violation("Tibco_CustomMetrics.Activitycannotbemigrated", Bookmark(file, 1, 1, -1, -1), additional_bookmarks=None) Print.info('Tibco Violation Saved for demo') else: Print.info("activity type can be migrated>>"+ fList[line + 1] + " Line #" + str(line + 1)) Tibco_Process.save_position(Bookmark(self.file, line + 1, 1, line + 1, -1)); Tibco_Process.save_violation("Tibco_CustomMetrics.Activitycannotbemigrated", Bookmark(file, 1, 1, -1, -1), additional_bookmarks=None) Print.info('Tibco Violation Saved for demo') pass
def start_file(self, file): Print.info("Start f!") contentList = [] #self.file = file #self.filename = "C:/Users/Angelin.mariya/Desktop/app.module.ts"; self.filename = file.get_path() self.file = file #Print.info("###############printing file name############") #Print.info("FileName--" + str(self.filename)) file_ref = open(self.filename, encoding='UTF_8') #contentList=[]; for i in file_ref: contentList.append(str(i)) indexOfClass = self.findIndex(contentList, "[c][l][a][s][s][\s]*.*[{]", 0) indexOfFunction = self.findIndex( contentList, "([v][o][i][d][\s]*|[s][t][r][i][n][g][\s]*|[i][n][t][\s]*).*[(].*[)][\s]+[{]", 0) Print.info(str(indexOfFunction)) classNameLine = contentList[indexOfClass] #className=classNameLine.replace('{',' '); className = classNameLine.split("{") className = className[0].split(" ") classObject = "NA" abstractClassObject = "NA" functionConnections = [] if className[0].strip() == "class": classObject = className[1] finalData["classObject"].append([classObject, indexOfClass]) Groovy_class = CustomObject() self.saveObject(Groovy_class, str(classObject), self.filename + str(classObject), "Groovy_class", self.file, self.filename + "Groovy_class") Groovy_class.save() Groovy_class.save_position( Bookmark(self.file, indexOfClass + 1, 1, indexOfClass + 1, -1)) functionList, functionConnections = self.getFunctionList( contentList, "([v][o][i][d][\s]*|[s][t][r][i][n][g][\s]*|[i][n][t][\s]*).*[(].*[)][\s]+[{]" ) for i in functionConnections: finalData["functionLink"].append(i) for i in functionList: Groovy_Function = CustomObject() self.saveObject(Groovy_Function, str(i[0]), self.filename + str(i[0]), "Groovy_Function", self.file, self.filename + str(i[0])) Groovy_Function.save() Groovy_Function.save_position( Bookmark(self.file, i[1], 1, i[1], -1)) create_link('containLink', Groovy_class, Groovy_Function) elif className[0].strip() == "abstract": abstractClassObject = className[2] finalData["abstractObject"].append( [abstractClassObject, indexOfClass]) Groovy_AbstractClass = CustomObject() self.saveObject(Groovy_AbstractClass, str(abstractClassObject), self.filename + str(abstractClassObject), "Groovy_AbstractClass", self.file, self.filename + "Groovy_AbstractClass") Groovy_AbstractClass.save() Groovy_AbstractClass.save_position( Bookmark(self.file, indexOfClass + 1, 1, indexOfClass + 1, -1)) functionList, functionConnections = self.getFunctionList( contentList, "([v][o][i][d][\s]*|[s][t][r][i][n][g][\s]*|[i][n][t][\s]*).*[(].*[)][\s]+[{]" ) for i in functionConnections: finalData["functionLink"].append(i) for i in functionList: Groovy_Function = CustomObject() self.saveObject(Groovy_Function, str(i[0]), self.filename + str(i[0]), "Groovy_Function", self.file, self.filename + str(i[0])) print("groovy object saved") Groovy_Function.save() Groovy_Function.save_position( Bookmark(self.file, i[1], 1, i[1], -1)) create_link('containLink', Groovy_AbstractClass, Groovy_Function) in1 = self.findIndex( contentList, "([v][o][i][d][\s]*|[s][t][r][i][n][g][\s]*|[i][n][t][\s]*).*[(].*[)][\s]+[{]", 0) print("sad", in1) #print("to",functionList); # save violation rule Groovy_Function.save_violation( "Groovy_CustomMetrics.AssertWithinFinallyBlock", Bookmark(file, 1, 1, -1, -1), additional_bookmarks=None) Print.info('Groovy Violation Saved for demo') self.validate(file) Print.info(str(functionList)) return contentList