Code detection method and device, equipment, medium and product

By creating a simulated environment consistent with the operation function of the development environment plug-in in the integration stage, and reusing the plug-in in the development stage for code detection, the problem of high detection costs in different stages is solved, and the cost is effectively reduced.

CN120386708APending Publication Date: 2025-07-29BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410108256.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-25
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

The cost of code detection at different development stages and integration stages is high, mainly because different code detection plugins need to be configured separately.

Method used

By obtaining the environment configuration information of the development environment, creating a simulated environment, so that its plug-in operation functions are consistent with the development environment, so that plug-ins in the development stage are reused for code detection in the integration stage.

Benefits of technology

It realizes code detection with the same set of plug-ins at different stages, effectively reducing the cost of code detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120386708A_ABST
    Figure CN120386708A_ABST
Patent Text Reader

Abstract

The invention discloses a code detection method and device, equipment, a medium and a product, and the method comprises the steps: for a to-be-detected code in an integration stage, part or all of the to-be-detected code is written by utilizing a development environment in a development stage; the code detection process of the to-be-detected code in the integration stage specifically comprises the steps that firstly, environment simulation demand information is obtained, and the environment simulation demand information is determined according to environment configuration information of a development environment used in the development stage; according to the environment simulation demand information, a simulation environment is created, so that the plug-in running function of the simulation environment is consistent with the plug-in running function of the development environment, and the simulation environment can perform code detection processing by means of at least one plug-in in the development environment; in this way, code detection processing can be conducted in the mode that some plug-ins in the development stage are reused in the integration stage, and therefore the code detection cost can be effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technologies, and in particular, to a code detection method, apparatus, device, medium, and product. Background Art

[0002] Code detection is a relatively important process in the program development process.

[0003] In addition, for the program development process, the program development process usually includes multiple stages, such as a development stage, an integration stage, etc.

[0004] Furthermore, for the above-mentioned multiple stages, different code detection means are usually adopted in different stages, which results in a relatively high code detection cost. Summary of the Invention

[0005] This application provides a code detection method, apparatus, device, medium, and product, which can effectively reduce the code detection cost.

[0006] To achieve the above object, the technical solutions provided in this application are as follows:

[0007] This application provides a code detection method, and the method includes:

[0008] Receiving a code detection request, where the code detection request carries code description information and detection description information, the code description information is used to describe the code to be detected, and part or all of the code to be detected is written using a development environment; the detection description information is used to describe the detection constraints of the code to be detected;

[0009] Obtaining environment simulation requirement information, where the environment simulation requirement information is determined according to the environment configuration information of the development environment;

[0010] Creating a simulation environment according to the environment simulation requirement information; the plug-in running function of the simulation environment is consistent with the plug-in running function of the development environment; the simulation environment is used to perform code detection processing according to the code description information and at least one plug-in in the development environment; the at least one plug-in is determined according to the detection description information.

[0011] In a possible implementation manner, the detection description information includes plug-in constraints; the at least one plug-in is determined according to the plug-in constraints.

[0012] In a possible implementation manner, the detection description information includes code constraints; the simulation environment is used to perform code detection processing on the part of the code to be detected that meets the code constraints.

[0013] In a possible implementation, the simulation environment is specifically configured to:

[0014] Register the at least one plugin;

[0015] Deploy the code to be detected according to the code description information;

[0016] Perform configuration initialization processing on some or all of the at least one plugin;

[0017] Run the at least one plugin, which is used to implement the code detection process.

[0018] In a possible implementation, the code to be detected includes at least two code modules;

[0019] The deploying the code to be detected according to the code description information includes:

[0020] Create a file object corresponding to the code to be detected according to the code description information;

[0021] Create module objects corresponding to the code modules, and configure the module objects corresponding to the at least two code modules according to the module association relationship between the at least two code modules.

[0022] In a possible implementation, the code to be detected includes at least two code modules;

[0023] After receiving the code detection request, the method further includes:

[0024] Perform configuration according to the code description information to obtain a configuration result, where the configuration result includes the module association relationship between the at least two code modules;

[0025] After creating the simulation environment, the method further includes:

[0026] Send the code description information, the detection description information, and the module association relationship to the simulation environment; the simulation environment is specifically configured to perform code detection processing according to the code description information, the module association relationship, and at least one plugin in the development environment.

[0027] In a possible implementation, the code detection method is applied to a target plugin called in the integration stage.

[0028] The present application provides a code detection device, including:

[0029] A receiving unit, configured to receive a code detection request, where the code detection request carries code description information and detection description information, the code description information is used to describe the code to be detected, and part or all of the code to be detected is written using a development environment; the detection description information is used to describe the detection constraints of the code to be detected.

[0030] An obtaining unit, configured to obtain environment simulation requirement information, where the environment simulation requirement information is determined according to the environment configuration information of the development environment.

[0031] A creating unit, configured to create a simulation environment according to the environment simulation requirement information; the plug-in running function of the simulation environment is consistent with the plug-in running function of the development environment; the simulation environment is used to perform code detection processing according to the code description information and at least one plug-in in the development environment; the at least one plug-in is determined according to the detection description information.

