Interface scanning method, device, equipment and storage medium based on Git source code

Through the interface scanning method based on Git source code, interface information is automatically identified and maintained, which solves the problem that manual operations in the existing technology cannot meet the rapid growth of business and quality improvement, and achieves interface changes covering the full range of applications and improvement of development efficiency.

CN118394407BActive Publication Date: 2024-09-10中邮消费金融有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410825471.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-09-10
Estimated Expiration
2044-06-25

AI Technical Summary

Technical Problem

Existing interface registration and difference comparison methods mainly rely on manual operations and cannot meet the needs of rapid business growth and quality improvement of enterprises.

Method used

The interface scanning method based on Git source code is used to monitor the multi-node message queue, start the asynchronous scanning process, determine the branch dependencies of the target Git project, build a neural network model for source code analysis, and automatically identify and maintain interface information.

Benefits of technology

It realizes automated processes, comprehensively detects code content, and fully covers application interface changes, improving the docking efficiency of developers and reducing the cumbersome process of manual entry and maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118394407B
    Figure CN118394407B
Patent Text Reader

Abstract

The present application belongs to the field of data processing technology, and discloses an interface scanning method, device, equipment and storage medium based on Git source code. The present application monitors a multi-node message queue, starts an interface asynchronous scanning process according to the monitored source code scanning message, determines the branch dependency corresponding to the target Git project; obtains the project source code from the preset registration information according to the branch dependency; builds a neural network model based on the project source code, and performs source code analysis on the project source code based on the neural network model to obtain the source code analysis result; determines the target interface information according to the annotation information in the source code analysis result. The automated process of the present application eliminates the cumbersome process for manual entry and maintenance of interfaces. Through source code scanning, it can comprehensively detect the code content, fully cover the interface changes of the application, and improve the docking efficiency of developers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a Git source code-based interface scanning method, device, equipment and storage medium. Background Art

[0002] With the rapid growth of enterprise business, more and more application services will be deployed, the interface capabilities provided will also increase accordingly, and the interaction between applications will become more complicated. At this time, interface registration is particularly important. However, the existing interface registration and difference comparison methods mostly use traditional manual operation and review methods, which cannot meet the requirements of rapid business growth and quality improvement. Summary of the invention

[0003] The main purpose of this application is to provide an interface scanning method, device, equipment and storage medium based on Git source code, aiming to solve the technical problem that most of the existing interface registration and difference comparison methods use traditional manual operation and review methods and cannot meet the requirements of rapid business growth and quality improvement.

[0004] To achieve the above purpose, the present application provides an interface scanning method based on Git source code, and the interface scanning method based on Git source code comprises the following steps:

[0005] Monitor the multi-node message queues, start the interface asynchronous scanning process according to the monitored source code scanning messages, and determine the branch dependencies corresponding to the target Git project;

[0006] Acquire project source code from preset registration information according to the branch dependency relationship;

[0007] Building a neural network model based on the project source code, and performing source code analysis on the project source code based on the neural network model to obtain a source code analysis result;

[0008] The target interface information is determined according to the target annotation information in the source code analysis result.

[0009] Optionally, before the step of monitoring the multi-node message queue and starting the interface asynchronous scanning process according to the monitored source code scanning message to determine the branch dependency relationship corresponding to the target Git project, the step further includes:

[0010] Enter the Gitlab project registration information through a scheduled task to obtain the first entry information;

[0011] Scan and enter the Springboot application entry according to each Git project included in the first entry information to obtain second entry information;

[0012] Obtain the Git project merged into the master branch regularly, perform interface scanning on the application affected by the Git project through the master branch, save all interface records, and obtain third input information;

[0013] Preset registration information is determined according to the first input information, the second input information, and the third input information.

[0014] Optionally, the step of monitoring the multi-node message queue, starting the interface asynchronous scanning process according to the monitored source code scanning message, and determining the branch dependency corresponding to the target Git project includes:

[0015] Monitor the multi-node message queue, start the interface asynchronous scanning process according to the monitored source code scanning message, and determine the dependency relationship according to the node type corresponding to the project to be scanned, the dependency relationship includes upward dependency relationship and downward dependency relationship;

[0016] Recursively searching the to-be-scanned item according to the upward dependency relationship and the downward dependency relationship to obtain upward metadata and downward metadata;

[0017] Determine a hierarchical directory relationship on which the application depends according to the upward metadata, the downward metadata, and the preset registration information;

[0018] Determine the branch dependency relationship corresponding to the target Git project based on the hierarchical directory relationship of the application dependency.

[0019] Optionally, the step of constructing a neural network model based on the project source code, performing source code analysis on the project source code based on the neural network model, and obtaining a source code analysis result includes:

[0020] Building a neural network model based on the project source code, and performing source code analysis on the project source code based on the neural network model to obtain a set of all class interpretation objects;

[0021] Convert the set of all class interpretation objects into a set of target forms, traverse the set of target forms, interpret each class one by one according to the interface annotation configuration method corresponding to the preset protocol, and obtain target annotation information;

[0022] A source code analysis result is determined according to the target annotation information.

[0023] Optionally, the preset protocol includes HTTP protocol, DUBBO protocol and KAFKA protocol, and the step of interpreting each class one by one according to the interface annotation configuration mode corresponding to the preset protocol to obtain target annotation information includes:

[0024] Interpreting each class one by one according to the interface annotation configuration method corresponding to the HTTP protocol to obtain first annotation information;

[0025] Interpret each class one by one according to the annotation configuration method and the XML configuration method corresponding to the DUBBO protocol to obtain second annotation information;

[0026] Interpret each class one by one according to the annotation configuration method corresponding to the KAFKA protocol and the Spring Cloud streaming configuration method to obtain third annotation information;

[0027] Target annotation information is determined according to the first annotation information, the second annotation information, and the third annotation information.

[0028] Optionally, the step of determining the target interface information according to the target annotation information in the source code analysis result includes:

[0029] Determine first interface information according to the class identifier corresponding to the first annotation information;

[0030] Determine the second interface information according to the class identifier corresponding to the second annotation information;

[0031] Determine the third interface information according to the class identifier corresponding to the third annotation information;

[0032] Target interface information is determined according to the first interface information, the second interface information, and the third interface information.

[0033] Optionally, after the step of determining the target interface information according to the target annotation information in the source code analysis result, the method further includes:

[0034] Regularly detect the record of Git projects being merged into the master branch, and obtain target applications with which the Git projects have dependencies;

[0035] Re-scan the master branch of the target application to obtain interface scanning results;

[0036] Compare the interface scan result with the original stock production version interface to obtain interface difference information;

[0037] The original interface is rewritten according to the interface difference information.

[0038] In addition, to achieve the above purpose, the present application also provides an interface scanning device based on Git source code, and the interface scanning device based on Git source code includes:

[0039] The relationship determination module is used to monitor the multi-node message queue, start the interface asynchronous scanning process according to the monitored source code scanning message, and determine the branch dependency relationship corresponding to the target Git project;

[0040] A source code acquisition module, used to acquire project source code from preset registration information according to the branch dependency relationship;

[0041] A source code analysis module, used to construct a neural network model based on the project source code, and perform source code analysis on the project source code based on the neural network model to obtain a source code analysis result;

[0042] The interface determination module is used to determine the target interface information according to the target annotation information in the source code analysis result.

[0043] In addition, to achieve the above-mentioned purpose, the present application also proposes an interface scanning device based on Git source code, the device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the interface scanning method based on Git source code as described above.

[0044] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the interface scanning method based on Git source code as described above are implemented.

[0045] One or more technical solutions proposed in this application have at least the following technical effects:

[0046] This application monitors multi-node message queues, starts an asynchronous interface scanning process based on the monitored source code scanning message, determines the branch dependency corresponding to the target Git project; obtains the project source code from the preset registration information based on the branch dependency; builds a neural network model based on the project source code, and performs source code analysis on the project source code based on the neural network model to obtain the source code analysis result; determines the target interface information based on the target annotation information in the source code analysis result. This application monitors multi-node message queues, performs asynchronous scanning on the source code, determines the branch dependency, and analyzes the source code based on the neural network model to determine the interface information. The automated process of this application eliminates the cumbersome process for manual entry and maintenance of interfaces. Through source code scanning, it can fully detect the code content and cover the interface changes of the application in a full range, thereby improving the docking efficiency of developers. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0048] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0049] Figure 1 A flowchart diagram of the first embodiment of the interface scanning method based on Git source code of the present application;

[0050] Figure 2 A schematic diagram of the overall design and implementation method provided for the first embodiment of the interface scanning method based on Git source code of this application;

[0051] Figure 3 A schematic diagram of Gitlab project registration information entry provided in the first embodiment of the interface scanning method based on Git source code of this application;

[0052] Figure 4 A schematic diagram of entering Springboot application entry registration information provided in the first embodiment of the interface scanning method based on Git source code of this application;

[0053] Figure 5 A schematic diagram of inputting preprocessed data registration information provided in the first embodiment of the interface scanning method based on Git source code of the present application;

[0054] Figure 6 A flowchart diagram of the second embodiment of the interface scanning method based on Git source code of the present application;

[0055] Figure 7 A schematic diagram of a single application scanning process provided in the second embodiment of the interface scanning method based on Git source code of the present application;

[0056] Figure 8 A schematic diagram of the interface audit process provided for the second embodiment of the interface scanning method based on Git source code of this application;

[0057] Fig. 9 This is a schematic diagram of the module structure of the interface scanning device based on Git source code in an embodiment of the present application;

[0058] Fig.10 This is a schematic diagram of the device structure of the hardware operating environment involved in the interface scanning method based on Git source code in an embodiment of the present application.

[0059] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0060] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0061] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0062] The main solution of the embodiment of the present application is: to monitor the multi-node message queue, start the interface asynchronous scanning process according to the monitored source code scanning message, and determine the branch dependency corresponding to the target Git project; obtain the project source code from the preset registration information according to the branch dependency; build a neural network model based on the project source code, and perform source code analysis on the project source code based on the neural network model to obtain the source code analysis result; determine the target interface information according to the target annotation information in the source code analysis result.

[0063] In this embodiment, for ease of description, the following description is made with the computing service device as the execution entity.

[0064] Since the existing interface registration and difference comparison methods in the prior art mostly use traditional manual operation and review methods, they cannot meet the requirements of rapid business growth and quality improvement.

[0065] This application provides a solution that can comprehensively detect code content and fully cover application interface changes, thereby improving the docking efficiency of developers.

