CN117806739A - Determine methods, devices, media and equipment for calling relationships across code repositories - Google Patents

Determine methods, devices, media and equipment for calling relationships across code repositories Download PDF

Info

Publication number
CN117806739A
CN117806739A CN202311869147.XA CN202311869147A CN117806739A CN 117806739 A CN117806739 A CN 117806739A CN 202311869147 A CN202311869147 A CN 202311869147A CN 117806739 A CN117806739 A CN 117806739A
Authority
CN
China
Prior art keywords
function
target
calling
code
relationship
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311869147.XA
Other languages
Chinese (zh)
Inventor
周旭峰
王际豪
方泽群
成森
洪文涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Zitiao Network Technology Co Ltd
Original Assignee
Beijing Zitiao Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Zitiao Network Technology Co Ltd filed Critical Beijing Zitiao Network Technology Co Ltd
Priority to CN202311869147.XA priority Critical patent/CN117806739A/en
Publication of CN117806739A publication Critical patent/CN117806739A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本公开涉及一种跨代码仓库的调用关系确定方法、装置、介质及设备。所述方法包括:确定至少两个代码仓库所包含的函数和所述代码仓库中的函数之间的第一调用关系;对于所述代码仓库中存在远程调用行为的目标函数,确定所述目标函数远程调用的目标服务标识和目标接口标识;根据所述目标服务标识、所述目标接口标识和目标映射关系,确定所述目标函数跨代码仓库远程调用的目标路由函数,并形成所述目标函数和所述目标路由函数之间的第二调用关系,其中,所述目标映射关系用于指示代码仓库与服务之间的映射关系;根据所述第一调用关系和所述第二调用关系,生成所述至少两个代码仓库所包含的函数之间的函数调用关系。

The present disclosure relates to a method, apparatus, medium and device for determining a call relationship across code repositories. The method comprises: determining a first call relationship between functions contained in at least two code repositories and functions in the code repositories; for a target function in the code repositories that has a remote call behavior, determining a target service identifier and a target interface identifier for the remote call of the target function; determining a target routing function for the remote call of the target function across code repositories based on the target service identifier, the target interface identifier and the target mapping relationship, and forming a second call relationship between the target function and the target routing function, wherein the target mapping relationship is used to indicate a mapping relationship between a code repositories and a service; generating a function call relationship between functions contained in the at least two code repositories based on the first call relationship and the second call relationship.

Description

跨代码仓库的调用关系确定方法、装置、介质及设备Determine methods, devices, media and equipment for calling relationships across code repositories

技术领域Technical field

本公开涉及计算机技术领域,具体地,涉及一种跨代码仓库的调用关系确定方法、装置、介质及设备。The present disclosure relates to the field of computer technology, and in particular, to a method, apparatus, medium and device for determining a calling relationship across code repositories.

背景技术Background technique

随着数字化技术的发展,越来越多的工作流程和服务建立在软件系统上,导致软件系统日趋复杂,微服务技术应运而生。在微服务架构中,将整体的服务拆分成模块化的独立服务,每个服务存在独立的代码仓库,服务与服务之间通过接口和RPC(RemoteProcedure Call,远程过程调用协议)调用的方式进行交互。但是,随着微服务和组件数量的爆炸式增长,服务层的服务与服务之间、代码层的组件与组件之间的结构越来越复杂,往往存在多级依赖和多级数据传递,导致服务与服务之间的关系逐渐难以明确。With the development of digital technology, more and more workflows and services are built on software systems, causing software systems to become increasingly complex, and microservice technology emerged as the times require. In the microservice architecture, the overall service is split into modular independent services. Each service has an independent code warehouse. Services are communicated through interfaces and RPC (Remote Procedure Call) calls. Interaction. However, with the explosive growth of the number of microservices and components, the structures between services in the service layer and between components in the code layer are becoming more and more complex. There are often multi-level dependencies and multi-level data transfer, resulting in The relationship between services is becoming increasingly difficult to clarify.

发明内容Contents of the invention

提供该发明内容部分以便以简要的形式介绍构思,这些构思将在后面的具体实施方式部分被详细描述。该发明内容部分并不旨在标识要求保护的技术方案的关键特征或必要特征,也不旨在用于限制所要求的保护的技术方案的范围。This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

第一方面,本公开提供一种跨代码仓库的调用关系确定方法,所述方法包括:In a first aspect, the present disclosure provides a method for determining a calling relationship across code repositories. The method includes:

确定至少两个代码仓库所包含的函数和所述代码仓库中的函数之间的第一调用关系;Determine the first calling relationship between functions contained in at least two code repositories and functions in the code repositories;

对于所述代码仓库中存在远程调用行为的目标函数,确定所述目标函数远程调用的目标服务标识和目标接口标识;For the target function with remote calling behavior in the code warehouse, determine the target service identifier and target interface identifier of the remote call of the target function;

根据所述目标服务标识、所述目标接口标识和目标映射关系,确定所述目标函数跨代码仓库远程调用的目标路由函数,并形成所述目标函数和所述目标路由函数之间的第二调用关系,其中,所述目标映射关系用于指示代码仓库与服务之间的映射关系;According to the target service identifier, the target interface identifier and the target mapping relationship, determine the target routing function that the target function remotely calls across the code repository, and form a second calling relationship between the target function and the target routing function, wherein the target mapping relationship is used to indicate a mapping relationship between a code repository and a service;

根据所述第一调用关系和所述第二调用关系,生成所述至少两个代码仓库所包含的函数之间的函数调用关系。According to the first calling relationship and the second calling relationship, a function calling relationship between functions included in the at least two code repositories is generated.

第二方面,本公开提供一种跨代码仓库的调用关系确定装置,所述装置包括:In a second aspect, the present disclosure provides a device for determining a call relationship across code repositories, the device comprising:

第一确定模块,用于确定至少两个代码仓库所包含的函数和所述代码仓库中的函数之间的第一调用关系;A first determining module, configured to determine a first calling relationship between functions included in at least two code repositories and functions in the code repositories;

第二确定模块,用于对于所述代码仓库中存在远程调用行为的目标函数,确定所述目标函数远程调用的目标服务标识和目标接口标识;The second determination module is used to determine the target service identifier and target interface identifier of the remote call of the target function for the target function in the code warehouse that has remote calling behavior;

第三确定模块,用于根据所述目标服务标识、所述目标接口标识和目标映射关系,确定所述目标函数跨代码仓库远程调用的目标路由函数,并形成所述目标函数和所述目标路由函数之间的第二调用关系,其中,所述目标映射关系用于指示代码仓库与服务之间的映射关系;The third determination module is used to determine the target routing function that the target function calls remotely across the code warehouse according to the target service identifier, the target interface identifier and the target mapping relationship, and form the target function and the target route The second calling relationship between functions, wherein the target mapping relationship is used to indicate the mapping relationship between the code warehouse and the service;

第一生成模块,用于根据所述第一调用关系和所述第二调用关系,生成所述至少两个代码仓库所包含的函数之间的函数调用关系。The first generating module is used to generate a function calling relationship between functions included in the at least two code repositories according to the first calling relationship and the second calling relationship.

第三方面,本公开提供一种计算机可读介质,其上存储有计算机程序,该程序被处理装置执行时实现本公开第一方面所述方法的步骤。In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, and when the program is executed by a processing device, the steps of the method described in the first aspect of the present disclosure are implemented.

第四方面,本公开提供一种电子设备,包括:In a fourth aspect, the present disclosure provides an electronic device, including:

存储装置,其上存储有计算机程序;a storage device having a computer program stored thereon;

处理装置,用于执行所述存储装置中的所述计算机程序,以实现本公开第一方面所述方法的步骤。A processing device, configured to execute the computer program in the storage device to implement the steps of the method described in the first aspect of the present disclosure.

通过上述技术方案,确定至少两个代码仓库所包含的函数和代码仓库中的函数的第一调用关系,对于代码仓库中存在远程调用行为的目标函数,确定目标函数远程调用的目标服务标识和目标接口标识,根据目标服务标识、目标接口标识和目标映射关系,确定目标函数跨代码仓库远程调用的目标路由函数,并形成目标函数和目标路由函数之间的第二调用关系,再根据第一调用关系和第二调用关系,生成代码仓库中函数之间的函数调用关系。由此,通过构建代码仓库与服务之间的映射关系,使得能够根据远程调用的服务确定对应的代码仓库,进而明确定位到提供远程调用接口的路由函数,形成函数到函数之间的远程调用关系,即跨代码仓库的函数调用关系。这样,即便在跨仓库调用数据的场景中,依然能够形成函数之间的明确的调用关系,有利于基于该调用关系实现安全风险的发现和服务与服务之间数据传递的信息确认。Through the above technical solution, the first calling relationship between the functions contained in at least two code warehouses and the functions in the code warehouse is determined. For the target function with remote calling behavior in the code warehouse, the target service identifier and target of the remote calling of the target function are determined. Interface identification, based on the target service identification, target interface identification and target mapping relationship, determine the target routing function that the target function calls remotely across the code warehouse, and form a second calling relationship between the target function and the target routing function, and then based on the first call The relationship and the second calling relationship generate the function calling relationship between functions in the code warehouse. Therefore, by constructing the mapping relationship between the code warehouse and the service, the corresponding code warehouse can be determined according to the remotely called service, and then the routing function that provides the remote calling interface can be clearly located, forming a remote calling relationship between functions. , that is, the function calling relationship across code warehouses. In this way, even in scenarios where data is called across warehouses, a clear calling relationship between functions can still be formed, which is conducive to the discovery of security risks and the confirmation of data transfer between services based on this calling relationship.

本公开的其他特征和优点将在随后的具体实施方式部分予以详细说明。Other features and advantages of the present disclosure will be described in detail in the detailed description that follows.

附图说明Description of drawings

结合附图并参考以下具体实施方式,本公开各实施例的上述和其他特征、优点及方面将变得更加明显。贯穿附图中,相同或相似的附图标记表示相同或相似的元素。应当理解附图是示意性的,原件和元素不一定按照比例绘制。在附图中:The above and other features, advantages, and aspects of various embodiments of the present disclosure will become more apparent with reference to the following detailed description taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It is to be understood that the drawings are schematic and that elements and elements are not necessarily drawn to scale. In the attached picture:

图1是根据本公开的一种实施方式提供的跨代码仓库的调用关系确定方法的流程图;Figure 1 is a flow chart of a method for determining a calling relationship across code repositories according to an embodiment of the present disclosure;

图2是本公开提供的跨代码仓库的调用关系确定方法中一种示例性的函数调用图;FIG2 is an exemplary function call graph in the method for determining a call relationship across code repositories provided by the present disclosure;

图3是本公开提供的跨代码仓库的调用关系确定方法中一种示例性的修正前的函数调用图;Figure 3 is an exemplary function call diagram before modification in the cross-code repository calling relationship determination method provided by the present disclosure;