[0032] This application provides an electronic device, characterized in that the device includes: a processor and a memory;

[0033] The memory is configured to store instructions or computer programs;

[0034] The processor is configured to execute the instructions or computer programs in the memory, so that the electronic device executes the code detection method provided by this application.

[0035] This application provides a computer-readable medium, characterized in that instructions or computer programs are stored in the computer-readable medium, and when the instructions or computer programs run on a device, the device is caused to execute the code detection method provided by this application.

[0036] This application provides a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program codes for executing the code detection method provided by this application.

[0037] Compared with the related art, this application has at least the following advantages:

[0038] In the technical solution provided by this application, for the code to be detected in the integration stage, some or all of the code to be detected is written using the development environment in the development stage. Moreover, the code detection process for the code to be detected in the integration stage is specifically as follows: First, obtain the environment simulation requirement information, and this environment simulation requirement information is determined based on the environment configuration information of the development environment used in the development stage, so that the environment simulation requirement information can describe the information required for simulating the development environment in the integration stage; then, based on the environment simulation requirement information, create a simulation environment, so that the plug-in running function of the simulation environment is consistent with the plug-in running function of the development environment, so that some plug-ins in the development environment can run normally in the simulation environment, and further enable the simulation environment to perform code detection processing with the help of at least one plug-in in the development environment. In this way, it is possible to implement code detection processing by reusing some plug-ins in the development stage in the integration stage, so that code detection processing can be performed using the same set of plug-ins in different stages, and further effectively overcome the cost caused by separately configuring different code detection processing implementation plug-ins for different stages, so that the code detection cost can be effectively reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only some embodiments recorded in this application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0040] Figure 1 It is a schematic diagram of the architecture of a development environment in the development stage provided by an embodiment of this application;

[0041] Figure 2 It is a flowchart of a code detection method provided by an embodiment of this application;

[0042] Figure 3 It is a schematic diagram of the working principle of a target plug-in called in the integration stage provided by an embodiment of this application;

[0043] Figure 4 It is a comparison schematic diagram between a simulation environment and a development environment provided by an embodiment of this application;

[0044] Figure 5 It is a logic schematic diagram of code detection processing using a virtual environment provided by an embodiment of this application;

[0045] Figure 6 It is a schematic diagram of an optimization solution for the code detection process in the integration stage provided by an embodiment of this application;

[0046] Figure 7 Schematic structural diagram of a code detection device provided by an embodiment of the present application;

[0047] Figure 8 Schematic structural diagram of an electronic device provided by an embodiment of the present application. Specific implementation manners

[0048] It has been found through research that for the above-mentioned development stage and integration stage, the code detection rules required in these two stages are usually the same. However, due to the significant differences between the frameworks used in the development stage and the integration stage, different ways need to be adopted to write the code detection rules in order to obtain code detection plugins that can be used in different stages. This results in a relatively high code detection cost. For example, for the development environment IntelliJ IDEA used in the development stage, although IntelliJ IDEA itself can provide code detection functions, the code detection functions provided by IntelliJ IDEA can only be used within IntelliJ IDEA and cannot run independently of the user interface (UI) of IntelliJ IDEA. Thus, in the integration stage, code detection processing can only be carried out by means of some additional plugins created for this integration stage, resulting in different plugins being used for code detection processing in different stages, and thus leading to a relatively high code detection cost.

[0049] Based on the above research, in order to better reduce costs, the present application provides a code detection method, which includes: First, receive a code detection request, which carries code description information and detection description information. The code description information is used to describe the code to be detected, and part or all of the code to be detected is written using a development environment; the detection description information is used to describe the detection constraints of the code to be detected; Then, obtain environment simulation requirement information, and the environment simulation requirement information is determined based on the environment configuration information of the development environment, so that the environment simulation requirement information can describe the information required for simulating the development environment during the integration stage; Finally, create a simulation environment based on the environment simulation requirement information. The plug-in running function of the simulation environment is consistent with the plug-in running function of the development environment. The simulation environment is used to perform code detection processing based on the code description information and at least one plug-in in the development environment; the at least one plug-in is determined based on the detection description information. Among them, because the plug-in running function of the simulation environment is consistent with the plug-in running function of the development environment, some plug-ins in the development environment can run normally in the simulation environment, so that the simulation environment can perform code detection processing with the help of at least one plug-in in the development environment. In this way, it is possible to perform code detection processing by reusing some plug-ins in the development stage during the integration stage, so that code detection processing can be performed using the same set of plug-ins in different stages, and thus the cost caused by separately configuring different code detection processing implementation plug-ins for different stages can be effectively overcome, so that the code detection cost can be effectively reduced.

[0050] In addition, the present application does not limit the execution subject of the code detection method provided by the embodiments of the present application. For example, the code detection method provided by the embodiments of the present application can be applied to a terminal device. Another example is that the code detection method provided by the embodiments of the present application can also be implemented by means of data interaction between a terminal device and a server. Among them, the terminal device can be a smart phone, a computer, a personal digital assistant (Personal Digital Assitant, PDA), a tablet computer, etc. The server can be an independent server, a cluster server or a cloud server.