[0066] From the above embodiments, it can be seen that the present application monitors multi-node message queues, performs asynchronous scanning on the source code, determines branch dependencies, and analyzes the source code based on a neural network model to determine interface information. The automated process of the present application eliminates the cumbersome process of manual entry and maintenance of interfaces. Through source code scanning, the code content can be fully detected, and the interface changes of the application can be fully covered, thereby improving the docking efficiency of developers.

[0067] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, including a device of an interface scanning system based on Git source code, etc. The following takes a computer as an example to illustrate this embodiment and the following embodiments.

[0068] Based on this, the embodiment of the present application provides an interface scanning method based on Git source code, referring to Figure 1 , Figure 1 A flowchart diagram of the first embodiment of the interface scanning method based on Git source code of the present application is provided.

[0069] In this embodiment, the interface scanning method based on Git source code includes steps S10 to S40:

[0070] Step S10, monitoring the multi-node message queue, starting the interface asynchronous scanning process according to the monitored source code scanning message, and determining the branch dependency corresponding to the target Git project.

[0071] It should be noted that this application monitors the multi-node message queue and performs asynchronous consumption based on the monitored source code scanning messages. Since the dependency of an application project does not only depend on the directory under its current Git project, it often needs to reference project codes in other warehouses. Therefore, when performing interface scanning analysis, it is necessary to determine the branch dependency corresponding to the target Git project. In this way, all relevant source codes of the Git project can be determined based on the branch dependency.

[0072] It is understandable that, in order to further illustrate the overall design and implementation of this application, the interface scanning process of this application can refer to Figure 2 As shown in the overall design and implementation diagram, when the producer receives a message to trigger source code scanning, the system will first determine whether the same application and the same branch are being scanned. If so, it will immediately return and prompt that the scanning is in progress; otherwise, it will enter the scanning queue. After the consumer listens to the message, it will scan the application.

[0073] In a feasible implementation, the step S10 also includes: entering the Gitlab project registration information through a scheduled task to obtain first entry information; scanning and entering the Springboot application entry according to each Git project contained in the first entry information to obtain second entry information; regularly obtaining the Git project merged into the master branch, and performing interface scanning on the application affected by the Git project through the master branch, and saving all interface records to obtain third entry information; determining the preset registration information based on the first entry information, the second entry information and the third entry information.

[0074] It should be noted that in order to improve the efficiency of interface scanning, this application pre-enters three types of project data through a scheduled task, including Gitlab project registration information, Springboot application entry registration information, and pre-processed data registration.

[0075] It should be understood that in order to illustrate the Gitlab project registration information entry process, refer to Figure 3The Gitlab project registration information entry diagram shown in the figure shows that through the API provided by Gitlab, all uploaded project information can be traversed, and all subdirectories of the Git project can be traversed to interpret its pom.xml file, and groupId and artifactId can be obtained, and registered and saved in the following formats:

[0076] A.Git project ID and http address information:

[0077]

[0078] B. Git project entry and groupId, atrifactId information:

[0079]

[0080] To illustrate the process of entering Springboot application entry registration information, refer to Figure 4 The schematic diagram of entering the Springboot application entry registration information is shown in step A. Through the operation in the previous step, the Springboot entry is scanned for each Git project. In the project, a special configuration file is agreed upon. For example, the application identification can be added to the bootstrap.properties file to identify the application number information. The identified results are registered and saved in the following format:

[0081] Application service entry information:

[0082]

[0083] To illustrate the process of entering preprocessing data registration information, refer to Figure 5 , the system will start a scheduled task to monitor the Git projects merged into the master branch, perform a rolling scan of the master branch of the application, and finally save two copies of the data: the result of the last master branch and the result of the latest scan of the master branch. By comparing the two copies of the master branch data, the changed interface can be obtained, which can then be merged into the existing production version interface registered with the system. The diagram of entering the pre-processed data registration information is shown, in which, after registering the information A and B above, an application can be scanned. Pre-processed data refers to the periodic acquisition of the Git project merged into the master, pre-scanning the application affected by the Git project using the master branch and saving all interface records. This data is used to compare the interface differences when scanning the demand branch.

[0084] It should be understood that the Gitlab project registration information is entered through a scheduled task to obtain the first entry information; the Springboot application entrance is scanned and entered according to each Git project contained in the first entry information to obtain the second entry information; the Git project merged into the master branch is obtained regularly, and the interface of the application affected by the Git project is scanned through the master branch, and all interface records are saved to obtain the third entry information; the preset registration information is determined based on the first entry information, the second entry information and the third entry information.

[0085] Step S20, obtaining project source code from preset registration information according to the branch dependency relationship.

[0086] It should be noted that in order to clarify the interface information, it is necessary to download the project source code required for each project based on the branch dependency relationship. However, the preset registration information includes the pre-stored Gitlab project registration information, so all project source codes can be obtained directly from the preset registration information.

[0087] In specific implementation, this application can use the API provided by Gitlab to traverse all uploaded project information according to branch dependencies, download all Git projects, load the sub-project class paths of all projects, and thus obtain all required project source codes.

[0088] Step S30, constructing a neural network model based on the project source code, and performing source code analysis on the project source code based on the neural network model to obtain a source code analysis result.