图4是本公开提供的跨代码仓库的调用关系确定方法中一种示例性的修正后的函数调用图;FIG4 is an exemplary modified function call graph in the method for determining a calling relationship across code repositories provided by the present disclosure;

图5是本公开提供的跨代码仓库的调用关系确定方法中一种示例性的总体流程示意图;FIG5 is a schematic diagram of an exemplary overall process of a method for determining a calling relationship across code repositories provided by the present disclosure;

图6是本公开的一种实施方式提供的跨代码仓库的调用关系确定装置的框图;Figure 6 is a block diagram of a cross-code repository calling relationship determination device provided by an embodiment of the present disclosure;

图7示出了适于用来实现本公开实施例的电子设备的结构示意图。FIG. 7 shows a schematic structural diagram of an electronic device suitable for implementing embodiments of the present disclosure.

具体实施方式Detailed ways

下面将参照附图更详细地描述本公开的实施例。虽然附图中显示了本公开的某些实施例,然而应当理解的是,本公开可以通过各种形式来实现,而且不应该被解释为限于这里阐述的实施例,相反提供这些实施例是为了更加透彻和完整地理解本公开。应当理解的是,本公开的附图及实施例仅用于示例性作用,并非用于限制本公开的保护范围。Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the disclosure are shown in the drawings, it should be understood that the disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, which rather are provided for A more thorough and complete understanding of this disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of the present disclosure.

应当理解,本公开的方法实施方式中记载的各个步骤可以按照不同的顺序执行,和/或并行执行。此外,方法实施方式可以包括附加的步骤和/或省略执行示出的步骤。本公开的范围在此方面不受限制。It should be understood that various steps described in the method implementations of the present disclosure may be executed in different orders and/or in parallel. Furthermore, method embodiments may include additional steps and/or omit performance of illustrated steps. The scope of the present disclosure is not limited in this regard.

本文使用的术语“包括”及其变形是开放性包括,即“包括但不限于”。术语“基于”是“至少部分地基于”。术语“一个实施例”表示“至少一个实施例”;术语“另一实施例”表示“至少一个另外的实施例”;术语“一些实施例”表示“至少一些实施例”。其他术语的相关定义将在下文描述中给出。The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

需要注意,本公开中提及的“第一”、“第二”等概念仅用于对不同的装置、模块或单元进行区分,并非用于限定这些装置、模块或单元所执行的功能的顺序或者相互依存关系。It should be noted that concepts such as “first” and “second” mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units. Or interdependence.

需要注意,本公开中提及的“一个”、“多个”的修饰是示意性而非限制性的,本领域技术人员应当理解,除非在上下文另有明确指出,否则应该理解为“一个或多个”。It should be noted that the modifications of "one" and "plurality" mentioned in this disclosure are illustrative and not restrictive. Those skilled in the art will understand that unless the context clearly indicates otherwise, it should be understood as "one or Multiple”.

本公开实施方式中的多个装置之间所交互的消息或者信息的名称仅用于说明性的目的,而并不是用于对这些消息或信息的范围进行限制。The names of messages or information exchanged between multiple devices in the embodiments of the present disclosure are for illustrative purposes only and are not used to limit the scope of these messages or information.

可以理解的是,在使用本公开各实施例公开的技术方案之前,均应当依据相关法律法规通过恰当的方式对本公开所涉及个人信息的类型、使用范围、使用场景等告知用户并获得用户的授权。It can be understood that before using the technical solutions disclosed in the embodiments of this disclosure, users should be informed of the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations and obtain the user's authorization. .

例如,在响应于接收到用户的主动请求时,向用户发送提示信息,以明确地提示用户,其请求执行的操作将需要获取和使用到用户的个人信息。从而,使得用户可以根据提示信息来自主地选择是否向执行本公开技术方案的操作的电子设备、应用程序、服务器或存储介质等软件或硬件提供个人信息。For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly remind the user that the operation requested will require the acquisition and use of the user's personal information. Therefore, users can autonomously choose whether to provide personal information to software or hardware such as electronic devices, applications, servers, or storage media that perform operations of the technical solution of the present disclosure based on the prompt information.

作为一种可选的但非限定性的实现方式,响应于接收到用户的主动请求,向用户发送提示信息的方式例如可以是弹窗的方式,弹窗中可以以文字的方式呈现提示信息。此外,弹窗中还可以承载供用户选择“同意”或者“不同意”向电子设备提供个人信息的选择控件。As an optional but non-limiting implementation method, in response to receiving the user's active request, the method of sending prompt information to the user may be, for example, a pop-up window, and the prompt information may be presented in the form of text in the pop-up window. In addition, the pop-up window can also contain a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

可以理解的是,上述通知和获取用户授权过程仅是示意性的,不对本公开的实现方式构成限定,其它满足相关法律法规的方式也可应用于本公开的实现方式中。It can be understood that the above process of notifying and obtaining user authorization is only illustrative and does not limit the implementation of the present disclosure. Other methods that satisfy relevant laws and regulations can also be applied to the implementation of the present disclosure.

同时,可以理解的是,本技术方案所涉及的数据(包括但不限于数据本身、数据的获取或使用)应当遵循相应法律法规及相关规定的要求。At the same time, it can be understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of corresponding laws, regulations and relevant regulations.

如背景技术所述,随着微服务和组件数量增长,服务与服务之间的结构越来越复杂,导致关系不明确。相关技术中,为了解决这一问题,往往采用在各个服务中插入探针代码的方式监控运行时的数据,但是,这一方式需要在各服务中均插入代码,实施成本高,且还需要额外考虑服务的性能和算力开销。As mentioned in the background art, as the number of microservices and components increases, the structure between services becomes more and more complex, resulting in unclear relationships. In related technologies, in order to solve this problem, the method of inserting probe code into each service is often used to monitor runtime data. However, this method requires inserting code into each service, which has high implementation costs and requires additional Consider the performance and computing overhead of the service.

此外,还可以采用代码分析的方式分析函数之间的调用关系,但是,目前的代码分析往往只能集中在单个的代码仓库,也就是只能分析单语言、单仓库之间的函数调用关系,应用场景比较单一。例如,一个SQL(Structured Query Language,结构化查询语言)注入漏洞,服务A的仓库是MySQL数据库的封装服务,服务B的仓库是业务代码,由于性能和SQL语句复杂性,服务A不具备SQL注入防御的能力,这就需要分析服务A的上层代码是否做了相应的防御,这可能涉及到多级依赖和数据传递过程,同时还涉及多开发语言的代码仓库的情况,函数间的调用关系依然难以明确。In addition, code analysis can also be used to analyze the calling relationship between functions. However, current code analysis can often only focus on a single code warehouse, that is, it can only analyze the function calling relationship between a single language and a single warehouse. The application scenario is relatively simple. For example, a SQL (Structured Query Language, Structured Query Language) injection vulnerability. The warehouse of service A is a package service of the MySQL database, and the warehouse of service B is business code. Due to performance and complexity of SQL statements, service A does not have SQL injection. Defense capabilities, this requires analyzing whether the upper-layer code of service A has implemented corresponding defenses. This may involve multi-level dependencies and data transfer processes, as well as code warehouses in multiple development languages. The calling relationship between functions remains Hard to pinpoint.

在本公开中所涉及到的函数是计算机技术中所限定的函数。在计算机技术中,函数是一种封装了可重复使用的代码块的机制,用于执行特定的操作或完成特定的任务。函数可以接受参数作为输入,通过代码的执行来实现特定的功能,并返回一个值作为输出,通过函数可以提供可组合、可重用和模块化的代码结构,便于代码的维护和扩展。与数学概念中的函数不同,代码中的函数是由编程语言提供的一种抽象概念,用于组织和管理代码。The functions involved in this disclosure are functions defined in computer technology. In computer technology, a function is a mechanism that encapsulates a reusable block of code that performs a specific operation or completes a specific task. Functions can accept parameters as input, implement specific functions through code execution, and return a value as output. Functions can provide a composable, reusable and modular code structure to facilitate code maintenance and expansion. Unlike functions in mathematical concepts, functions in code are an abstract concept provided by a programming language for organizing and managing code.

为了解决上述技术问题,本公开提供一种跨代码仓库的调用关系确定方法、装置、介质及设备。In order to solve the above technical problems, the present disclosure provides a method, device, medium and equipment for determining a calling relationship across code warehouses.

图1是根据本公开的一种实施方式提供的跨代码仓库的调用关系确定方法的流程图。FIG. 1 is a flow chart of a method for determining a calling relationship across code repositories according to an embodiment of the present disclosure.

一般情况下,代码遵循如下的业务数据流转模型:In general, the code follows the following business data flow model:

一个服务对应一个代码仓库,从语言层面包含一个或多个模块,其中包含有业务代码和依赖模块;A service corresponds to a code warehouse, which contains one or more modules at the language level, including business code and dependent modules;

每个服务(代码仓库)对外提供多个接口,不同的接口会向框架注册不同的入口函数,入口函数接收来自用户的请求数据或者其他服务的请求数据;Each service (code warehouse) provides multiple interfaces to the outside world. Different interfaces will register different entry functions with the framework. The entry functions receive request data from users or request data from other services;

入口函数获取请求数据后,根据不同的业务处理函数进行数据处理,比如调用数据库操作函数进行数据的增、删、改、查,在单仓库内,数据在函数的调用过程中流转;After the entry function obtains the requested data, it processes the data according to different business processing functions, such as calling database operation functions to add, delete, modify, and query data. In a single warehouse, data flows during the calling process of the function;

当跨服务调用(即,跨代码仓库调用)时,S1服务需要对框架客户端提供一个特殊函数调用(即,远程调用),框架通过目标地址(即,微服务ID)和接口名与S2服务的框架通信,S2服务的框架将数据发送给对应接口的入口函数进行处理,获取处理结果并返回给S1,在跨仓库之间,数据在远程调用的过程中流转,一般来说,框架客户端提供的调用函数直接连接到框架服务端注册的入口函数。When calling across services (i.e., calling across code repositories), the S1 service needs to provide a special function call (i.e., remote call) to the framework client. The framework communicates with the framework of the S2 service through the target address (i.e., microservice ID) and interface name. The framework of the S2 service sends the data to the entry function of the corresponding interface for processing, obtains the processing result and returns it to S1. Between repositories, data flows during the remote call process. Generally speaking, the calling function provided by the framework client is directly connected to the entry function registered with the framework server.

根据上述流转模型,可以初步构建出数据流转的骨架,这一骨架上通常存在如下几种数据元素:Based on the above flow model, the skeleton of data flow can be initially constructed. This skeleton usually contains the following data elements:

节点:表征代码仓库的仓库节点,代码仓库可以以仓库名作为仓库的唯一标识;表征代码所定义函数的函数节点,函数可以以函数名作为函数的唯一标识;Node: a repository node that represents a code repository. A code repository can use the repository name as the unique identifier of the repository. A function node that represents a function defined by the code. A function can use the function name as the unique identifier of the function.

关系:在仓库节点和函数节点之间的服务提供关系;仓库内函数与函数之间的调用关系;不同仓库的不同函数之间的远程调用关系。Relationship: the service provision relationship between warehouse nodes and function nodes; the calling relationship between functions in the warehouse; the remote calling relationship between different functions in different warehouses.

如图1所示,本公开提供的方法可以包括步骤11至步骤14。As shown in Figure 1, the method provided by the present disclosure may include steps 11 to 14.

在步骤11中,确定至少两个代码仓库所包含的函数和代码仓库中的函数之间的第一调用关系。In step 11, a first calling relationship between functions contained in at least two code warehouses and functions in the code warehouses is determined.

如上文所述,本公开涉及到跨代码仓库的数据调用场景,因此,本公开涉及到的代码仓库包括至少两个,且这至少两个代码仓库之间存在远程调用的行为。在实际的应用场景中,通常涉及多个代码仓库,并需要对这多个代码仓库中的函数调用关系进行确定。可选地,步骤11可以对涉及到的所有的代码仓库进行上述分析、确定。As mentioned above, the present disclosure involves data calling scenarios across code repositories. Therefore, the code repositories involved in the present disclosure include at least two, and there is remote calling behavior between the at least two code repositories. In actual application scenarios, multiple code warehouses are usually involved, and the function calling relationships in these code warehouses need to be determined. Optionally, step 11 can perform the above analysis and determination on all involved code repositories.

针对每一代码仓库,可以通过静态分析的方式,分别确定该代码仓库所包含的函数和该代码仓库中的函数之间的调用关系,也就是第一调用关系,第一调用关系就是一个代码仓库内部的函数与函数之间的调用关系。For each code repository, static analysis can be used to determine the calling relationship between the functions contained in the code repository and the functions in the code repository, that is, the first calling relationship. The first calling relationship is the calling relationship between functions within a code repository.

除此之外,还可以通过静态分析确定出代码仓库所提供的对外接口(例如,可以通过接口标识区分)、代码仓库远程调用的服务和接口、代码仓库中用于远程调用上述服务和接口的函数等。In addition, static analysis can also be used to determine the external interfaces provided by the code warehouse (for example, they can be distinguished by interface identifiers), the services and interfaces remotely called by the code warehouse, and the methods used in the code warehouse to remotely call the above services and interfaces. functions etc.

示例地,上述静态分析可以采用RTA(Rapid Type Analysis,快速类型分析)分析算法或VTA(Value-Flow Type Analysis,值流类型分析)实现。For example, the above static analysis can be implemented using RTA (Rapid Type Analysis, rapid type analysis) analysis algorithm or VTA (Value-Flow Type Analysis, value flow type analysis).

在步骤12中,对于代码仓库中存在远程调用行为的目标函数,确定目标函数远程调用的目标服务标识和目标接口标识。In step 12, for the target function with remote calling behavior in the code warehouse, determine the target service ID and target interface ID of the target function for remote calling.

如上文所述,通过静态代码分析可以确定出代码仓库远程调用的服务和接口,也能够确定出代码仓库中的哪个函数实施了上述远程调用,进而,容易确定存在远程调用行为的目标函数。As mentioned above, static code analysis can be used to determine the services and interfaces that are remotely called by the code repository, and it can also be used to determine which function in the code repository implements the remote call, thereby easily determining the target function that has the remote call behavior.

同时,在本公开中,服务可以通过服务标识(如,服务名)进行表征,接口可以通过接口标识(如,接口名)进行表征,基于此,容易确定目标函数所远程调用的服务的服务标识和接口标识,也就得到了目标服务标识和目标接口标识。At the same time, in the present disclosure, the service can be represented by a service identifier (such as a service name), and the interface can be represented by an interface identifier (such as an interface name). Based on this, it is easy to determine the service identifier and interface identifier of the service remotely called by the target function, and thus obtain the target service identifier and target interface identifier.

在步骤13中,根据目标服务标识、目标接口标识和目标映射关系,确定目标函数跨代码仓库远程调用的目标路由函数,并形成目标函数和目标路由函数之间的第二调用关系。In step 13, based on the target service identifier, the target interface identifier and the target mapping relationship, the target routing function that the target function calls remotely across the code warehouse is determined, and a second calling relationship between the target function and the target routing function is formed.

其中,目标映射关系可以用于指示代码仓库与服务之间的映射关系。Among them, the target mapping relationship can be used to indicate the mapping relationship between the code warehouse and the service.

由于在客户端所能获得的是服务和与服务相关的信息,对于该服务的代码、函数等是无法获知的,这些仅能在服务端通过与该服务对应的代码仓库中获得。因此,可以通过建立上述目标映射关系,将服务和代码仓库关联起来,以便于通过服务确定提供该服务的代码仓库,进而明确代码仓库内的相关信息。Since the client can only obtain the service and information related to the service, the code and functions of the service cannot be known, which can only be obtained on the server through the code repository corresponding to the service. Therefore, the service and the code repository can be associated by establishing the above target mapping relationship, so that the code repository providing the service can be determined through the service, and the relevant information in the code repository can be clarified.

可选地,目标映射关系可以通过以下方式确定:Optionally, the target mapping relationship can be determined by:

确定服务的服务标识与服务的接口标识之间的对应关系;Determine the correspondence between the service identifier of the service and the interface identifier of the service;

确定代码仓库的仓库标识与代码仓库的接口标识之间的对应关系;Determine the correspondence between the warehouse ID of the code warehouse and the interface ID of the code warehouse;

根据关联有相同接口标识的服务标识和仓库标识,生成目标映射关系。Generate a target mapping relationship based on the service ID and warehouse ID associated with the same interface ID.

示例地,可以在获取远程调用相关信息的同时提取出微服务调用信息,进而构建出服务标识(例如,服务ID)与服务的接口标识(例如,接口名)之间的对应关系的二元组。For example, the microservice call information can be extracted while obtaining the remote call related information, and then a tuple of the correspondence between the service identifier (for example, service ID) and the service's interface identifier (for example, interface name) can be constructed. .

示例地,可以在上述静态代码分析过程中,提取出代码仓库的对外接口,并形成仓库标识(例如,仓库名)与代码仓库的接口标识(例如,接口名)之间的对应关系的二元组。此时,接口所对应的函数(即,入口函数)也能通过静态代码分析获知。For example, during the above static code analysis process, the external interface of the code warehouse can be extracted, and a binary corresponding relationship between the warehouse identification (for example, warehouse name) and the interface identification (for example, interface name) of the code warehouse can be formed. Group. At this time, the function corresponding to the interface (ie, the entry function) can also be learned through static code analysis.

基于此,通过相同的接口标识(例如,同名的接口),即可将服务标识与仓库标识建立对应关系,进而形成服务与代码仓库之间的目标映射关系。Based on this, through the same interface identifier (for example, an interface with the same name), a corresponding relationship can be established between the service identifier and the warehouse identifier, thereby forming a target mapping relationship between the service and the code warehouse.

在一种可能的实施方式中,步骤13可以包括以下步骤:In a possible implementation, step 13 may include the following steps:

根据目标映射关系,确定与目标服务标识对应的目标代码仓库;According to the target mapping relationship, determine the target code warehouse corresponding to the target service identifier;

确定目标代码仓库中与目标接口标识相对应的接口所在的函数,作为目标路由函数,并形成所述目标函数和所述目标路由函数之间的第二调用关系。目标路由函数实质上就是目标函数所远程调用的其他代码仓库内的函数。Determine the function in the target code warehouse where the interface corresponding to the target interface identifier is located as the target routing function, and form a second calling relationship between the target function and the target routing function. The target routing function is essentially a function in other code repositories that is remotely called by the target function.

根据目标函数所远程调用的服务的目标服务标识,可以通过上述目标映射关系确定出对应的代码仓库,作为目标代码仓库。由于目标代码仓库是用于提供该服务的代码,因而被调用的接口是一致的,基于此,可以根据目标接口标识,在目标代码仓库中定位到对应的接口,进而,可以确定出该接口所在的函数,也就确定出了目标函数远程调用的路由函数,即目标路由函数。从而可以形成目标函数与目标路由函数之间的第二调用关系,第二调用关系就是不同代码仓库的不同函数之间的远程调用关系。According to the target service identifier of the service remotely called by the target function, the corresponding code warehouse can be determined through the above target mapping relationship as the target code warehouse. Since the target code repository is the code used to provide the service, the called interfaces are consistent. Based on this, the corresponding interface can be located in the target code repository according to the target interface identifier, and then the location of the interface can be determined. function, the routing function called remotely by the target function is determined, that is, the target routing function. Thus, a second calling relationship between the target function and the target routing function can be formed. The second calling relationship is the remote calling relationship between different functions in different code warehouses.

在步骤14中,根据第一调用关系和第二调用关系,生成至少两个代码仓库所包含的函数之间的函数调用关系。In step 14, a function calling relationship between functions included in at least two code repositories is generated according to the first calling relationship and the second calling relationship.

第一调用关系可以表征本公开所涉及的代码仓库中仓库内部的函数调用关系,第二调用关系可以表征存在远程调用的仓库之间的函数调用关系,如此,相当于形成了代码仓库(即,上述至少两个代码仓库)的全量的函数调用关系。The first calling relationship can represent the function calling relationship within the warehouse in the code warehouse involved in the present disclosure, and the second calling relationship can represent the function calling relationship between warehouses with remote calls. In this way, it is equivalent to forming a code warehouse (i.e., Full function calling relationships between at least two of the above code repositories).

在一种可能的实施方式中,可以根据第一调用关系和第二调用关系生成文档或列表,以表征上述函数调用关系。In a possible implementation, a document or a list may be generated according to the first calling relationship and the second calling relationship to characterize the above function calling relationship.

可选地,为了使函数调用关系更直观,还可以通过调用图的方式表征函数调用关系。因此,在另一种实施方式中,步骤14可以包括以下步骤:Optionally, in order to make the function calling relationship more intuitive, the function calling relationship can also be represented by a call graph. Therefore, in another embodiment, step 14 may include the following steps:

根据至少两个代码仓库所包含的函数,确定函数节点;Determine function nodes based on the functions contained in at least two code repositories;

根据第一调用关系,确定用于表征代码仓库内部调用的第一调用边,第一调用边用于连接同一代码仓库中的函数节点;According to the first calling relationship, determine the first calling edge used to represent internal calls in the code warehouse, and the first calling edge is used to connect function nodes in the same code warehouse;