[0051] In addition, in order to better improve the code detection effect, the code detection method provided by the present application can be applied to the target plug-in called during the integration stage, so that the target plug-in can be used to execute any implementation manner of the code detection method provided by the present application. It should be noted that the present application does not limit the implementation manner of the target plug-in. For example, the target plug-in can be implemented using a Gradle plug-in. It can be seen that in a possible implementation manner, the code detection method provided by the present application can be applied to the Gradle plug-in called during the integration stage.

[0052] To enable those skilled in the art to better understand the solution of this application, the following will clearly and completely describe the technical solutions in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts belong to the scope of protection of this application.

[0053] To better understand the technical solution provided by this application, the code detection method provided by this application will be described below with reference to some drawings. As Figure 2 shown, the code detection method provided by the embodiment of this application includes S1 - S3 below. Among them, this Figure 2 is a flowchart of a code detection method provided by the embodiment of this application.

[0054] S1: Receive a code detection request, which carries code description information and detection description information. The code description information is used to describe the code to be detected, and part or all of the code to be detected is written using a development environment; the detection description information is used to describe the detection constraints of the code to be detected.

[0055] Among them, the code detection request is used to request code detection processing in the integration stage. For example, the code detection request can be a request received by a target plug - in called in the integration stage.

[0056] In addition, for the above - mentioned code detection request, the code detection request carries code description information and detection description information so that the code detection request can indicate what code to perform which detection processing in the integration stage. For the convenience of understanding, these two pieces of information will be introduced separately below.

[0057] Regarding the above - mentioned code description information, the code description information is used to describe the code to be detected, such as the implementation code of a certain project or Figure 3 the project shown, etc. Among them, the code to be detected refers to the code involved in the integration stage that needs to be subjected to code detection processing; and part or all of the code to be detected is written using a development environment, such as IntelliJ IDEA, in the development stage. In addition, this application does not limit the code to be detected. For example, the code to be detected can be the implementation code written for a certain project with the help of IntelliJ IDEA. Another example is that the code to be detected can be the optimized code obtained by performing code optimization processing on the implementation code of a certain project with the help of IntelliJ IDEA. In addition, this application does not limit the implementation manner of the code description information. For example, when the code to be detected includes at least two code modules, such as Figure 3When referring to the Project Module shown above, the code description information may include the entry identifiers of each code module, so that the subsequent target plug-in in the above context can access the corresponding code module based on the entry identifier. Among them, for any code module, the entry identifier of the code module is used to uniquely identify the access path of the code module. In this way, the code description information including the entry identifiers of all code modules can represent the access path of the code to be detected, so that the code to be detected and its related information can be obtained based on the code description information subsequently.

[0058] Regarding the above detection description information, the detection description information is used to describe the detection constraints of the code to be detected. That is, some constraints that need to be referred to when performing code detection processing on the code to be detected during the integration phase. In addition, the present application does not limit the implementation manner of the detection description information. For example, in some application scenarios, the detection description information may include at least one of plug-in constraints and code constraints. Among them, the plug-in constraint is used to limit the plug-ins that need to be used when performing code detection processing on the code to be detected during the integration phase, so that the plug-ins that need to be reused in the development environment can be determined based on the plug-in constraint during the code detection processing of the code to be detected in the future; and the present application does not limit the plug-in constraint. For example, the plug-in constraint may include some detection rules. The code constraint is used to describe the part of the code to be detected that needs to be subjected to code detection processing, so that the part of the code to be detected that meets the code constraint can be subjected to code detection processing subsequently. In addition, the present application does not limit the acquisition method of the detection description information. For example, relevant personnel can configure the detection description information through any constraint configuration method, such as Figure 3 the method of the Build Script shown above.

[0059] Based on the relevant content of S1 above, it can be known that in the integration phase, relevant personnel can call the target plug-in through the instruction trigger method, so that the target plug-in can receive the code detection request conveyed by the instruction, so that the target plug-in can learn from the code detection request which codes need to be subjected to code detection processing and some constraints that need to be referred to when performing code detection processing, such as plug-in constraints, etc.

[0060] S2: Obtain the environment simulation requirement information, which is determined based on the environment configuration information of the development environment.

[0061] Among them, the environment simulation requirement information refers to the information that needs to be relied on when creating a simulation environment of the above development environment during the integration phase, such as some codes in the implementation code of the development environment.

[0062] In addition, the above-mentioned environment simulation requirement information is determined based on the environment configuration information of the development environment, so that the environment simulation requirement information can represent the information required for creating the simulation environment of the development environment. Moreover, the present application does not limit the environment simulation requirement information. For example, the environment simulation requirement information may include a part of the environment configuration information of the development environment. Among them, the environment configuration information of the development environment is used to describe the characteristics of the development environment. Moreover, the present application does not limit the implementation manner of the environment configuration information. For example, the environment configuration information may adopt the implementation code of the development environment, such as the code for implementing the development environment shown in Figure 4 is implemented. It can be seen that in a possible implementation manner, when the environment configuration information of the development environment is the implementation code of the development environment, the environment simulation requirement information may be determined based on the implementation code of the development environment, so that the environment simulation requirement information includes a part of the implementation code of the development environment, such as the code required for implementing the plug-in operation function.