[0089] It should be noted that all project source codes are integrated together to build a neural network model, so as to perform source code analysis on all project source codes, obtain a set of all class interpretation objects, and convert all class interpretation objects into a set of target forms, and traverse the set of target forms to interpret each class one by one, so as to determine the source code analysis results.

[0090] It should be understood that the target form of the collection in this solution refers to Map<String, CtType> Type (where key is the full path name of the class and value is the class interpretation object), and the source code analysis result is obtained by looping each class of the Map for source code analysis.

[0091] Step S40: determining target interface information according to target annotation information in the source code analysis result.

[0092] It should be noted that the annotation information refers to the annotation information after the interpretation of each class in the source code analysis result, and the annotation information may be the annotation information constructed by the class identification information.

[0093] In the specific implementation, different interfaces are identified by scanning the special identifier of the class, so as to determine the interface information. The interface information can be interface information constructed by different field identifiers. When interpreting the class, the present application generates different fields for the class identifier in the annotation information according to the signature method in combination with different interface protocols, so that the uniqueness of the interface can be determined based on the field, so as to facilitate the later difference analysis of the interface.

[0094] This embodiment monitors the multi-node message queue, starts the interface asynchronous scanning process according to the monitored source code scanning message, determines the branch dependency corresponding to the target Git project; obtains the project source code from the preset registration information according to the branch dependency; builds a neural network model based on the project source code, and performs source code analysis on the project source code based on the neural network model to obtain the source code analysis result; determines the target interface information according to the target annotation information in the source code analysis result. This embodiment monitors the multi-node message queue, performs asynchronous scanning on the source code, determines the branch dependency, and analyzes the source code based on the neural network model to determine the interface information. The automated process of this embodiment eliminates the cumbersome process for manual entry and maintenance of interfaces. Through source code scanning, it can comprehensively detect the code content and cover the interface changes of the application in a full range, thereby improving the docking efficiency of developers.

[0095] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above introduction, and will not be described in detail later. Figure 6 , Figure 6 A flowchart diagram of the second embodiment of the interface scanning method based on Git source code of the present application.

[0096] In this embodiment, the step S10 further includes S101 to S104:

[0097] Step S101: monitor the multi-node message queue, start the interface asynchronous scanning process according to the monitored source code scanning message, and determine the dependency relationship according to the node type corresponding to the project to be scanned, wherein the dependency relationship includes an upward dependency relationship and a downward dependency relationship.

[0098] It should be noted that the dependencies of an application project do not only depend on the directory under the current Git project, but often reference project codes from other repositories. Therefore, the dependencies between projects need to be determined during interface scanning and analysis. For Maven projects, the node types include <parent>node, <dependencies>Node, if introduced in its pom file <parent>Node, which means there is an upward dependency relationship. If it is introduced in its pom file <dependencies>A node indicates a downward dependent relationship.

[0099] Step S102: recursively search the to-be-scanned items according to the upward dependency relationship and the downward dependency relationship to obtain upward metadata and downward metadata.

[0100] It should be noted that if a Maven project introduces <parent>Node, which means there is an upward dependency relationship. It is necessary to explain whether the parent <dependencies>If there is a node, it needs to be explained. And recursively search upward layer by layer until all items are found, and generate upward metadata for the searched data.

[0101] It is understandable that a Maven project introduces <dependencies>Node, which means there is a downward dependency relationship. <dependencies>All dependent nodes under it. Through the information in the preset registration information, recursively search downward layer by layer until all items are found, and generate downward metadata for the searched data.

[0102] Step S103: determining the hierarchical directory relationship on which the application depends according to the upward metadata, the downward metadata, and the preset registration information.

[0103] It should be noted that, through the information in the above preset registration information, as well as the metadata of the upward and downward dependencies, all the Maven projects that an application depends on and their sub-path relationships can be obtained as shown in the following table:

[0104]

[0105] That is, you need to record which sub-projects in which Git project are needed for each application in order to fully identify all the source code to be analyzed.

[0106] It should be understood that the hierarchical directory relationship of the application dependency is composed of all Maven projects that the application depends on and their sub-path relationships.

[0107] Step S104: Determine the branch dependency relationship corresponding to the target Git project according to the hierarchical directory relationship of the application dependency.

[0108] It should be noted that the hierarchical directory relationship of application dependencies can be used to determine which sub-projects in which Git project each application needs to use, so that the branch dependency corresponding to the target Git project can be determined according to the hierarchical directory relationship of application dependencies.

[0109] In the specific implementation, this application can download all Git projects according to the "hierarchical directory relationship of application dependencies" and load the sub-project class paths of all projects (the standard Maven project class is under / src / main / java).

[0110] In this embodiment, the step S30 also includes constructing a neural network model based on the project source code, and performing source code analysis on the project source code based on the neural network model to obtain a set of all class interpretation objects; converting the set of all class interpretation objects into a set in a target form, and traversing the set in the target form, interpreting each class one by one according to the interface annotation configuration method corresponding to the preset protocol to obtain target annotation information; determining the source code analysis result according to the target annotation information.

[0111] It should be noted that this application builds a neural network model based on Launcher and project source code, and performs source code analysis on the project source code based on the neural network model to obtain a set of all class interpretation objects. This application converts all class interpretation object sets into a geometry in the form of a Map, where the key is the full class path and the value is the interpretation class object, and interprets each class one by one by traversing the Map to obtain the target annotation information.

