Esempio n. 1
0
    def CFStoredProcLinking(self, application, CFStored_Proc_List):
        for items in CFStored_Proc_List:
            parent_type = items[0]
            parent_name = items[1]
            proc_name = items[2]
            child = None
            parent = None
            #logging.info("Porc Name inside CFStoredProcLinking.." + str(proc_name))
            parentlist = list(
                application.search_objects(category=parent_type,
                                           load_properties=False))
            #logging.info("CFStoredProcLinking.. parentlist" + str(parentlist))
            for parentobject in parentlist:
                if parentobject.get_name() == parent_name:
                    parent = parentobject
                    #logging.info("Parent Found for Proc--> " + str(parent))
                    break

            procedurelist = list(
                application.search_objects(category='CAST_Oracle_Procedure',
                                           name=proc_name,
                                           load_properties=False))
            #logging.info("CFStoredProcLinking.. proclist.." + str(procedurelist))
            for procobject in procedurelist:
                if procobject.get_name() == proc_name:
                    child = procobject
                    break

            if parent and child:
                #logging.info("Parent.." + str(parent) + "Child.." + str(child))
                cast.application.create_link("callLink", parent, child)
                logging.info("Proc Link Created")
        pass
Esempio n. 2
0
    def InvokeWebMethodAndComponentLinking(self, application,
                                           invokeproperties):
        logging.info("InvokeWebMethodAndComponentLinking@@@")
        invokelist = list(
            application.search_objects(category=invokeproperties,
                                       load_properties=True))

        logging.info("invokelist.." + str(invokelist))
        if len(invokelist) > 0:
            for invokeobject in invokelist:
                webservice_name = invokeobject.get_property(
                    'CFInvokeProperties.InvokeWebserviceName')
                method_name = invokeobject.get_property(
                    'CFInvokeProperties.InvokeMethodName')
                webobj = invokeobject.get_property(
                    'CFInvokeProperties.WebService')
                #webcompList = list(application.search_objects(category='CFWebService',load_properties=True))
                parent = invokeobject
                logging.debug(
                    "Parent in InvokeWebMethodAndComponentLinking..   " +
                    str(parent))

                child = None

                if webservice_name is not None:
                    webcompList = list(
                        application.search_objects(category='CFWebService',
                                                   load_properties=True))
                    #logging.debug("CFWebservice..   " + str(webcompList))
                    #logging.info("Webservice Name found.." + str(webobj))
                    #logging.info("method_name found.." + str(method_name))
                    for childobj in webcompList:
                        logging.debug('childobj...  ' + str(childobj))
                        child = childobj
                        logging.debug("webcomponentlist.." + str(child))
                        break
                    if parent and child is not None:
                        #logging.info("Child not none")
                        #logging.info("Parent Child in CFInvoke.." + str(parent) + "----" + str(child))
                        cast.application.create_link("callLink", parent, child)
                        logging.info("CFInvoke Link Created")

                elif method_name is not None:
                    method_name = "cfcomponent." + method_name
                    #logging.info("### method_name@@@   " + str( method_name))
                    componentlist = list(
                        application.search_objects(category='CFComponent',
                                                   load_properties=True))
                    logging.debug("componentlist.." + str(componentlist))
                    for childobject in componentlist:
                        if childobject.get_name() == method_name:
                            child = childobject
                            #logging.info("Child 222 obj" + str(child))
                            break
                    if parent and child:
                        #logging.info("Child not none")
                        #logging.info("Parent Child in CFCOMPONENT.." + str(parent) + "----" + str(child))
                        cast.application.create_link("callLink", parent, child)
                        logging.info("CFCOMPONENT Link Created")
        pass
Esempio n. 3
0
    def end_application(self, application):
        logging.debug("Running code at the end of an Application")

        invokeJavaCodeList = []
        # getting data from the intermediate file and converting to the correct format before inserting in the list
        for line in self.get_intermediate_file('bpel.txt'):
            invokeJavaCodeList.append(ast.literal_eval(line))

        bpelInvokeObjectReferences = list(
            application.search_objects(category='BPEL_Invoke',
                                       load_properties=False))
        javaMethodObjectReferences = list(
            application.search_objects(category='JV_METHOD',
                                       load_properties=False))
        for javaMethodObject in javaMethodObjectReferences:
            for invoke_keys in invokeJavaCodeList:
                for javaCode in invoke_keys:
                    if (re.search(
                            '(?:\w+\.' + javaMethodObject.get_name() +
                            '\s*\()', invoke_keys[javaCode])):
                        for bpelInvokeObject in bpelInvokeObjectReferences:
                            if '--' in bpelInvokeObject.get_fullname():
                                if str(javaCode
                                       ) == bpelInvokeObject.get_fullname(
                                       ).split("--")[1]:
                                    cast.application.create_link(
                                        "callLink",
                                        bpelInvokeObject,
                                        javaMethodObject,
                                        bookmark=None)
                                    logging.debug(
                                        bpelInvokeObject.get_fullname())

        logging.debug("DONE!")
        pass