[0063] In addition, the present application does not limit the implementation manner of the above-mentioned S2. For example, in some application scenarios, when the environment configuration information of the above-mentioned development environment is stored in the cloud in advance, S2 may specifically be: obtaining the above-mentioned environment simulation requirement information from the stored data in the cloud, so as to effectively avoid the resource pressure caused when directly adding the environment simulation requirement information to the implementation code of each project, thereby being beneficial to reducing the resource pressure caused by environment simulation.

[0064] Furthermore, in order to better reduce the resource pressure, the present application also provides a possible implementation manner of the above-mentioned S2. In this implementation manner, when the compressed file of the environment configuration information of the above-mentioned development environment is stored in the cloud in advance, S2 may specifically be: first obtaining the compressed file of the above-mentioned environment simulation requirement information from the stored data in the cloud; then decompressing the compressed file to obtain the environment simulation requirement information, which is not only beneficial to reducing the storage pressure in the cloud, but also beneficial to reducing the communication pressure when obtaining data from the remote end, thereby being beneficial to improving the efficiency.

[0065] Based on the relevant content in S2 above, for the target plugin called during the integration phase, after the target plugin receives a code detection request, the target plugin can obtain environment simulation requirement information from the cloud, so that the environment simulation requirement information includes part of the environment configuration information of the above-mentioned development environment, such as the part for implementing the plugin running function, etc., so that the environment simulation requirement information can represent the information required for creating a simulation environment of the development environment during the integration phase, and further enable the subsequent simulation environment created based on the environment simulation requirement information to replicate some functions of the development environment, such as the plugin running function, etc., and further enable some plugins configured for the development environment to be reused in the subsequent simulation environment.

[0066] S3: Create a simulation environment according to the environment simulation requirement information; the plugin running function of the simulation environment is consistent with the plugin running function of the development environment; the simulation environment is used to perform code detection processing according to the code description information and at least one plugin in the development environment; the at least one plugin is determined according to the detection description information.

[0067] Among them, the simulation environment refers to an environment created during the integration phase that can simulate some functions of the development environment used in the development phase, such as Figure 4 the shown simulation environment.

[0068] In addition, the present application does not limit the implementation manner of the simulation environment. For example, as Figure 4 shown, when the development environment used in the development phase includes a platform layer, a general plugin layer, and a custom layer, if the simulation environment is used to simulate some functions of the development environment, the simulation environment has the following characteristics: ① The architecture of the simulation environment is the same as the architecture of the development environment, that is, the simulation environment also includes a platform layer, a general plugin layer, and a custom layer; ② The platform layer in the simulation environment is the same as the platform layer in the development environment, that is, the entire platform layer in the development environment is retained in the simulation environment; ③ The general plugin layer in the simulation environment includes some or all of the plugins in the general plugin layer in the development environment, that is, some plugins existing in the general plugin layer in the development environment and used to participate in code detection processing are retained in the simulation environment, such as Kotlin Plugin, Java Plugin, etc.; ④ The custom layer in the simulation environment includes some or all of the plugins in the custom plugin layer in the development environment, that is, some plugins existing in the custom plugin layer in the development environment and used to participate in code detection processing are retained in the simulation environment, such as the custom plugins corresponding to each detection rule in the above plugin constraints.

[0069] It can be seen that in a possible implementation, the plugin running function of the above-mentioned simulation environment is consistent with the plugin running function of the above-mentioned development environment, so that the simulation environment completely replicates the plugin running function of the development environment, enabling some plugins in the development environment to run properly in the simulation environment. Furthermore, the simulation environment can perform code detection processing with the help of some plugins in the development environment. In this way, code detection processing can be achieved by reusing some plugins in the development environment during the integration phase, which helps reduce the cost of code detection.

[0070] In addition, for the above-mentioned simulation environment, the simulation environment can be used to perform code detection processing based on the above-mentioned code description information and at least one plugin in the above-mentioned development environment. Among them, the at least one plugin is determined according to the detection description information, so that the at least one plugin can represent the plugins required for code detection processing during the integration phase. Moreover, this application does not limit the at least one plugin. For example, it can include a syntax tree construction plugin (Intellij Core Plugin), a first programming language plugin (Kotlin Plugin), a second programming language plugin (Java Plugin), and custom plugins corresponding to some detection rules, etc. It can be seen that in a possible implementation, when the detection description information includes plugin constraints, the at least one plugin is determined according to the plugin constraints, so that the at least one plugin includes the plugins in the development environment that meet the plugin constraints, such as the plugins corresponding to each detection rule in the plugin constraints.

[0071] Furthermore, in order to better improve the flexibility of code detection, code detection processing can be performed on some or all of the above-mentioned code to be detected based on user requirements. Based on this, this application also provides a possible implementation of the above-mentioned simulation environment. In this implementation, when the above-mentioned detection description information includes code constraints, the simulation environment can specifically be used to perform code detection processing on the part of the code to be detected that meets the code constraints. In this way, local or global detection processing of the code to be detected can be achieved, thus better meeting the user's code detection scope requirements. It can be seen that relevant personnel can customize the code detection scope by configuring the code constraints. In this way, not only can full-range detection processing of the code to be detected be achieved, but also detection processing can be performed on some parts of the code to be detected, such as a certain code module, which helps improve the flexibility of code detection.