[0112] It should be understood that the preset protocols include HTTP, DUBBO and KAFKA. The HTTP interface supports two frameworks, Spring MVC and Jersey. The DUBBO interface supports two configuration modes: one is based on annotation configuration mode and the other is based on Xml configuration mode. The KAFKA interface supports two configuration modes: one is based on annotation configuration mode and the other is based on Spring Cloud streaming configuration mode.

[0113] In a specific implementation, the Java polymorphism characteristic is utilized to establish different implementation analysis processes for the interface of each protocol type, and the source code analysis result is determined according to the first annotation information, the second annotation information and the third annotation information.

[0114] Furthermore, the step of interpreting each class one by one according to the interface annotation configuration method corresponding to the preset protocol to obtain target annotation information includes: interpreting each class one by one according to the interface annotation configuration method corresponding to the HTTP protocol to obtain first annotation information; interpreting each class one by one according to the annotation configuration method and the Xml configuration method corresponding to the DUBBO protocol to obtain second annotation information; interpreting each class one by one according to the annotation configuration method and the SpringCloud streaming configuration method corresponding to the KAFKA protocol to obtain third annotation information; determining the target annotation information according to the first annotation information, the second annotation information and the third annotation information.

[0115] It should be noted that this application supports two frameworks based on the HTTP interface. One is Spring MVC, which mainly analyzes whether the class has annotations @RestController and @Controller. If yes, it further analyzes whether the method has annotations such as @GetMapping, @PostMapping and @RequestMapping. If yes, it can be determined as an interface, and then the value in the annotation is used as the URL of the interface, and the method input and output parameters are used as the input and output parameters of the interface, and finally converted into Json Schema. The other is Jersey, which can identify the method in the same way, just by replacing different annotations, so as to obtain the first annotation information;

[0116] It should be understood that this application supports two configuration methods based on the DUBBO interface, one is based on annotation configuration and the other is based on Xml configuration. The annotation configuration method is to scan whether there is an @Service annotation on the implementation class. If so, it can be determined to be a dubbo service class, and then the interface implemented by the class is obtained. The Json Schema can be generated in the same way. The Xml configuration method requires loading an Xml file at an external specified location and analyzing it. <dubbo:service>The node configuration obtains the corresponding dubbo service class, and then generates the interface content to obtain the second annotation information.

[0117] It is understandable that this application supports two configuration methods based on the KAFKA interface, one is based on the annotation configuration method, and the other is based on the Spring Cloud streaming configuration method. The annotation-based configuration method is to scan whether there is a @KafkaListener annotation on the class method. If so, it can be determined as a KAFKA interface. Since KAFKA is an asynchronous communication, there is no return value, and only the input parameters can generate the Json Schema. The streaming configuration method requires loading the .properties or .yml file at the external specified location, finding the information after spring.cloud.stream.bindings to interpret the topic, and the same method further generates the Json Schema to obtain the third annotation information.

[0118] In the specific implementation, to further explain the application interface scanning process, refer to Figure 7 From the single application scanning process diagram shown, it can be seen that this application determines whether the interface is compliant through the marking information contained in the annotation information, and determines whether the interface needs to be ignored, and then determines the interface information.

[0119] Furthermore, the step S40 also includes: determining the first interface information according to the class identifier corresponding to the first annotation information; determining the second interface information according to the class identifier corresponding to the second annotation information; determining the third interface information according to the class identifier corresponding to the third annotation information; determining the target interface information according to the first interface information, the second interface information and the third interface information.

[0120] It should be noted that the class identifiers in this application are identifiers generated according to different protocols. Since the interfaces of each protocol use different contents, in order to better identify whether an interface is unique in this application, this solution provides a signature method to identify the interface. The uniqueness can be determined based on this field.

[0121] The signature definition can be as follows:

[0122] HTTP protocol: (application identifier + http address + http method) converted to MD5;

[0123] DUBBO protocol: (application identifier + dubbo interface + dubbo method + dubbo version number) converted to MD5;

[0124] KAFKA protocol: (application identifier + topic) is converted to MD5.

[0125] It is understandable that by scanning the special identifier of the class, different interfaces are identified, and the output and input parameters of the interface are converted to Json Schema, and finally the necessary information of an interface is fully explained.

[0126] In the specific implementation, this application determines the interface type through different class identifiers corresponding to the HTTP protocol, DUBBO protocol, and KAFKA protocol, obtains the interface of this class according to the interface type, and converts the output and input parameters of this class interface into JsonSchema, thereby forming the interface information according to the class identifier and Json Schema information. This application analyzes the basic information of the interface and the input and output parameters and other data to find out the technical means of interfaces with high similarity and simulate the merger of new interfaces. This method can effectively reduce code redundancy, keep the code concise and simple, and greatly improve the cost of code maintenance.