Esempio n. 4
0
    def findpattern(self, application, files, group, links, rf):
        #looping through Files

        for o in files:
            greferences = []
            extfile = group.find('RefFileExtension').text

            if o.get_name().find(extfile) is not -1:
                #   check if file is analyzed source code, or if it generated (Unknown)

                logging.debug("GenericRefLink :" + extfile)
                #   check if file is a program , skip the headers

                greferences += [
                    reference for reference in rf.find_references_in_file(o)
                ]
                for ref in greferences:
                    sobjcat = group.find('TargetObjectCategory').text
                    sobjname = group.find('TargetObjectname').text
                    if sobjname is None:
                        logging.debug("GenericRefLink :" + extfile +
                                      "application")
                        for callpgm in application.search_objects(
                                category=sobjcat, load_properties=False):
                            strreforg = str(ref.value)
                            strjvclsorg = callpgm.get_name()
                            if strreforg.find(strjvclsorg) is not -1:
                                slinktyp = group.find('LinkType').text
                                sorgin = group.find('LinkOrginRef').text
                                if sorgin.lower() == 'true':
                                    links.append((slinktyp, ref.object,
                                                  callpgm, ref.bookmark))
                                else:
                                    links.append((slinktyp, callpgm,
                                                  ref.object, ref.bookmark))
                            else:
                                Notfound = False
                    else:

                        for javaclass in application.search_objects(
                                category=sobjcat,
                                name=sobjname,
                                load_properties=False):
                            strreforg = str(ref.value)
                            strjvclsorg = javaclass.get_fullname()
                            if strreforg.find(strjvclsorg) is not -1:
                                slinktyp = group.find('LinkType').text
                                sorgin = group.find('LinkOrginRef').text
                                if sorgin.lower() == 'true':
                                    links.append((slinktyp, ref.object,
                                                  javaclass, ref.bookmark))
                                else:
                                    links.append((slinktyp, javaclass,
                                                  ref.object, ref.bookmark))
                            else:
                                Notfound = False
            else:

                logging.debug('outside' + str(o.get_name()))
    def searchmodule(self, application, key, file):
        # try :
        #Print.info("file scan module :"+Path(file.get_path()).name)
        rf = ReferenceFinder()
        greferences = []
        rf.add_pattern('moduleexport', before='', element='module.*', after='')
        greferences += [
            reference for reference in rf.find_references_in_file(file)
        ]
        for ref in greferences:

            try:
                if ref.value.find('module') is not -1:
                    if ref.value.find('=') is not -1:
                        response = ref.value.replace("=", '')
                        resp = response.replace("module", '')
                        cleanvalue = re.sub('[^0-9a-zA-Z.]+', ' ', resp)
                        fsharpmoduleObjReferences = application.search_objects(
                            category='fsharp_module',
                            name=cleanvalue,
                            load_properties=False)
                        if fsharpmoduleObjReferences is not None:
                            for o in fsharpmoduleObjReferences:
                                self.scan_fs(application, key, o, file)

            except AttributeError:
                logging.info("error search module sub")
    def end_application(self, application):
        logging.info(
            "fsharp : Running extension code at the end of an application")
        Rulekey = []
        RuleValue = []
        self.appobj = application
        #declare ownershipship for 1 diags (this call also performs the required init cleaning)
        self.QAdeclarerules(application)
        #application.declare_property_ownership('fsharplint_CustomMetrics.RulesHintRefactor',["fsharp_module"])
        s = self.get_plugin()
        #logging.info(str(s.get_plugin_directory()))
        self.xmlfile = str(s.get_plugin_directory()) + "\\rulemap.xml"
        logging.info(self.xmlfile)
        self.parsexmltree(self.xmlfile, "")

        for o in application.search_objects(category='sourceFile'):
            fn = o.get_fullname()
            ff = o.get_name()
            #
            #
            if fn.endswith('.fs'):
                self.currentsrcfile = fn
                #logging.info('sourceFile objects successfully retrieved 1'+fn)
                #if fn.find("ModelConverter.fs") is not -1:
                self.reset()

                #proc=subprocess.call(["powershell", pspath, fn],stdout=subprocess.PIPE)

                cform = "dotnet fsharplint lint " + '"' + fn + '"'
                #logging.info(cform)
                result = self.run_command(cform)
                cmdoutput = str(result[1])
                #logging.info(str(result[1]))
                if len(cmdoutput) > 0:
                    self.processmapping(application, cmdoutput, fn, o)