[0072] Moreover, this application does not limit the implementation manner of using the above-mentioned simulation environment for code detection processing. For example, in a possible implementation, the running logic of the simulation environment can at least include the following steps 11 - step 14.

[0073] Step 11: Register at least one of the above plugins.

[0074] In this application, for the above simulation environment, when the simulation environment includes a plugin registration environment (CoreEnvironment), the simulation environment has a plugin registration function. Therefore, at least one of the above plugins in the development environment can be registered in the simulation environment so that these plugins can be used normally in the simulation environment, so that these plugins can be used for code detection processing in the integration stage in the simulation environment later.

[0075] It should be noted that for the above plugin registration process, this process not only needs to register some plugins in the general plugin layer of the development environment, such as Kotlin Plugin and Java Plugin, but also needs to register the custom plugins corresponding to each detection rule in the above plugin constraints.

[0076] Step 12: Deploy the code to be detected according to the above code description information.

[0077] It should be noted that this application does not limit the implementation manner of the above Step 12. For example, it can be implemented by using any existing or future method that can perform code deployment processing in a certain environment.

[0078] For another example, in order to better improve the deployment effect, when the above code to be detected includes at least two code modules, the above Step 12 can specifically include the following Steps 121 - 122.

[0079] Step 121: Create a file object corresponding to the code to be detected according to the above code description information.

[0080] In this application, for the above simulation environment, a file object corresponding to the code to be detected can be created in the simulation environment according to the above code description information, such as creating a file system (File System) and a file index (FileIndex), so as to abstract the architecture of the code to be detected in the simulation environment.

[0081] It should be noted that this application does not limit the implementation manner of the above Step 121. For example, specifically, it can be: according to the above code description information, obtain the relevant information of the above code to be detected, and create interfaces corresponding to these information, etc.

[0082] Step 122: Create module objects corresponding to each code module, and configure the module objects corresponding to the at least two code modules according to the module association relationship between the above at least two code modules.

[0083] Among them, the module association relationship is used to describe the data dependency relationship between different modules in the to-be-detected code above.

[0084] It can be seen that for the simulation environment above, since the concept of module Module does not exist in this simulation environment, in order to better improve the deployment effect, module objects corresponding to each code module in the to-be-detected code above can be created, and these module objects corresponding to the code modules can be configured according to the module association relationship between these code modules, so that the module characteristics in the to-be-detected code can be better represented in this simulation environment, thereby enabling the to-be-detected code to be better abstracted in this simulation environment. Among them, for any code module, the module object corresponding to this code module refers to the object created in this simulation environment and used to represent this code module.

[0085] Based on the relevant content of steps 121 to 122 above, for the simulation environment above, first, according to the code description information above, create the corresponding File System and File Index of the to-be-detected code in this simulation environment; then create module objects corresponding to each code module of the to-be-detected code in this simulation environment, and configure these module objects according to the relevant information of these code modules, so as to be able to better deploy the to-be-detected code in this simulation environment.

[0086] Step 13: Perform configuration initialization processing on some or all of the above at least one plug-in.

[0087] It should be noted that this application does not limit the implementation manner of the configuration initialization processing in step 13 above. For example, for some custom plug-ins, these custom plug-ins need to first perform configuration initialization processing according to the relevant information of the to-be-detected code above, such as module information. Therefore, this application can implement the configuration initialization processing for these plug-ins by reusing the function method of StartUpActivity in the development environment.

[0088] Step 14: Run the above at least one plug-in, and the at least one plug-in is used to implement code detection processing.

[0089] In this application, for the simulation environment above, this simulation environment can implement the built-in code detection logic of the development environment by reusing some plug-ins in the development environment, so as to complete the detection processing of some or all of the to-be-detected code above based on this code detection logic in this simulation environment.

[0090] Based on the relevant content of steps 11 to 14 above, for the target plug-in called in the integration stage, this target plug-in can create and use a simulation environment so that this simulation environment can Figure 5The logic shown above completes the detection process for some or all of the code to be detected in the above text, so that the code detection task in the integration stage can be completed by reusing some plugins in the development environment during the development stage, which helps to reduce the code detection cost.

[0091] Based on the relevant content of the above simulation environment, in a possible implementation manner, when the code to be detected above includes at least two code modules, the simulation environment can be specifically used to perform code detection processing based on the above code description information, the module association relationship between the at least two code modules, and at least one plugin in the above development environment, so that the simulation environment can not only perform detection processing on each code module, but also perform detection processing on the data dependency relationship between different modules, which helps to improve the comprehensiveness of detection and thus helps to improve the detection effect. It should be noted that the present application does not limit the acquisition method of the module association relationship. For example, the module association relationship can be read by the simulation environment based on the code description information.