[0127] This embodiment monitors a multi-node message queue, starts an interface asynchronous scanning process according to the monitored source code scanning message, and determines the dependency relationship according to the node type corresponding to the project to be scanned, wherein the dependency relationship includes an upward dependency relationship and a downward dependency relationship; recursively searches the project to be scanned according to the upward dependency relationship and the downward dependency relationship to obtain upward metadata and downward metadata; determines the hierarchical directory relationship of application dependency according to the upward metadata, the downward metadata, and the preset registration information; determines the branch dependency corresponding to the target Git project according to the hierarchical directory relationship of the application dependency; obtains the project source code from the preset registration information according to the branch dependency; constructs a neural network model based on the project source code, and performs source code analysis on the project source code based on the neural network model to obtain a source code analysis result; determines the target interface information according to the target annotation information in the source code analysis result. This embodiment monitors multi-node message queues, asynchronously scans the source code, determines branch dependencies, and analyzes the source code based on a neural network model to determine interface information. The automated process of this embodiment eliminates the cumbersome process of manual entry and maintenance of interfaces. Through source code scanning, it can comprehensively detect code content and fully cover application interface changes, thereby improving the docking efficiency of developers.

[0128] Based on the first embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those of the above-mentioned first embodiment can be referred to the above introduction and will not be repeated later.

[0129] In this embodiment, step S40 also includes: regularly detecting the record of merging the Git project into the master branch, and obtaining the target application with which the Git project has a dependency; re-scanning the master branch of the target application to obtain an interface scanning result; comparing the interface scanning result with the original existing production version interface to obtain interface difference information; and rewriting the original interface according to the interface difference information.

[0130] It should be noted that the source code analysis of this application improves the completeness and accuracy of the interface registration, ensures the quality of the interface when providing reference, and reduces communication costs. At the same time, it can audit the changes in the interface of the production version and finally reach an agreement with the master branch, without the need for manual scheduled changes.

[0131] It is understandable that since the development branch code of a version needs to be merged into the master branch after it goes online, this will cause inconsistency between the production version interface and the actual master branch code. In order to achieve eventual consistency, the production version interface audit process is introduced here. Figure 8 The interface audit process diagram shown in the figure is to obtain all applications affected by the Git project by regularly detecting the records of merging Git projects into the master branch, and then re-scan the master branch and compare the differences with the original production version interface to perform incremental updates. The following is the interface difference comparison method:

[0132] (1) Adding a new interface: Based on signature matching, if the interface does not exist in the stock interface but exists in the scanned interface, it will be added as a production version interface.

[0133] (2) Modify the interface: Based on the signature match, if the signature exists in both the stock interface and the scan interface but the structure or annotation has changed, the input and output parameters are updated.

[0134] (3) The offline interface is matched according to the signature. If the signature is found in the stock interface but not in the scan interface, it is marked as offline.

[0135] Among them, for the newly merged set, it will be compared with the stock production interface registered in the system, and compared as a newly added interface and a modified interface. For the newly added interface, it can be directly entered as the production version interface; for the modified interface, the input and output parameters will be overwritten according to the results of the new scan, and other information will be based on the stock production version.

[0136] It should be understood that this application designs a method for entering interfaces based on Git source code scanning. After developers complete the requirements review, they will design their respective functions. In this process, interface design is essential. Developers only need to define the Bean, path and method name of each interface input and output parameter on the code branch, submit the code and scan and identify it with one click through the source code, then the interface can be registered. As long as the source code has special identifiers (such as annotations, comments, or custom identifiers, etc.), it can be identified. After the code is scanned, it is displayed according to the three operation types of add, modify, and delete. Developers can click to compare the differences and confirm the entry work. This application can enable developers to reduce the tedious tasks of manually registering interfaces repeatedly during the code writing process, and can accurately identify the differences between the existing interfaces and the scanned interfaces to ensure consistency, greatly improving efficiency.

[0137] This embodiment monitors the multi-node message queue, starts the interface asynchronous scanning process according to the monitored source code scanning message, determines the branch dependency corresponding to the target Git project; obtains the project source code from the preset registration information according to the branch dependency; builds a neural network model based on the project source code, and performs source code analysis on the project source code based on the neural network model to obtain the source code analysis result; determines the target interface information according to the target annotation information in the source code analysis result. This embodiment monitors the multi-node message queue, performs asynchronous scanning on the source code, determines the branch dependency, and analyzes the source code based on the neural network model to determine the interface information. The automated process of this embodiment eliminates the cumbersome process for manual entry and maintenance of interfaces. Through source code scanning, it can comprehensively detect the code content and cover the interface changes of the application in a full range, thereby improving the docking efficiency of developers.

[0138] This application also provides an interface scanning device based on Git source code, please refer to Fig. 9 , the interface scanning device based on Git source code includes:

[0139] The relationship determination module 10 is used to monitor the multi-node message queue, start the interface asynchronous scanning process according to the monitored source code scanning message, and determine the branch dependency relationship corresponding to the target Git project;

[0140] A source code acquisition module 20, used to acquire project source code from preset registration information according to the branch dependency relationship;

[0141] A source code analysis module 30, used to construct a neural network model based on the project source code, and perform source code analysis on the project source code based on the neural network model to obtain a source code analysis result;

[0142] The interface determination module 40 is used to determine the target interface information according to the target annotation information in the source code analysis result.

[0143] Furthermore, the interface scanning device based on Git source code also includes an information entry module, which is used to enter the Gitlab project registration information through a scheduled task to obtain first entry information; scan and enter the Springboot application entrance according to each Git project contained in the first entry information to obtain second entry information; regularly obtain the Git project merged into the master branch, and perform interface scanning on the application affected by the Git project through the master branch, and save all interface records to obtain third entry information; determine the preset registration information based on the first entry information, the second entry information and the third entry information.