根据第二调用关系,确定用于表征跨代码仓库调用的第二调用边,第二调用边用于连接不同代码仓库中的函数节点;According to the second calling relationship, determine a second calling edge used to represent cross-code repository calls, and the second calling edge is used to connect function nodes in different code repositories;

根据函数节点、第一调用边和第二调用边,生成用于表征函数调用关系的函数调用图。According to the function node, the first calling edge and the second calling edge, a function calling graph representing the function calling relationship is generated.

第一调用边、第二调用边对应有实施调用的上游函数节点和被调用的下游函数节点,因此,基于第一调用边、第二调用边可以将代码仓库涉及到的函数节点均对应实现连接,从而能够形成函数调用图。The first calling edge and the second calling edge correspond to the upstream function node that implements the call and the called downstream function node. Therefore, based on the first calling edge and the second calling edge, the function nodes involved in the code warehouse can be connected to each other. , thus forming a function call graph.

可选地,在函数调用图中还可以包含有仓库节点和用于表征仓库与入口函数之间的服务提供关系的边。Optionally, the function call graph may also include warehouse nodes and edges used to characterize the service provision relationship between the warehouse and the entry function.

示例地,函数调用图可以如图2所示。其中,作为根节点的两个节点均为仓库节点,其他节点均为函数节点,同一仓库内的函数节点之间通过第一调用边连接(例如,函数3调用函数5的调用边),不同仓库间的函数节点通过第二调用边连接(例如,函数5调用函数x的调用边)。For example, the function call graph can be shown in Figure 2. Among them, the two nodes as root nodes are both warehouse nodes, and the other nodes are function nodes. Function nodes in the same warehouse are connected through the first call edge (for example, the call edge of function 3 calling function 5). Different warehouses The function nodes between are connected by a second call edge (for example, the call edge of function 5 calling function x).

在一种可能的实施方式中,为了保证函数间可达性的准确性,还可以对调用边进行一定程度的修正,避免出现可达性错误的情况。因此,在这一实施方式中,在根据函数节点、第一调用边和第二调用边,生成用于表征函数调用关系的函数调用图的步骤之前,本公开提供的方法还可以包括以下步骤:In a possible implementation, in order to ensure the accuracy of reachability between functions, the calling edge can also be corrected to a certain extent to avoid reachability errors. Therefore, in this implementation, before the step of generating a function call graph representing a function call relationship based on the function node, the first call edge and the second call edge, the method provided by the present disclosure may further include the following steps:

若存在符合预设条件的目标函数节点,对调用边进行修正处理,调用边包括第一调用边和/或第二调用边。If there is a target function node that meets the preset conditions, the calling edge is corrected, and the calling edge includes the first calling edge and/or the second calling edge.

可选地,预设条件可以为:Optionally, the preset conditions can be:

调用边的入度达到第一阈值、调用边的出度达到第二阈值且函数节点对应的函数动态调用下游函数节点对应的函数。The in-degree of the call edge reaches a first threshold, the out-degree of the call edge reaches a second threshold, and the function corresponding to the function node dynamically calls the function corresponding to the downstream function node.

也就是说,若某个作为中间件的函数其调用边入度、出度均较多,且该中间件存在动态调用的情况,这极易导致可达性出现错误,因此,可以对调用边进行修正处理。That is to say, if a function as a middleware has a large number of in-degrees and out-degrees of calling edges, and the middleware is dynamically called, this can easily lead to reachability errors. Therefore, the calling edges can be Make corrections.

在一种可能的实施方式中,对调用边进行修正处理,可以包括以下步骤:In a possible implementation, correcting the calling edge may include the following steps:

删除目标函数节点与位于目标函数节点下游的第一函数节点之间的调用边,并生成位于目标函数节点上游的第二函数节点与第一函数节点之间的调用边,其中,第一函数节点对应的函数、目标函数节点对应的函数和第二函数节点对应的函数位于一条函数调用链路上。A call edge between a target function node and a first function node located downstream of the target function node is deleted, and a call edge between a second function node located upstream of the target function node and the first function node is generated, wherein the function corresponding to the first function node, the function corresponding to the target function node, and the function corresponding to the second function node are located on a function call link.

示例地,对于函数f1→函数f3→函数f4和f2→函数f3→函数f5这两个调用链路,易形成如图3所示的函数调用图,这就导致函数f1→函数f4和函数f2→函数f5的可达性出现混乱,基于此,可以将函数f3→函数f4和函数f3→函数f5这两个调用边删除,并生成函数f1→函数f4和函数f2→函数f5这两条调用边,如图4所示,以保证可达性的准确。For example, for the two call links of function f1→function f3→function f4 and f2→function f3→function f5, it is easy to form a function call graph as shown in Figure 3, which leads to confusion in the reachability of function f1→function f4 and function f2→function f5. Based on this, the two call edges of function f3→function f4 and function f3→function f5 can be deleted, and two call edges of function f1→function f4 and function f2→function f5 can be generated, as shown in Figure 4, to ensure the accuracy of reachability.

通过上述技术方案,确定至少两个代码仓库所包含的函数和代码仓库中的函数的第一调用关系,对于代码仓库中存在远程调用行为的目标函数,确定目标函数远程调用的目标服务标识和目标接口标识,根据目标服务标识、目标接口标识和目标映射关系,确定目标函数跨代码仓库远程调用的目标路由函数,并形成目标函数和目标路由函数之间的第二调用关系,再根据第一调用关系和第二调用关系,生成代码仓库中函数之间的函数调用关系。由此,通过构建代码仓库与服务之间的映射关系,使得能够根据远程调用的服务确定对应的代码仓库,进而明确定位到提供远程调用接口的路由函数,形成函数到函数之间的远程调用关系。这样,即便在跨仓库调用数据的场景中,依然能够形成函数之间的明确的调用关系,有利于基于该调用关系实现安全风险的发现和服务与服务之间数据传递的信息确认。Through the above technical solution, the first calling relationship between the functions contained in at least two code repositories and the functions in the code repository is determined. For the target function with remote calling behavior in the code repository, the target service identifier and the target interface identifier of the remote call of the target function are determined. According to the target service identifier, the target interface identifier and the target mapping relationship, the target routing function of the remote call of the target function across the code repository is determined, and the second calling relationship between the target function and the target routing function is formed. Then, according to the first calling relationship and the second calling relationship, the function calling relationship between the functions in the code repository is generated. Thus, by constructing the mapping relationship between the code repository and the service, the corresponding code repository can be determined according to the remotely called service, and then the routing function that provides the remote calling interface can be clearly located to form a remote calling relationship between functions. In this way, even in the scenario of calling data across warehouses, a clear calling relationship between functions can still be formed, which is conducive to the discovery of security risks and the information confirmation of data transmission between services based on the calling relationship.

可选地,本公开提供的方法还可以包括以下步骤:Optionally, the method provided by the present disclosure may also include the following steps:

将函数节点、第一调用边和第二调用边存储至在线的图数据库中。The function node, the first call edge, and the second call edge are stored in an online graph database.

如此,可以通过在线的图数据库满足在线的查询需求,响应较快。In this way, online query needs can be met through the online graph database, and the response is faster.

在一种可能的实施方式中,本公开提供的方法还可以包括以下步骤:In a possible implementation, the method provided by the present disclosure may further include the following steps:

接收数据更新指令,数据更新指令携带有指定更新周期内的数据变更信息,数据变更信息包括函数节点的变更信息、第一调用边的变更信息、第二调用边的变更信息中的至少一者;Receive a data update instruction, the data update instruction carries data change information within a specified update period, and the data change information includes at least one of change information of the function node, change information of the first calling edge, and change information of the second calling edge;

响应于数据更新指令,对图数据库进行更新。In response to the data update instructions, the graph database is updated.

示例地,指定更新周期可以为1天。也就是说,以天为单位确定存在变更的函数节点或调用边,并将该变更以天为单位更新到图数据库中。For example, the specified update period may be 1 day. In other words, the changed function nodes or call edges are determined in units of days, and the changes are updated to the graph database in units of days.

这样处理的原因在于,图数据库的性能有限,如果每次都进行全量导入,图数据的性能不足以支撑,因此,可以按照指定更新周期周期性地导入变更的部分,以保证性能,且能满足在线查询。需要说明的是,初次将节点、调用边一类的内容同步至图数据库时,可以进行全量导入。The reason for this processing is that the performance of the graph database is limited. If the full amount is imported every time, the performance of the graph data is not enough. Therefore, the changed parts can be imported periodically according to the specified update cycle to ensure performance and meet the requirements. online search. It should be noted that when synchronizing content such as nodes and calling edges to the graph database for the first time, you can import them in full.

在一种可能的实施方式中,本公开提供的方法还可以包括以下步骤:In a possible implementation, the method provided by the present disclosure may further include the following steps:

接收第一类查询指令,第一类查询指令用于查询第一函数的函数调用关系;receiving a first type of query instruction, where the first type of query instruction is used to query a function call relationship of a first function;

响应于第一类查询指令,确定图数据库中与第一函数对应的函数节点;In response to the first type of query instruction, determine the function node corresponding to the first function in the graph database;

确定与第一函数对应的函数节点所在调用链路的函数节点列表和调用边列表,调用边列表包括第一调用边和/或第二调用边;Determine the function node list and the calling edge list of the calling link where the function node corresponding to the first function is located, and the calling edge list includes the first calling edge and/or the second calling edge;

根据函数节点列表和调用边列表,生成查询结果并输出。Based on the function node list and the calling edge list, query results are generated and output.

在接收到第一类查询指令后,可以确定第一类查询指令所查询的第一函数对应的函数节点,这一步可以通过作为函数标识的函数名实现。进而,可以从图数据库中定位到第一函数对应的函数节点,以该函数节点为起点,分别向上、向下逐级确定存在调用关系的函数节点,直至查找到根节点和叶子节点,这样,也就获知了第一函数的调用链路,查找过程中经过的函数节点和调用边就可以分别形成列表,作为查询结果。示例地,查询结果可以通过JSON输出。After receiving the first type of query instruction, the function node corresponding to the first function queried by the first type of query instruction can be determined. This step can be achieved by using the function name as the function identifier. Furthermore, the function node corresponding to the first function can be located from the graph database. Taking the function node as the starting point, the function nodes with calling relationships are determined step by step upwards and downwards until the root node and leaf node are found. In this way, In this way, the calling link of the first function is known, and the function nodes and calling edges passed during the search process can be formed into lists respectively as query results. For example, query results can be output via JSON.

通过这一方式,可以通过在线的图数据库为用户提供直接查询的功能,简单方便。In this way, users can be provided with direct query functions through the online graph database, which is simple and convenient.