[0092] Based on the relevant content of S1 to S3 above, for the code detection method provided in the embodiments of the present application, first, a code detection request is received. The code detection request carries code description information and detection description information. The code description information is used to describe the code to be detected, and some or all of the code to be detected is written using the development environment; the detection description information is used to describe the detection constraints of the code to be detected; then, environment simulation requirement information is obtained, and the environment simulation requirement information is determined based on the environment configuration information of the development environment, so that the environment simulation requirement information can describe the information required for simulating the development environment in the integration stage; finally, based on the environment simulation requirement information, a simulation environment is created. The plugin running function of the simulation environment is consistent with the plugin running function of the development environment. The simulation environment is used to perform code detection processing based on the code description information and at least one plugin in the development environment; the at least one plugin is determined based on the detection description information. Among them, since the plugin running function of the simulation environment is consistent with the plugin running function of the development environment, some plugins in the development environment can run normally in the simulation environment, so that the simulation environment can perform code detection processing with the help of at least one plugin in the development environment. In this way, code detection processing can be realized by reusing some plugins in the development stage in the integration stage, so that code detection processing can be realized using the same set of plugins in different stages, and further, the cost caused by separately configuring different code detection processing implementation plugins for different stages can be effectively overcome, so that the code detection cost can be effectively reduced.

[0093] In addition, to better improve efficiency, the simulation environment can directly reuse the module association relationships already obtained by the target plugin. Based on this, the present application also provides a possible implementation of the above-mentioned code detection method. In this implementation, the code detection method may include the following steps 21-step 25.

[0094] Step 21: The target plugin receives a code detection request, which carries code description information and detection description information. The code description information is used to describe the code to be detected, and part or all of the code to be detected is written using a development environment. The code to be detected includes at least two code modules; the detection description information is used to describe the detection constraints of the code to be detected.

[0095] It should be noted that for the relevant content of step 21, please refer to S1 above.

[0096] Step 22: The target plugin configures according to the above-mentioned code description information to obtain a configuration result, which includes the module association relationships between at least two code modules in the above-mentioned code to be detected.

[0097] Among them, the configuration result refers to the information collected when the target plugin is configured according to the code to be detected, such as the module association relationships between at least two code modules in the code to be detected, etc.

[0098] In addition, the present application does not limit the implementation manner of the above-mentioned step 22. For example, it can be implemented using any existing or future method that can configure a certain plugin according to a certain code.

[0099] Based on the relevant content of the above-mentioned step 22, for the target plugin called during the integration stage, after the target plugin receives the code detection request, the target plugin can configure the target plugin according to the code description information carried by the code detection request, so that the configured target plugin can better process the code to be detected described by the code description information; and the present application does not limit this configuration process. For example, specifically, it can be: first obtain the relevant information of the code to be detected according to the code description information, such as the above-mentioned module association relationships, etc., and then build an abstraction of the code to be detected in the target plugin based on this information, so that the target plugin can perform corresponding processing on the code to be detected, so as to achieve the engineering configuration processing of the target plugin according to the code to be detected, such as Figure 6 the engineering configuration processing shown.

[0100] Step 23: The target plugin obtains environment simulation requirement information, which is determined according to the environment configuration information of the development environment.

[0101] It should be noted that for the relevant content of step 23, please refer to S2 above.

[0102] Step 24: The target plugin creates a simulation environment according to the environment simulation requirement information; the plugin running function of this simulation environment is consistent with the plugin running function of the development environment.

[0103] In this application, for the target plugin called in the integration stage, after the target plugin obtains the environment simulation requirement information, it can create a simulation environment based on this environment simulation requirement information, so that the plugin running function of this simulation environment is consistent with the plugin running function of the above-mentioned development environment, so that some plugins in this development environment can run normally in this simulation environment, and then this simulation environment can perform code detection processing with the help of at least one plugin in this development environment.

[0104] Step 25: The target plugin sends the above-mentioned code description information, the above-mentioned detection description information, and the module association relationship between the above-mentioned at least two code modules to the simulation environment; this simulation environment is specifically used to perform code detection processing according to this code description information, this module association relationship, and at least one plugin in the above-mentioned development environment; the at least one plugin is determined according to this detection description information.

[0105] In this application, for the target plugin called in the integration stage, after the target plugin creates the simulation environment, the target plugin can send the obtained code description information, detection description information, and the above-mentioned module association relationship to this simulation environment, so that this simulation environment can complete code detection processing based on these, so as to effectively overcome the time overhead caused when the simulation environment itself obtains this module association relationship, thus being beneficial to improving the detection efficiency.

[0106] Based on the relevant content of the above steps 21 to 25, in some application scenarios, for the target plugin called in the integration stage, the target plugin not only needs to send the code description information and the detection description information to the simulation environment, but also needs to send the above-mentioned module association relationship collected in its configuration process to the simulation environment, so that this simulation environment can directly perform code detection processing based on these information, so as to effectively overcome the time overhead caused when the simulation environment itself obtains this module association relationship, thus being beneficial to improving the detection efficiency.

[0107] Based on the code detection method provided by the embodiments of this application, the embodiments of this application also provide a code detection device, which will be combined with Figure 7 for explanation and illustration. Among them, Figure 7Schematic structural diagram of a code detection device provided by an embodiment of this application. It should be noted that for the technical details of the code detection device provided by the embodiment of this application, please refer to the relevant content of the above code detection method.