[0144] Furthermore, the relationship determination module 10 is also used to monitor the multi-node message queue, start the interface asynchronous scanning process according to the monitored source code scanning message, and determine the dependency relationship according to the node type corresponding to the project to be scanned, the dependency relationship includes upward dependency and downward dependency; recursively search the project to be scanned according to the upward dependency and the downward dependency to obtain upward metadata and downward metadata; determine the hierarchical directory relationship of application dependency according to the upward metadata, the downward metadata, and the preset registration information; determine the branch dependency corresponding to the target Git project according to the hierarchical directory relationship of the application dependency.

[0145] Furthermore, the source code analysis module 30 is also used to build a neural network model based on the project source code, and perform source code analysis on the project source code based on the neural network model to obtain a set of all class interpretation objects; convert the set of all class interpretation objects into a set in a target form, and traverse the set in the target form to interpret each class one by one according to the interface annotation configuration method corresponding to the preset protocol to obtain target annotation information; determine the source code analysis result based on the target annotation information.

[0146] Furthermore, the preset protocols include HTTP protocol, DUBBO protocol and KAFKA protocol, and the source code analysis module 30 is also used to interpret each class according to the interface annotation configuration method corresponding to the HTTP protocol to obtain first annotation information; interpret each class according to the annotation configuration method and Xml configuration method corresponding to the DUBBO protocol to obtain second annotation information; interpret each class according to the annotation configuration method and Spring Cloud streaming configuration method corresponding to the KAFKA protocol to obtain third annotation information; determine the target annotation information according to the first annotation information, the second annotation information and the third annotation information.

[0147] Furthermore, the interface determination module 40 is also used to determine the first interface information according to the class identifier corresponding to the first annotation information; determine the second interface information according to the class identifier corresponding to the second annotation information; determine the third interface information according to the class identifier corresponding to the third annotation information; and determine the target interface information according to the first interface information, the second interface information and the third interface information.

[0148] Furthermore, the interface determination module 40 is also used to periodically detect the record of Git projects being merged into the master branch, and obtain the target application with which the Git project has a dependency relationship; re-scan the master branch of the target application to obtain the interface scanning result; compare the interface scanning result with the original existing production version interface to obtain interface difference information; and rewrite the original interface according to the interface difference information.

[0149] The interface scanning device based on Git source code provided by the present application adopts the interface scanning method based on Git source code in the above embodiment, which can solve the technical problem of interface scanning based on Git source code. Compared with the prior art, the beneficial effects of the interface scanning device based on Git source code provided by the present application are the same as the beneficial effects of the interface scanning method based on Git source code provided by the above embodiment, and the other technical features of the interface scanning device based on Git source code are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0150] The present application provides an interface scanning device based on Git source code, and the interface scanning device based on Git source code includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the interface scanning method based on Git source code in the above-mentioned first embodiment.

[0151] Reference below Fig.10 , which shows a schematic diagram of the structure of an interface scanning device based on Git source code suitable for implementing the embodiment of the present application. The interface scanning device based on Git source code in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.10 The Git source code-based interface scanning device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0152] like Fig.10 As shown, the interface scanning device based on Git source code may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. Various programs and data required for the operation of the interface scanning device based on Git source code are also stored in RAM1004. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can allow the interface scanning device based on Git source code to communicate wirelessly or wired with other devices to exchange data. Although the figure shows an interface scanning device based on Git source code with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have alternatively.

[0153] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0154] The interface scanning device based on Git source code provided by the present application adopts the interface scanning method based on Git source code in the above embodiment, which can solve the technical problem of interface scanning based on Git source code. Compared with the prior art, the beneficial effects of the interface scanning device based on Git source code provided by the present application are the same as the beneficial effects of the interface scanning method based on Git source code provided by the above embodiment, and the other technical features of the interface scanning device based on Git source code are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0155] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0156] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0157] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the Git source code-based interface scanning method in the above-mentioned embodiment.

[0158] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.

[0159] The computer-readable storage medium may be included in the interface scanning device based on Git source code; or may exist independently without being assembled into the interface scanning device based on Git source code.

[0160] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by an interface scanning device based on Git source code, the interface scanning device based on Git source code: When the interface scanning device based on Git source code is executed, the interface scanning device based on Git source code: monitors the multi-node message queue, starts the interface asynchronous scanning process according to the monitored source code scanning message, and determines the branch dependency corresponding to the target Git project; obtains the project source code from the preset registration information according to the branch dependency; builds a neural network model based on the project source code, and performs source code analysis on the project source code based on the neural network model to obtain the source code analysis result; determines the target interface information according to the target annotation information in the source code analysis result.

[0161] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0162] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0163] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0164] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned interface scanning method based on Git source code, and can solve the technical problem of interface scanning based on Git source code. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the interface scanning method based on Git source code provided by the above-mentioned embodiment, and will not be repeated here.

[0165] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.< / dubbo:service> < / dependencies> < / dependencies> < / dependencies> < / parent> < / dependencies> < / parent> < / dependencies> < / parent>

Claims