Esempio n. 7
0
 def CreatejmsQueuelink(self, application, jmstext):
     jmsObjectReferences = list(
         application.search_objects(category=jmstext, load_properties=True))
     javaMethodObjectReferences = list(
         application.search_objects(category='JSP_PROPERTY_MAPPING',
                                    load_properties=False))
     if len(jmsObjectReferences) > 0:
         for jmsObject in jmsObjectReferences:
             prop_type = jmsObject.get_property(
                 'JmsQueueProperties.sourcefile')
             if prop_type.lower() == 'properties':
                 method_name = jmsObject.get_name()
                 for javaObject in javaMethodObjectReferences:
                     javamethod_name = javaObject.get_name()
                     if javamethod_name == method_name:
                         cast.application.create_link("callLink",
                                                      jmsObject,
                                                      javaObject,
                                                      bookmark=None)
                         logging.debug("link created-->" + method_name)
Esempio n. 8
0
    def CFUpdateInsertTablesLinking(self, application,
                                    CFUpdateInsert_Tables_List):
        for items in CFUpdateInsert_Tables_List:
            logging.info("CFUpdateInsertTablesLinking")
            parent_type = items[0]
            parent_name = items[1]
            table_name = items[2]
            child = None
            #logging.info("parent_type.. " + str(parent_type))
            #logging.info("parent_name" + str(parent_name))
            #logging.info("table name.." + str(table_name))
            parentlist = list(
                application.search_objects(category=parent_type,
                                           name=parent_name,
                                           load_properties=False))
            #logging.info("parentlist" + str(parentlist))
            for parentobject in parentlist:
                if parentobject.get_name() == parent_name:
                    parent = parentobject
                    break

            tableslist = list(
                application.search_objects(
                    category='CAST_Oracle_RelationalTable',
                    name=table_name,
                    load_properties=False))
            #logging.info("tableslist" + str(tableslist))
            for tableobject in tableslist:
                #logging.info("Table Objects...CFUpdateInsertTablesLinking.." + str(tableobject.get_name))
                if tableobject.get_name() == table_name:
                    child = tableobject
                    logging.info("Child 333 obj" + str(child))
                    break

            if parent and child is not None:
                cast.application.create_link("useSelectLink", parent, child)
                logging.info("Link Created for Oracle table")

        pass
Esempio n. 9
0
 def Createxmljmslink(self,application,jmstext):
     jmsObjectReferences = list(application.search_objects(category=jmstext, load_properties= True))
     javaMethodObjectReferences = list(application.search_objects(category='JV_METHOD', load_properties=False))
     javaMethodclassReferences = list(application.search_objects(category='JV_CLASS', load_properties=False))
     if len(jmsObjectReferences)>0:
         for jmsObject in jmsObjectReferences :
                 #logging.info('method_name --> ' + jmsObject.get_name())
                 xml_type = jmsObject.get_property('JmsListenerProperties.sourcefile')
                 if xml_type.lower() == 'xml':
                     method_name = jmsObject.get_property('JmsListenerProperties.containerFactory')
                     for javaObject in javaMethodObjectReferences : 
                         javamethod_name = javaObject.get_name()
                         if javamethod_name ==  method_name:
                             #logging.info('method_name --> '+javamethod_name)
                             cast.application.create_link("callLink", jmsObject, javaObject, bookmark=None) 
                             logging.debug("link created-->" + method_name)
                             for javaclassObject in javaMethodclassReferences : 
                                 #logging.info('class_name --> ' + javaclassObject.get_name())
                                 javaclassmethod_name = javaclassObject.get_name()
                                 classmethod_name = jmsObject.get_property('JmsListenerProperties.id')
                                 if javaclassmethod_name ==  classmethod_name:
                                     #logging.info('method_name --> '+javaclassmethod_name)
                                     cast.application.create_link("callLink", jmsObject, javaclassObject, bookmark=None)
                                     logging.debug("link created-->" + classmethod_name)