可选地,在本公开中,通过静态代码分析得到的内容(例如,代码仓库所包含的函数、代码仓库中的函数之间的调用关系、代码仓库所提供的对外接口、代码仓库中函数远程调用的服务和接口等),由于代码分析所产出的数据规模庞大,且代码分析需要的字段可能变化,可以存储在文档型数据库(如,MongoDB)中。示例地,该文档型数据库可以设置在线上。Optionally, in the present disclosure, the content obtained through static code analysis (e.g., functions contained in the code repository, calling relationships between functions in the code repository, external interfaces provided by the code repository, services and interfaces for remote calls of functions in the code repository, etc.) can be stored in a document-based database (e.g., MongoDB) because the data generated by code analysis is huge and the fields required for code analysis may change. For example, the document-based database can be set online.

在一种可能的实施方式中,本公开提供的方法还可以包括以下步骤:In a possible implementation, the method provided by the present disclosure may further include the following steps:

接收第二类查询指令,第二类查询指令用于查询第二函数的函数调用关系;Receive a second type of query instruction, which is used to query the function calling relationship of the second function;

响应于第二类查询指令,确定文档型数据库中与第二函数对应的第一调用关系并输出。In response to the second type of query instruction, the first calling relationship corresponding to the second function in the document database is determined and output.

在接收到第二类查询指令后,可以从文档型数据库中定位到第二函数对应的相关信息,进而确定出第二函数对应的第一调用关系,以进行输出。需要说明的是,基于第二类查询指令无法获得完整的调用链,只能查询到与第二函数存在调用关系(仓库内部的调用)的上一级或下一级的函数。After receiving the second type of query instruction, the relevant information corresponding to the second function can be located from the document database, and then the first calling relationship corresponding to the second function is determined for output. It should be noted that the complete call chain cannot be obtained based on the second type of query instructions. Only the upper-level or lower-level functions that have a calling relationship with the second function (calls within the warehouse) can be queried.

可选地,在本公开中,上述文档型数据库的数据还可以同步至离线数据库(如,Hive数据表),以供用户通过SQL语句进行离线查询。Optionally, in the present disclosure, the data of the above-mentioned document database can also be synchronized to an offline database (such as a Hive data table) for users to perform offline queries through SQL statements.

可选地,在本公开中,可以将静态代码分析后得到的内容和有关第一调用边的信息存储在在线的文档型数据库中,同时可以将该内容同步到离线数据库中,并通过离线数据库获取远程调用相关信息,离线进行函数间远程调用以及第二调用边的分析,进而,将分析结果存储到数据表中,该数据表中存储有全量的点表和边表,基于该数据表的内容向图数据库进行数据同步(即,初次全量导入,后续按照变更信息周期性同步)。示例地,图5示出了本公开的总的流程示意图。其中,静态代码分析可以通过例如Golang、Python、Node、Java等分析引擎实现。Optionally, in the present disclosure, the content obtained after static code analysis and the information about the first calling edge can be stored in an online document-type database, and the content can be synchronized to an offline database, and can be retrieved through the offline database Obtain the information related to remote calls, conduct remote call between functions and analyze the second call edge offline, and then store the analysis results in a data table. The data table stores a full amount of point tables and edge tables. Based on the data table The content is synchronized to the graph database (i.e., full import for the first time, followed by periodic synchronization based on change information). By way of example, FIG. 5 shows a general flow diagram of the present disclosure. Among them, static code analysis can be implemented through analysis engines such as Golang, Python, Node, and Java.

在一种可能的场景中,通过本公开提供的方法,可以实现安全漏洞的全链路梳理。举例来说,可以在确定潜在的风险函数后,基于本公开确定出的函数调用关系(如,函数调用图),快速定位到所有的调用到该风险函数的代码仓库,以提前规避风险。In one possible scenario, through the method provided by this disclosure, full-link combing of security vulnerabilities can be achieved. For example, after determining a potential risky function, you can quickly locate all code repositories that call the risky function based on the function call relationship (such as a function call graph) determined in this disclosure to avoid risks in advance.

在另一种可能的场景中,通过本公开提供的方法,可以实现风险的排查。举例来说,对于涉及到保密数据或敏感数据的业务,代码仓库所提供的服务通常需要进行严格的权限校验,如果服务的调用链上未使用权限校验函数,该服务可能会存在潜在的风险,基于本公开确定出的函数调用关系(如,函数调用图),可以十分方便地从全局判断是否使用了权限校验函数,实现风险的排查。In another possible scenario, risk investigation can be implemented through the method provided by this disclosure. For example, for businesses involving confidential or sensitive data, the services provided by the code warehouse usually require strict permission verification. If the permission verification function is not used in the call chain of the service, the service may have potential risks. Risk, based on the function call relationship (such as function call graph) determined by this disclosure, it is very convenient to judge whether the permission verification function is used from a global perspective, so as to implement risk investigation.

图6是本公开的一种实施方式提供的跨代码仓库的调用关系确定装置的框图。如图6所示,该装置80包括:Figure 6 is a block diagram of a cross-code repository calling relationship determination device provided by an embodiment of the present disclosure. As shown in Figure 6, the device 80 includes:

第一确定模块81,用于确定至少两个代码仓库所包含的函数和所述代码仓库中的函数之间的第一调用关系;The first determination module 81 is used to determine the first calling relationship between the functions contained in at least two code warehouses and the functions in the code warehouse;

第二确定模块82,用于对于所述代码仓库中存在远程调用行为的目标函数,确定所述目标函数远程调用的目标服务标识和目标接口标识;A second determination module 82 is used to determine, for a target function in the code repository that has a remote call behavior, a target service identifier and a target interface identifier for the remote call of the target function;

第三确定模块83,用于根据所述目标服务标识、所述目标接口标识和目标映射关系,确定所述目标函数跨代码仓库远程调用的目标路由函数,并形成所述目标函数和所述目标路由函数之间的第二调用关系,其中,所述目标映射关系用于指示代码仓库与服务之间的映射关系;The third determination module 83 is used to determine the target routing function that the target function calls remotely across the code warehouse according to the target service identifier, the target interface identifier and the target mapping relationship, and form the target function and the target The second calling relationship between routing functions, wherein the target mapping relationship is used to indicate the mapping relationship between the code warehouse and the service;

第一生成模块84,用于根据所述第一调用关系和所述第二调用关系,生成所述至少两个代码仓库所包含的函数之间的函数调用关系。The first generation module 84 is configured to generate a function calling relationship between functions included in the at least two code repositories based on the first calling relationship and the second calling relationship.

可选地,所述目标映射关系通过以下模块确定:Optionally, the target mapping relationship is determined through the following modules:

第四确定模块,用于确定所述服务的服务标识与所述服务的接口标识之间的对应关系;The fourth determination module is used to determine the correspondence between the service identifier of the service and the interface identifier of the service;

第五确定模块,用于确定所述代码仓库的仓库标识与所述代码仓库的接口标识之间的对应关系;The fifth determination module is used to determine the correspondence between the warehouse identification of the code warehouse and the interface identification of the code warehouse;

第二生成模块,用于根据关联有相同接口标识的服务标识和仓库标识,生成所述目标映射关系。The second generation module is used to generate the target mapping relationship according to the service identifier and the warehouse identifier associated with the same interface identifier.

可选地,所述第三确定模块83,包括:Optionally, the third determination module 83 includes:

第一确定子模块,用于根据所述目标映射关系,确定与所述目标服务标识对应的目标代码仓库;The first determination sub-module is used to determine the target code warehouse corresponding to the target service identifier according to the target mapping relationship;

第二确定子模块,用于确定所述目标代码仓库中与所述目标接口标识相对应的接口所在的函数,作为所述目标路由函数。The second determination submodule is used to determine a function in the target code repository where the interface corresponding to the target interface identifier is located as the target routing function.

可选地,所述第一生成模块84,包括:Optionally, the first generation module 84 includes:

第三确定子模块,用于根据所述至少两个代码仓库所包含的函数,确定函数节点;The third determination sub-module is used to determine function nodes based on the functions contained in the at least two code repositories;

第四确定子模块,用于根据所述第一调用关系,确定用于表征代码仓库内部调用的第一调用边,所述第一调用边用于连接同一代码仓库中的函数节点;a fourth determining submodule, configured to determine, according to the first calling relationship, a first calling edge for characterizing a call within the code repository, wherein the first calling edge is used to connect function nodes in the same code repository;

第五确定子模块,用于根据所述第二调用关系,确定用于表征跨代码仓库调用的第二调用边,所述第二调用边用于连接不同代码仓库中的函数节点;The fifth determination sub-module is used to determine the second calling edge used to represent cross-code warehouse calls according to the second calling relationship, and the second calling edge is used to connect function nodes in different code warehouses;

生成子模块,用于根据所述函数节点、所述第一调用边和所述第二调用边,生成用于表征函数调用关系的函数调用图。Generating a submodule, configured to generate a function call graph representing a function call relationship based on the function node, the first calling edge, and the second calling edge.

可选地,所述装置80还包括:Optionally, the device 80 also includes:

修正模块,在所述生成子模块根据所述函数节点、所述第一调用边和所述第二调用边,生成用于表征函数调用关系的函数调用图之前,若存在符合预设条件的目标函数节点,对调用边进行修正处理,所述调用边包括所述第一调用边和/或所述第二调用边。The correction module, before the generation submodule generates a function call graph for characterizing the function call relationship based on the function node, the first call edge and the second call edge, if there is a target function node that meets the preset conditions, the call edge is corrected, and the call edge includes the first call edge and/or the second call edge.

可选地,所述预设条件为:Optionally, the preset conditions are:

调用边的入度达到第一阈值、调用边的出度达到第二阈值且函数节点对应的函数动态调用下游函数节点对应的函数。The in-degree of the calling edge reaches the first threshold, the out-degree of the calling edge reaches the second threshold, and the function corresponding to the function node dynamically calls the function corresponding to the downstream function node.

可选地,所述修正模块用于:删除所述目标函数节点与位于所述目标函数节点下游的第一函数节点之间的调用边,并生成位于所述目标函数节点上游的第二函数节点与所述第一函数节点之间的调用边,其中,所述第一函数节点对应的函数、所述目标函数节点对应的函数和所述第二函数节点对应的函数位于一条函数调用链路上。Optionally, the correction module is used to: delete the call edge between the target function node and a first function node located downstream of the target function node, and generate a call edge between a second function node located upstream of the target function node and the first function node, wherein the function corresponding to the first function node, the function corresponding to the target function node, and the function corresponding to the second function node are located on a function call link.

可选地,所述装置80还包括:Optionally, the device 80 also includes:

将所述函数节点、所述第一调用边和所述第二调用边存储至在线的图数据库中。The function node, the first call edge, and the second call edge are stored in an online graph database.

可选地,所述装置80还包括:Optionally, the device 80 also includes:

第一接收模块,用于接收数据更新指令,所述数据更新指令携带有指定更新周期内的数据变更信息,所述数据变更信息包括函数节点的变更信息、第一调用边的变更信息、第二调用边的变更信息中的至少一者;The first receiving module is used to receive data update instructions. The data update instructions carry data change information within a specified update period. The data change information includes change information of function nodes, change information of the first calling edge, second Call at least one of the change information of the edge;

更新模块,用于响应于所述数据更新指令,对所述图数据库进行更新。An update module, configured to update the graph database in response to the data update instruction.

可选地,所述装置80还包括:Optionally, the device 80 further includes:

第二接收模块,用于接收第一类查询指令,所述第一类查询指令用于查询第一函数的函数调用关系;The second receiving module is used to receive the first type of query instructions, and the first type of query instructions are used to query the function calling relationship of the first function;

第六确定模块,用于响应于所述第一类查询指令,确定所述图数据库中与所述第一函数对应的函数节点;A sixth determination module, configured to determine the function node corresponding to the first function in the graph database in response to the first type of query instruction;

第七确定模块,用于确定与所述第一函数对应的函数节点所在调用链路的函数节点列表和调用边列表,所述调用边列表包括第一调用边和/或第二调用边;The seventh determination module is used to determine the function node list and the calling edge list of the calling link where the function node corresponding to the first function is located, and the calling edge list includes the first calling edge and/or the second calling edge;

第三生成模块,用于根据所述函数节点列表和所述调用边列表,生成查询结果并输出。The third generation module is used to generate query results according to the function node list and the calling edge list and output them.

关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Regarding the devices in the above embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments related to the method, and will not be described in detail here.

下面参考图7,其示出了适于用来实现本公开实施例的电子设备600的结构示意图。本公开实施例中的终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、PDA(个人数字助理)、PAD(平板电脑)、PMP(便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。图7示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。Referring to FIG. 7 , a schematic diagram of the structure of an electronic device 600 suitable for implementing the embodiment of the present disclosure is shown. The terminal device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. The electronic device shown in FIG. 7 is only an example and should not bring any limitation to the functions and scope of use of the embodiment of the present disclosure.

如图7所示,电子设备600可以包括处理装置(例如中央处理器、图形处理器等)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储装置608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有电子设备600操作所需的各种程序和数据。处理装置601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。As shown in FIG. 7 , the electronic device 600 may include a processing device (eg, central processing unit, graphics processor, etc.) 601 , which may be loaded into a random access device according to a program stored in a read-only memory (ROM) 602 or from a storage device 608 . The program in the memory (RAM) 603 executes various appropriate actions and processes. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, ROM 602 and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.

通常,以下装置可以连接至I/O接口605:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置606;包括例如液晶显示器(LCD)、扬声器、振动器等的输出装置607;包括例如磁带、硬盘等的存储装置608;以及通信装置609。通信装置609可以允许电子设备600与其他设备进行无线或有线通信以交换数据。虽然图7示出了具有各种装置的电子设备600,但是应理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, a liquid crystal display (LCD), speakers, vibration An output device 607 such as a computer; a storage device 608 including a magnetic tape, a hard disk, etc.; and a communication device 609. Communication device 609 may allow electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although FIG. 7 illustrates electronic device 600 with various means, it should be understood that implementation or availability of all illustrated means is not required. More or fewer means may alternatively be implemented or provided.

特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在非暂态计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置609从网络上被下载和安装,或者从存储装置608被安装,或者从ROM 602被安装。在该计算机程序被处理装置601执行时,执行本公开实施例的方法中限定的上述功能。In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product including a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the method illustrated in the flowchart. In such embodiments, the computer program may be downloaded and installed from the network via communication device 609, or from storage device 608, or from ROM 602. When the computer program is executed by the processing device 601, the above functions defined in the method of the embodiment of the present disclosure are performed.

需要说明的是,本公开上述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two. The computer-readable storage medium may be, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination thereof. More specific examples of computer readable storage media may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard drive, random access memory (RAM), read only memory (ROM), removable Programmed read-only memory (EPROM or flash memory), fiber optics, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In this disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code therein. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device . Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wire, optical cable, RF (radio frequency), etc., or any suitable combination of the above.

在一些实施方式中,客户端、服务器可以利用诸如HTTP(HyperText TransferProtocol,超文本传输协议)之类的任何当前已知或未来研发的网络协议进行通信,并且可以与任意形式或介质的数字数据通信(例如,通信网络)互连。通信网络的示例包括局域网(“LAN”),广域网(“WAN”),网际网(例如,互联网)以及端对端网络(例如,ad hoc端对端网络),以及任何当前已知或未来研发的网络。In some embodiments, the client and server can communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and can communicate with digital data in any form or medium. (e.g., communications network) interconnection. Examples of communications networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or developed in the future network of.

上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。The above-mentioned computer-readable medium may be included in the above-mentioned electronic device; it may also exist independently without being assembled into the electronic device.

上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备:确定至少两个代码仓库所包含的函数和所述代码仓库中的函数之间的第一调用关系;对于所述代码仓库中存在远程调用行为的目标函数,确定所述目标函数远程调用的目标服务标识和目标接口标识;根据所述目标服务标识、所述目标接口标识和目标映射关系,确定所述目标函数跨代码仓库远程调用的目标路由函数,并形成所述目标函数和所述目标路由函数之间的第二调用关系,其中,所述目标映射关系用于指示代码仓库与服务之间的映射关系;根据所述第一调用关系和所述第二调用关系,生成所述至少两个代码仓库所包含的函数之间的函数调用关系。The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: determines the functions contained in at least two code warehouses and the functions in the code warehouse. The first calling relationship between them; for the target function with remote calling behavior in the code warehouse, determine the target service identifier and target interface identifier of the remote call of the target function; according to the target service identifier, the target interface identifier and a target mapping relationship to determine the target routing function that the target function calls remotely across the code warehouse, and form a second calling relationship between the target function and the target routing function, where the target mapping relationship is used to indicate Mapping relationship between code repositories and services; generating a function calling relationship between functions contained in the at least two code repositories based on the first calling relationship and the second calling relationship.

可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,上述程序设计语言包括但不限于面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言——诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)——连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, including but not limited to object-oriented programming languages—such as Java, Smalltalk, C++, and Includes conventional procedural programming languages - such as "C" or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In situations involving remote computers, the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as an Internet service provider). connected via the Internet).

附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, segment, or portion of code that contains one or more logic functions that implement the specified executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown one after another may actually execute substantially in parallel, or they may sometimes execute in the reverse order, depending on the functionality involved. It will also be noted that each block of the block diagram and/or flowchart illustration, and combinations of blocks in the block diagram and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or operations. , or can be implemented using a combination of specialized hardware and computer instructions.

描述于本公开实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,模块的名称在某种情况下并不构成对该模块本身的限定,例如,第一确定模块还可以被描述为“确定至少两个代码仓库所包含的函数和所述代码仓库中的函数之间的第一调用关系的模块”。The modules involved in the embodiments of the present disclosure can be implemented in software or hardware. Among them, the name of the module does not constitute a limitation on the module itself under certain circumstances. For example, the first determination module can also be described as “determining the functions contained in at least two code warehouses and the functions in the code warehouse. The first calling relationship between modules".

本文中以上描述的功能可以至少部分地由一个或多个硬件逻辑部件来执行。例如,非限制性地,可以使用的示范类型的硬件逻辑部件包括:现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、片上系统(SOC)、复杂可编程逻辑设备(CPLD)等等。The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), Systems on Chips (SOCs), Complex Programmable Logical device (CPLD) and so on.

在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of this disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media may include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include electrical connections based on one or more wires, laptop disks, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.

根据本公开的一个或多个实施例,提供了一种跨代码仓库的调用关系确定方法,所述方法包括:According to one or more embodiments of the present disclosure, a method for determining call relationships across code repositories is provided, and the method includes:

确定至少两个代码仓库所包含的函数和所述代码仓库中的函数之间的第一调用关系;Determine the first calling relationship between functions contained in at least two code repositories and functions in the code repositories;

对于所述代码仓库中存在远程调用行为的目标函数,确定所述目标函数远程调用的目标服务标识和目标接口标识;For the target function with remote calling behavior in the code warehouse, determine the target service identifier and target interface identifier of the remote call of the target function;

根据所述目标服务标识、所述目标接口标识和目标映射关系,确定所述目标函数跨代码仓库远程调用的目标路由函数,并形成所述目标函数和所述目标路由函数之间的第二调用关系,其中,所述目标映射关系用于指示代码仓库与服务之间的映射关系;According to the target service identifier, the target interface identifier and the target mapping relationship, determine the target routing function that the target function remotely calls across the code repository, and form a second calling relationship between the target function and the target routing function, wherein the target mapping relationship is used to indicate a mapping relationship between a code repository and a service;

根据所述第一调用关系和所述第二调用关系,生成所述至少两个代码仓库所包含的函数之间的函数调用关系。According to the first calling relationship and the second calling relationship, a function calling relationship between functions included in the at least two code repositories is generated.

根据本公开的一个或多个实施例,提供了一种跨代码仓库的调用关系确定方法,所述目标映射关系通过以下方式确定:According to one or more embodiments of the present disclosure, a method for determining a call relationship across code repositories is provided, and the target mapping relationship is determined in the following manner:

确定所述服务的服务标识与所述服务的接口标识之间的对应关系;Determine the correspondence between the service identifier of the service and the interface identifier of the service;

确定所述代码仓库的仓库标识与所述代码仓库的接口标识之间的对应关系;Determine the correspondence between the warehouse identification of the code warehouse and the interface identification of the code warehouse;

根据关联有相同接口标识的服务标识和仓库标识,生成所述目标映射关系。The target mapping relationship is generated according to the service identifier and the warehouse identifier associated with the same interface identifier.

根据本公开的一个或多个实施例,提供了一种跨代码仓库的调用关系确定方法,所述根据所述目标服务标识、所述目标接口标识和目标映射关系,确定所述目标函数跨代码仓库远程调用的目标路由函数,包括:According to one or more embodiments of the present disclosure, a method for determining a cross-code repository calling relationship is provided. The target function is determined based on the target service identifier, the target interface identifier and the target mapping relationship. The target routing function of the warehouse remote call includes:

根据所述目标映射关系,确定与所述目标服务标识对应的目标代码仓库;Determine, according to the target mapping relationship, a target code repository corresponding to the target service identifier;

确定所述目标代码仓库中与所述目标接口标识相对应的接口所在的函数,作为所述目标路由函数。Determine the function in the target code repository where the interface corresponding to the target interface identifier is located as the target routing function.