1. An interface scanning method based on Git source code, characterized in that: The interface scanning method based on Git source code includes: Monitor the multi-node message queues, start the interface asynchronous scanning process according to the monitored source code scanning messages, and determine the branch dependencies corresponding to the target Git project; Acquire project source code from preset registration information according to the branch dependency relationship; Building a neural network model based on the project source code, and performing source code analysis on the project source code based on the neural network model to obtain a source code analysis result; Determine target interface information according to target annotation information in the source code analysis result; The step of monitoring the multi-node message queue, starting the interface asynchronous scanning process according to the monitored source code scanning message, and determining the branch dependency relationship corresponding to the target Git project includes: Monitor the multi-node message queue, start the interface asynchronous scanning process according to the monitored source code scanning message, and determine the dependency relationship according to the node type corresponding to the project to be scanned, the dependency relationship includes upward dependency relationship and downward dependency relationship; Recursively searching the to-be-scanned item according to the upward dependency relationship and the downward dependency relationship to obtain upward metadata and downward metadata; Determine a hierarchical directory relationship of application dependency according to the upward metadata, the downward metadata, and preset registration information; Determine the branch dependency relationship corresponding to the target Git project according to the hierarchical directory relationship of the application dependency; The step of constructing a neural network model based on the project source code, and performing source code analysis on the project source code based on the neural network model to obtain a source code analysis result includes: Building a neural network model based on the project source code, and performing source code analysis on the project source code based on the neural network model to obtain a set of all class interpretation objects; Convert the set of all class interpretation objects into a set of target forms, traverse the set of target forms, interpret each class one by one according to the interface annotation configuration method corresponding to the preset protocol, and obtain target annotation information; The source code analysis result is determined according to the target annotation information.

2. The method according to claim 1, characterized in that Before the step of monitoring the multi-node message queue and starting the interface asynchronous scanning process according to the monitored source code scanning message to determine the branch dependency relationship corresponding to the target Git project, the step further includes: Enter the Gitlab project registration information through a scheduled task to obtain the first entry information; Scan and enter the Springboot application entry according to each Git project included in the first entry information to obtain second entry information; Obtain the Git project merged into the master branch regularly, perform interface scanning on the application affected by the Git project through the master branch, save all interface records, and obtain third input information; Preset registration information is determined according to the first input information, the second input information, and the third input information.

3. The method according to claim 1, characterized in that The preset protocols include HTTP protocol, DUBBO protocol and KAFKA protocol, and the step of interpreting each class one by one according to the interface annotation configuration method corresponding to the preset protocol to obtain target annotation information includes: Interpreting each class one by one according to the interface annotation configuration method corresponding to the HTTP protocol to obtain first annotation information; Interpret each class one by one according to the annotation configuration method and the XML configuration method corresponding to the DUBBO protocol to obtain second annotation information; According to the annotation configuration method corresponding to the KAFKA protocol and the Spring Cloud streaming configuration method, each class is interpreted to obtain third annotation information; Target annotation information is determined according to the first annotation information, the second annotation information, and the third annotation information.

4. The method according to claim 3, characterized in that The step of determining the target interface information according to the target annotation information in the source code analysis result includes: Determine first interface information according to the class identifier corresponding to the first annotation information; Determine the second interface information according to the class identifier corresponding to the second annotation information; Determine the third interface information according to the class identifier corresponding to the third annotation information; Target interface information is determined according to the first interface information, the second interface information, and the third interface information.

5. The method according to claim 1, characterized in that After the step of determining the target interface information according to the target annotation information in the source code analysis result, the method further includes: Regularly detect the record of Git projects being merged into the master branch, and obtain target applications with which the Git projects have dependencies; Re-scan the master branch of the target application to obtain interface scanning results; Compare the interface scan result with the original stock production version interface to obtain interface difference information; The original interface is rewritten according to the interface difference information.

6. An interface scanning device based on Git source code, characterized in that: The device comprises: The relationship determination module is used to monitor the multi-node message queue, start the interface asynchronous scanning process according to the monitored source code scanning message, and determine the branch dependency relationship corresponding to the target Git project; A source code acquisition module, used to acquire project source code from preset registration information according to the branch dependency relationship; A source code analysis module, used to construct a neural network model based on the project source code, and perform source code analysis on the project source code based on the neural network model to obtain a source code analysis result; An interface determination module, used to determine target interface information according to target annotation information in the source code analysis result; The relationship determination module is further used to monitor the multi-node message queue, start the interface asynchronous scanning process according to the monitored source code scanning message, and determine the dependency relationship according to the node type corresponding to the project to be scanned, the dependency relationship includes an upward dependency relationship and a downward dependency relationship; recursively search the project to be scanned according to the upward dependency relationship and the downward dependency relationship to obtain upward metadata and downward metadata; determine the hierarchical directory relationship of application dependency according to the upward metadata, the downward metadata, and preset registration information; determine the branch dependency relationship corresponding to the target Git project according to the hierarchical directory relationship of the application dependency; The source code analysis module is also used to build a neural network model based on the project source code, and perform source code analysis on the project source code based on the neural network model to obtain a set of all class interpretation objects; convert the set of all class interpretation objects into a set in a target form, and traverse the set in the target form to interpret each class one by one according to the interface annotation configuration method corresponding to the preset protocol to obtain target annotation information; determine the source code analysis result according to the target annotation information.

7. An interface scanning device based on Git source code, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the Git source code-based interface scanning method as described in any one of claims 1 to 5.

8. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the interface scanning method based on Git source code are implemented as described in any one of claims 1 to 5.