[0108] As Figure 7 shown, the code detection device 700 provided by the embodiment of this application includes:

[0109] A receiving unit 701, configured to receive a code detection request, where the code detection request carries code description information and detection description information, the code description information is used to describe the code to be detected, and part or all of the code to be detected is written using a development environment; the detection description information is used to describe the detection constraints of the code to be detected;

[0110] An obtaining unit 702, configured to obtain environment simulation requirement information, where the environment simulation requirement information is determined according to the environment configuration information of the development environment;

[0111] A creating unit 703, configured to create a simulation environment according to the environment simulation requirement information; the plug-in running function of the simulation environment is consistent with the plug-in running function of the development environment; the simulation environment is used to perform code detection processing according to the code description information and at least one plug-in in the development environment; the at least one plug-in is determined according to the detection description information.

[0112] In a possible implementation manner, the detection description information includes plug-in constraints; the at least one plug-in is determined according to the plug-in constraints.

[0113] In a possible implementation manner, the detection description information includes code constraints; the simulation environment is used to perform code detection processing on the part of the code to be detected that meets the code constraints.

[0114] In a possible implementation manner, the simulation environment is specifically configured to: register the at least one plug-in; deploy the code to be detected according to the code description information; perform configuration initialization processing on part or all of the at least one plug-in; run the at least one plug-in, and the at least one plug-in is used to implement the code detection processing.

[0115] In a possible implementation manner, the code to be detected includes at least two code modules; the deployment process of the code to be detected includes: creating a file object corresponding to the code to be detected according to the code description information; creating module objects corresponding to the at least two code modules, and configuring the module objects corresponding to the at least two code modules according to the module association relationship between the at least two code modules.

[0116] In a possible implementation, the code to be detected includes at least two code modules;

[0117] The code detection device 700 further includes:

[0118] A configuration unit, configured to perform configuration according to the code description information after receiving a code detection request, and obtain a configuration result, where the configuration result includes the module association relationship between the at least two code modules;

[0119] A sending unit, configured to send the code description information, the detection description information, and the module association relationship to the simulation environment after creating the simulation environment; the simulation environment is specifically configured to perform code detection processing according to the code description information, the module association relationship, and at least one plugin in the development environment.

[0120] In a possible implementation, the code detection method is applied to a target plugin called in the integration stage.

[0121] Based on the relevant content of the above code detection device 700, for the code detection device 700 provided in the embodiments of the present application, when some or all of the code to be detected is written using the development environment in the development stage, the code detection device 700 is used to implement the code detection process of the code to be detected in the integration stage, and the working principle of the code detection device 700 is as follows: first, obtain environment simulation requirement information, and the environment simulation requirement information is determined according to the environment configuration information of the development environment used in the development stage, so that the environment simulation requirement information can describe the information required to simulate the development environment in the integration stage; then, create a simulation environment according to the environment simulation requirement information, so that the plugin running function of the simulation environment is consistent with the plugin running function of the development environment, so that some plugins in the development environment can run normally in the simulation environment, and then the simulation environment can perform code detection processing with the help of at least one plugin in the development environment. In this way, code detection processing can be realized by reusing some plugins in the development stage in the integration stage, so that code detection processing can be realized by using the same set of plugins in different stages, and further, the cost caused by separately configuring different code detection processing implementation plugins for different stages can be effectively overcome, so that the code detection cost can be effectively reduced.

[0122] In addition, an embodiment of the present application further provides an electronic device, where the device includes a processor and a memory: the memory is used to store instructions or computer programs; the processor is used to execute the instructions or computer programs in the memory, so that the electronic device executes any implementation manner of the code detection method provided in the embodiments of the present application.

[0123] See Figure 8 , which shows a schematic structural diagram of an electronic device 800 suitable for implementing the embodiments of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are 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), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The electronic device shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present disclosure.

[0124] As Figure 8 shown, the electronic device 800 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 801, which may perform various appropriate actions and processes according to the programs stored in the read-only memory (ROM) 802 or the programs loaded from the storage device 808 into the random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. The input / output (I / O) interface 805 is also connected to the bus 804.

[0125] Generally, the following devices may be connected to the I / O interface 805: an input device 806 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 808 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 809. The communication device 809 may allow the electronic device 800 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 8 shows the electronic device 800 having various devices, it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices may be implemented or had.

[0126] In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from the network through the communication device 809, or installed from the storage device 808, or installed from the ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are executed.

[0127] The electronic device provided by the embodiments of the present disclosure and the method provided by the above embodiments belong to the same inventive concept. For technical details not described in detail in this embodiment, reference may be made to the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.

[0128] An embodiment of the present application also provides a computer-readable medium, in which instructions or computer programs are stored. When the instructions or computer programs run on a device, the device is caused to execute any implementation manner of the code detection method provided by the embodiments of the present application.

[0129] It should be noted that the computer-readable medium of the present disclosure described above may be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which computer-readable program code is carried. Such a propagated data signal may take various 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, and the computer-readable signal medium may send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0130] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as HTTP (Hyper Text Transfer Protocol), and can be interconnected with digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include local area networks ("LANs"), wide area networks ("WANs"), 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 future-developed networks.