根据本公开的一个或多个实施例,提供了一种跨代码仓库的调用关系确定方法,所述根据所述第一调用关系和所述第二调用关系,生成所述至少两个代码仓库所包含的函数之间的函数调用关系,包括:According to one or more embodiments of the present disclosure, a method for determining a calling relationship across code repositories is provided, wherein the at least two code repositories are generated based on the first calling relationship and the second calling relationship. Function calling relationships between included functions, including:

根据所述至少两个代码仓库所包含的函数,确定函数节点;Determine function nodes according to the functions contained in the at least two code repositories;

根据所述第一调用关系,确定用于表征代码仓库内部调用的第一调用边,所述第一调用边用于连接同一代码仓库中的函数节点;According to the first calling relationship, determine a first calling edge used to characterize internal calls in the code warehouse, and the first calling edge is used to connect function nodes in the same code warehouse;

根据所述第二调用关系,确定用于表征跨代码仓库调用的第二调用边,所述第二调用边用于连接不同代码仓库中的函数节点;According to the second calling relationship, determine a second calling edge used to characterize cross-code repository calls, and the second calling edge is used to connect function nodes in different code repositories;

根据所述函数节点、所述第一调用边和所述第二调用边,生成用于表征函数调用关系的函数调用图。A function call graph for representing a function call relationship is generated according to the function node, the first call edge, and the second call edge.

根据本公开的一个或多个实施例,提供了一种跨代码仓库的调用关系确定方法,在所述根据所述函数节点、所述第一调用边和所述第二调用边,生成用于表征函数调用关系的函数调用图的步骤之前,所述方法还包括:According to one or more embodiments of the present disclosure, a method for determining a calling relationship across code warehouses is provided, in which a method for determining a calling relationship is generated based on the function node, the first calling edge and the second calling edge. Before the step of forming a function call graph characterizing the function call relationship, the method further includes:

若存在符合预设条件的目标函数节点,对调用边进行修正处理,所述调用边包括所述第一调用边和/或所述第二调用边。If there is a target function node that meets the preset conditions, correction processing is performed on the calling edge, which includes the first calling edge and/or the second calling edge.

根据本公开的一个或多个实施例,提供了一种跨代码仓库的调用关系确定方法,所述预设条件为:According to one or more embodiments of the present disclosure, a method for determining call relationships across code repositories is provided, and the preset conditions are:

调用边的入度达到第一阈值、调用边的出度达到第二阈值且函数节点对应的函数动态调用下游函数节点对应的函数。The in-degree of the calling edge reaches the first threshold, the out-degree of the calling edge reaches the second threshold, and the function corresponding to the function node dynamically calls the function corresponding to the downstream function node.

根据本公开的一个或多个实施例,提供了一种跨代码仓库的调用关系确定方法,所述对调用边进行修正处理,包括:According to one or more embodiments of the present disclosure, a method for determining a call relationship across code repositories is provided, wherein the correction processing of the call edge includes:

删除所述目标函数节点与位于所述目标函数节点下游的第一函数节点之间的调用边,并生成位于所述目标函数节点上游的第二函数节点与所述第一函数节点之间的调用边,其中,所述第一函数节点对应的函数、所述目标函数节点对应的函数和所述第二函数节点对应的函数位于一条函数调用链路上。Delete a call edge between the target function node and a first function node located downstream of the target function node, and generate a call edge between a second function node located upstream of the target function node and the first function node, wherein the function corresponding to the first function node, the function corresponding to the target function node, and the function corresponding to the second function node are located on a function call link.

根据本公开的一个或多个实施例,提供了一种跨代码仓库的调用关系确定方法,所述方法还包括:According to one or more embodiments of the present disclosure, a method for determining call relationships across code repositories is provided, and the method further includes:

将所述函数节点、所述第一调用边和所述第二调用边存储至在线的图数据库中。The function node, the first calling edge and the second calling edge are stored in an online graph database.

根据本公开的一个或多个实施例,提供了一种跨代码仓库的调用关系确定方法,所述方法还包括:According to one or more embodiments of the present disclosure, a method for determining call relationships across code repositories is provided, and the method further includes:

接收数据更新指令,所述数据更新指令携带有指定更新周期内的数据变更信息,所述数据变更信息包括函数节点的变更信息、第一调用边的变更信息、第二调用边的变更信息中的至少一者;receiving a data update instruction, the data update instruction carrying data change information within a specified update period, the data change information including at least one of change information of a function node, change information of a first call edge, and change information of a second call edge;

响应于所述数据更新指令,对所述图数据库进行更新。In response to the data update instruction, the graph database is updated.

根据本公开的一个或多个实施例,提供了一种跨代码仓库的调用关系确定方法,所述方法还包括:According to one or more embodiments of the present disclosure, a method for determining call relationships across code repositories is provided, and the method further includes:

接收第一类查询指令,所述第一类查询指令用于查询第一函数的函数调用关系;receiving a first type of query instruction, where the first type of query instruction is used to query a function call relationship of a first function;

响应于所述第一类查询指令,确定所述图数据库中与所述第一函数对应的函数节点;In response to the first type of query instruction, determining a function node in the graph database corresponding to the first function;

确定与所述第一函数对应的函数节点所在调用链路的函数节点列表和调用边列表,所述调用边列表包括第一调用边和/或第二调用边;Determine the function node list and the calling edge list of the calling link where the function node corresponding to the first function is located, and the calling edge list includes the first calling edge and/or the second calling edge;

根据所述函数节点列表和所述调用边列表,生成查询结果并输出。According to the function node list and the calling edge list, query results are generated and output.

根据本公开的一个或多个实施例,提供了一种跨代码仓库的调用关系确定装置,所述装置包括:According to one or more embodiments of the present disclosure, a device for determining call relationships across code repositories is provided, and the device includes:

第一确定模块,用于确定至少两个代码仓库所包含的函数和所述代码仓库中的函数之间的第一调用关系;A first determining module, configured to determine a first calling relationship between functions included in at least two code repositories and functions in the code repositories;

第二确定模块,用于对于所述代码仓库中存在远程调用行为的目标函数,确定所述目标函数远程调用的目标服务标识和目标接口标识;The second determination module is used to determine the target service identifier and target interface identifier of the remote call of the target function for the target function in the code warehouse that has remote calling behavior;

第三确定模块,用于根据所述目标服务标识、所述目标接口标识和目标映射关系,确定所述目标函数跨代码仓库远程调用的目标路由函数,并形成所述目标函数和所述目标路由函数之间的第二调用关系,其中,所述目标映射关系用于指示代码仓库与服务之间的映射关系;The third determination module is used to determine the target routing function that the target function calls remotely across the code warehouse according to the target service identifier, the target interface identifier and the target mapping relationship, and form the target function and the target route The second calling relationship between functions, wherein the target mapping relationship is used to indicate the mapping relationship between the code warehouse and the service;

第一生成模块,用于根据所述第一调用关系和所述第二调用关系,生成所述至少两个代码仓库所包含的函数之间的函数调用关系。A first generation module, configured to generate a function calling relationship between functions included in the at least two code repositories based on the first calling relationship and the second calling relationship.

根据本公开的一个或多个实施例,提供了一种计算机可读介质,其上存储有计算机程序,该程序被处理装置执行时实现本公开任意实施例所述跨代码仓库的调用关系确定方法的步骤。According to one or more embodiments of the present disclosure, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processing device, the cross-code repository calling relationship determination method described in any embodiment of the present disclosure is implemented. A step of.

根据本公开的一个或多个实施例,提供了一种电子设备,包括:According to one or more embodiments of the present disclosure, there is provided an electronic device, including:

存储装置,其上存储有计算机程序;a storage device having a computer program stored thereon;

处理装置,用于执行所述存储装置中的所述计算机程序,以实现本公开任意实施例所述跨代码仓库的调用关系确定方法的步骤。A processing device, configured to execute the computer program in the storage device to implement the steps of the cross-code repository calling relationship determination method described in any embodiment of the present disclosure.

以上描述仅为本公开的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本公开中所涉及的公开范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本公开中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a description of the preferred embodiments of the present disclosure and the technical principles applied. Those skilled in the art should understand that the disclosure scope involved in the present disclosure is not limited to technical solutions composed of specific combinations of the above technical features, but should also cover solutions that are composed of the above technical features or without departing from the above disclosed concept. Other technical solutions formed by any combination of equivalent features. For example, a technical solution is formed by replacing the above features with technical features with similar functions disclosed in this disclosure (but not limited to).

此外,虽然采用特定次序描绘了各操作,但是这不应当理解为要求这些操作以所示出的特定次序或以顺序次序执行来执行。在一定环境下,多任务和并行处理可能是有利的。同样地,虽然在上面论述中包含了若干具体实现细节,但是这些不应当被解释为对本公开的范围的限制。在单独的实施例的上下文中描述的某些特征还可以组合地实现在单个实施例中。相反地,在单个实施例的上下文中描述的各种特征也可以单独地或以任何合适的子组合的方式实现在多个实施例中。Furthermore, although operations are depicted in a specific order, this should not be understood as requiring that these operations be performed in the specific order shown or performed in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.

尽管已经采用特定于结构特征和/或方法逻辑动作的语言描述了本主题,但是应当理解所附权利要求书中所限定的主题未必局限于上面描述的特定特征或动作。相反,上面所描述的特定特征和动作仅仅是实现权利要求书的示例形式。关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims. Regarding the devices in the above embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments related to the method, and will not be described in detail here.

Claims (13)