[0131] The above computer-readable medium can be included in the above electronic device; or can exist separately without being assembled into the electronic device.

[0132] The above computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device can execute the above method.

[0133] Computer program code for performing the operations of the present disclosure can be written in one or more programming languages or combinations thereof. The programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., by using an Internet service provider to connect through the Internet).

[0134] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations 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, a segment of a program, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks may occur in a different order than that noted in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0135] The units involved in the embodiments described in the present disclosure can be implemented in software or in hardware. Among them, the name of the unit / module does not, in some cases, constitute a limitation on the unit itself.

[0136] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: Field Programmable Gate Arrays (FPGA), Application Specific Integrated Circuits (ASIC), Application Specific Standard Products (ASSP), System on a Chip (SOC), Complex Programmable Logic Devices (CPLD), and so on.

[0137] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable Programmable Read-Only Memory (EPROM or Flash Memory), an optical fiber, a portable Compact Disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0138] It should be noted that the embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other. For the systems or devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple. For the relevant parts, reference can be made to the description in the method section.

[0139] It should be understood that in this application, "at least one (item)" means one or more, and "a plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist. For example, "A and / or B" can mean: only A exists, only B exists, and both A and B exist at the same time. Among them, A and B can be singular or plural. The character " / " generally means that the associated objects before and after are in an "or" relationship. "At least one (one) of the following" or similar expressions refer to any combination of these items, including any combination of single item (one) or plural items (ones). For example, at least one (one) of a, b, or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0140] It should also be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the said element.

[0141] The steps of the methods or algorithms described in connection with the embodiments disclosed in this article can be implemented directly by hardware, software modules executed by a processor, or a combination of both. The software module can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.

[0142] The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A code detection method, characterized in that, The method includes: Receiving a code detection request, where the code detection request carries code description information and detection description information. The code description information is used to describe the code to be detected, and part or all of the code to be detected is written using a development environment; the detection description information is used to describe the detection constraints of the code to be detected. Obtaining environment simulation requirement information, where the environment simulation requirement information is determined based on the environment configuration information of the development environment. Creating a simulation environment according to the environment simulation requirement information; the plug-in running function of the simulation environment is consistent with that of the development environment; the simulation environment is used to perform code detection processing based on the code description information and at least one plug-in in the development environment; the at least one plug-in is determined according to the detection description information.

2. The method according to claim 1, wherein The detection description information includes plug-in constraints. The at least one plug-in is determined according to the plug-in constraints.

3. The method according to claim 1, characterized in that, The detection description information includes code constraints. The simulation environment is used to perform code detection processing on the part of the code to be detected that meets the code constraints.

4. The method according to claim 1, wherein Specifically, the simulation environment is used for: Registering the at least one plug-in. Deploying the code to be detected according to the code description information. Performing configuration initialization processing on part or all of the at least one plug-in. Running the at least one plug-in, where the at least one plug-in is used to implement the code detection processing.

5. The method according to claim 4, wherein The code to be detected includes at least two code modules. The deploying the code to be detected according to the code description information includes: Creating a file object corresponding to the code to be detected according to the code description information. Creating module objects corresponding to the at least two code modules, and configuring the module objects corresponding to the at least two code modules according to the module association relationship between the at least two code modules.

6. The method according to claim 1, wherein The code to be detected includes at least two code modules. After receiving the code detection request, the method further includes: Performing configuration according to the code description information to obtain a configuration result, where the configuration result includes the module association relationship between the at least two code modules. After creating the simulation environment, the method further includes: Sending the code description information, the detection description information, and the module association relationship to the simulation environment; specifically, the simulation environment is used to perform code detection processing based on the code description information, the module association relationship, and at least one plug-in in the development environment.

7. The method according to claim 1, wherein The code detection method is applied to a target plug-in called during the integration phase.

8. A code detection device, characterized in that, It includes: A receiving unit, configured to receive a code detection request, where the code detection request carries code description information and detection description information. The code description information is used to describe the code to be detected, and part or all of the code to be detected is written using a development environment; the detection description information is used to describe the detection constraints of the code to be detected. An obtaining unit, configured to obtain environment simulation requirement information, where the environment simulation requirement information is determined based on the environment configuration information of the development environment. Creation unit, configured to create a simulation environment according to the environment simulation requirement information; the plug-in running function of the simulation environment is consistent with that of the development environment; the simulation environment is used to perform code detection processing according to the code description information and at least one plug-in in the development environment; The at least one plug-in is determined according to the detection description information.

9. An electronic device, characterized in that, The device includes: a processor and a memory; The memory is configured to store instructions or computer programs; The processor is configured to execute the instructions or computer programs in the memory, so that the electronic device executes the method according to any one of claims 1-7.

10. A computer-readable medium, characterized in that, Instructions or computer programs are stored in the computer-readable medium, and when the instructions or computer programs run on the device, the device executes the method according to any one of claims 1-7.

11. A computer program product, characterized in that, It includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program codes for executing the method according to any one of claims 1-7.