1.一种跨代码仓库的调用关系确定方法,其特征在于,所述方法包括:1. A method for determining call relationships across code warehouses, characterized in that the method includes: 确定至少两个代码仓库所包含的函数和所述代码仓库中的函数之间的第一调用关系;Determine the first calling relationship between functions contained in at least two code repositories and functions in the code repositories; 对于所述代码仓库中存在远程调用行为的目标函数,确定所述目标函数远程调用的目标服务标识和目标接口标识;For a target function in the code repository that has a remote call behavior, determine a target service identifier and a target interface identifier for the remote call of the target function; 根据所述目标服务标识、所述目标接口标识和目标映射关系,确定所述目标函数跨代码仓库远程调用的目标路由函数,并形成所述目标函数和所述目标路由函数之间的第二调用关系,其中,所述目标映射关系用于指示代码仓库与服务之间的映射关系;According to the target service identifier, the target interface identifier and the target mapping relationship, determine the target routing function that the target function calls remotely across the code warehouse, and form a second call between the target function and the target routing function Relationship, wherein the target mapping relationship is used to indicate the mapping relationship between the code warehouse and the service; 根据所述第一调用关系和所述第二调用关系,生成所述至少两个代码仓库所包含的函数之间的函数调用关系。According to the first calling relationship and the second calling relationship, a function calling relationship between functions included in the at least two code repositories is generated. 2.根据权利要求1所述的方法,其特征在于,所述目标映射关系通过以下方式确定:2. The method according to claim 1, characterized in that the target mapping relationship is determined in the following manner: 确定服务的服务标识与所述服务的接口标识之间的对应关系;Determine the correspondence between the service identifier of the service and the interface identifier of the service; 确定代码仓库的仓库标识与所述代码仓库的接口标识之间的对应关系;Determine the correspondence between the warehouse identification of the code warehouse and the interface identification of the code warehouse; 根据关联有相同接口标识的服务标识和仓库标识,生成所述目标映射关系。The target mapping relationship is generated according to the service identifier and the warehouse identifier associated with the same interface identifier. 3.根据权利要求1所述的方法,其特征在于,所述根据所述目标服务标识、所述目标接口标识和目标映射关系,确定所述目标函数跨代码仓库远程调用的目标路由函数,包括:3. The method of claim 1, wherein determining the target routing function for remote calling of the target function across code warehouses according to the target service identifier, the target interface identifier and the target mapping relationship includes: : 根据所述目标映射关系,确定与所述目标服务标识对应的目标代码仓库;According to the target mapping relationship, determine the target code warehouse corresponding to the target service identifier; 确定所述目标代码仓库中与所述目标接口标识相对应的接口所在的函数,作为所述目标路由函数。Determine the function in the target code repository where the interface corresponding to the target interface identifier is located as the target routing function. 4.根据权利要求1所述的方法,其特征在于,所述根据所述第一调用关系和所述第二调用关系,生成所述至少两个代码仓库所包含的函数之间的函数调用关系,包括:4. The method according to claim 1, characterized in that, according to the first calling relationship and the second calling relationship, a function calling relationship between functions contained in the at least two code warehouses is generated. ,include: 根据所述至少两个代码仓库所包含的函数,确定函数节点;Determine a function node according to the functions included in the at least two code repositories; 根据所述第一调用关系,确定用于表征代码仓库内部调用的第一调用边,所述第一调用边用于连接同一代码仓库中的函数节点;According to the first calling relationship, determine a first calling edge used to characterize internal calls in the code warehouse, and the first calling edge is used to connect function nodes in the same code warehouse; 根据所述第二调用关系,确定用于表征跨代码仓库调用的第二调用边,所述第二调用边用于连接不同代码仓库中的函数节点;Determine, according to the second call relationship, a second call edge for characterizing a cross-code repository call, where the second call edge is used to connect function nodes in different code repositories; 根据所述函数节点、所述第一调用边和所述第二调用边,生成用于表征函数调用关系的函数调用图。According to the function node, the first calling edge and the second calling edge, a function calling graph representing a function calling relationship is generated. 5.根据权利要求4所述的方法,其特征在于,在所述根据所述函数节点、所述第一调用边和所述第二调用边,生成用于表征函数调用关系的函数调用图的步骤之前,所述方法还包括:5. The method according to claim 4, characterized in that, according to the function node, the first calling edge and the second calling edge, a function call graph representing a function calling relationship is generated. Before step, the method also includes: 若存在符合预设条件的目标函数节点,对调用边进行修正处理,所述调用边包括所述第一调用边和/或所述第二调用边。If there is a target function node that meets the preset conditions, the call edge is modified, and the call edge includes the first call edge and/or the second call edge. 6.根据权利要求5所述的方法,其特征在于,所述预设条件为:6. The method according to claim 5, characterized in that the preset condition is: 调用边的入度达到第一阈值、调用边的出度达到第二阈值且函数节点对应的函数动态调用下游函数节点对应的函数。The in-degree of the calling edge reaches the first threshold, the out-degree of the calling edge reaches the second threshold, and the function corresponding to the function node dynamically calls the function corresponding to the downstream function node. 7.根据权利要求5所述的方法,其特征在于,所述对调用边进行修正处理,包括:7. The method according to claim 5, characterized in that the correction process on the calling edge includes: 删除所述目标函数节点与位于所述目标函数节点下游的第一函数节点之间的调用边,并生成位于所述目标函数节点上游的第二函数节点与所述第一函数节点之间的调用边,其中,所述第一函数节点对应的函数、所述目标函数节点对应的函数和所述第二函数节点对应的函数位于一条函数调用链路上。Delete the call edge between the target function node and the first function node located downstream of the target function node, and generate a call between the second function node located upstream of the target function node and the first function node Edge, wherein the function corresponding to the first function node, the function corresponding to the target function node, and the function corresponding to the second function node are located on a function call link. 8.根据权利要求4所述的方法,其特征在于,所述方法还包括:8. The method according to claim 4, characterized in that, the method further comprises: 将所述函数节点、所述第一调用边和所述第二调用边存储至在线的图数据库中。The function node, the first calling edge and the second calling edge are stored in an online graph database. 9.根据权利要求8所述的方法,其特征在于,所述方法还包括:9. The method according to claim 8, characterized in that the method further comprises: 接收数据更新指令,所述数据更新指令携带有指定更新周期内的数据变更信息,所述数据变更信息包括函数节点的变更信息、第一调用边的变更信息、第二调用边的变更信息中的至少一者;receiving a data update instruction, the data update instruction carrying data change information within a specified update period, the data change information including at least one of change information of a function node, change information of a first call edge, and change information of a second call edge; 响应于所述数据更新指令,对所述图数据库进行更新。In response to the data update instruction, the graph database is updated. 10.根据权利要求8所述的方法,其特征在于,所述方法还包括:10. The method according to claim 8, characterized in that the method further comprises: 接收第一类查询指令,所述第一类查询指令用于查询第一函数的函数调用关系;Receive a first type of query instruction, the first type of query instruction is used to query the function calling relationship of the first function; 响应于所述第一类查询指令,确定所述图数据库中与所述第一函数对应的函数节点;In response to the first type of query instruction, determine the function node corresponding to the first function in the graph database; 确定与所述第一函数对应的函数节点所在调用链路的函数节点列表和调用边列表,所述调用边列表包括第一调用边和/或第二调用边;Determine the function node list and the calling edge list of the calling link where the function node corresponding to the first function is located, where the calling edge list includes the first calling edge and/or the second calling edge; 根据所述函数节点列表和所述调用边列表,生成查询结果并输出。According to the function node list and the calling edge list, query results are generated and output. 11.一种跨代码仓库的调用关系确定装置,其特征在于,所述装置包括:11. A device for determining calling relationships across code warehouses, characterized in that the device includes: 第一确定模块,用于确定至少两个代码仓库所包含的函数和所述代码仓库中的函数之间的第一调用关系;A first determination module, configured to determine a first calling relationship between functions contained in at least two code repositories and functions in the code repositories; 第二确定模块,用于对于所述代码仓库中存在远程调用行为的目标函数,确定所述目标函数远程调用的目标服务标识和目标接口标识;The second determination module is used to determine the target service identifier and target interface identifier of the remote call of the target function for the target function in the code warehouse that has remote calling behavior; 第三确定模块,用于根据所述目标服务标识、所述目标接口标识和目标映射关系,确定所述目标函数跨代码仓库远程调用的目标路由函数,并形成所述目标函数和所述目标路由函数之间的第二调用关系,其中,所述目标映射关系用于指示代码仓库与服务之间的映射关系;The third determination module is used to determine the target routing function that the target function calls remotely across the code warehouse according to the target service identifier, the target interface identifier and the target mapping relationship, and form the target function and the target route The second calling relationship between functions, wherein the target mapping relationship is used to indicate the mapping relationship between the code warehouse and the service; 第一生成模块,用于根据所述第一调用关系和所述第二调用关系,生成所述至少两个代码仓库所包含的函数之间的函数调用关系。A first generation module, configured to generate a function calling relationship between functions included in the at least two code repositories based on the first calling relationship and the second calling relationship. 12.一种计算机可读介质,其上存储有计算机程序,其特征在于,该程序被处理装置执行时实现权利要求1-10中任一项所述方法的步骤。12. A computer-readable medium having a computer program stored thereon, characterized in that when the program is executed by a processing device, the steps of the method according to any one of claims 1 to 10 are implemented. 13.一种电子设备,其特征在于,包括:13. An electronic device, comprising: 存储装置,其上存储有计算机程序;a storage device having a computer program stored thereon; 处理装置,用于执行所述存储装置中的所述计算机程序,以实现权利要求1-10中任一项所述方法的步骤。A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1-10.
CN202311869147.XA 2023-12-29 2023-12-29 Determine methods, devices, media and equipment for calling relationships across code repositories Pending CN117806739A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311869147.XA CN117806739A (en) 2023-12-29 2023-12-29 Determine methods, devices, media and equipment for calling relationships across code repositories

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311869147.XA CN117806739A (en) 2023-12-29 2023-12-29 Determine methods, devices, media and equipment for calling relationships across code repositories

Publications (1)

Publication Number Publication Date
CN117806739A true CN117806739A (en) 2024-04-02

Family

ID=90431849

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311869147.XA Pending CN117806739A (en) 2023-12-29 2023-12-29 Determine methods, devices, media and equipment for calling relationships across code repositories

Country Status (1)

Country Link
CN (1) CN117806739A (en)

Similar Documents

Publication Publication Date Title
CN111679990B (en) Test data generation method and device, readable medium and electronic equipment
CN112597047B (en) Test method, test device, electronic equipment and computer readable medium
CN111324342B (en) Method, device, medium and electronic equipment for generating interface layer code
CN110851139B (en) Method and device for checking codes and electronic equipment
CN110659907A (en) Method and apparatus for executing smart contracts
US20210200806A1 (en) Method and apparatus for parallel processing of information
CN113918659A (en) Data manipulation method, device, storage medium and electronic device
CN115712597A (en) Information processing method, device, electronic equipment and storage medium
CN114764282B (en) Information processing method, device, terminal and storage medium
CN117807601A (en) Vulnerability detection method, device, medium and equipment for application program
CN117667710A (en) Determination method, test method, device, medium and equipment for page test case
CN112286773A (en) Method, device, medium and electronic equipment for collecting crash information
CN116823012A (en) A data analysis method, device, equipment and media, and program product
CN111787041A (en) Method and apparatus for processing data
WO2025016112A1 (en) Information transfer method and apparatus, medium, and electronic device
WO2024179565A1 (en) Task processing method and apparatus, and medium and electronic device
WO2024160121A1 (en) Data production method and apparatus, and medium and electronic device
CN112115154A (en) Data processing and data query method, device, equipment and computer readable medium
CN117806739A (en) Determine methods, devices, media and equipment for calling relationships across code repositories
CN113779315B (en) Information generation method, device, electronic device, and computer-readable medium
CN117931813A (en) Lake bin metadata change determining method, device, equipment and medium
CN111367590A (en) Interrupt event processing method and device
CN115098453B (en) Information storage method, apparatus, electronic device, and computer readable medium
CN114036053B (en) Test method, device, readable medium and electronic device
CN116886531A (en) Business processing methods, devices, media and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination