Code scanning processing method and device, electronic equipment and storage medium
By selecting the appropriate scanning strategy based on the code type and scanning the code comprehensively and accurately, it solves the problem that traditional code scanning technology cannot fully cover the code, and improves scanning efficiency and accuracy.
Patent Information
- Application Number
- CN202510191157.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-05-30
AI Technical Summary
Traditional code scanning technology relies on fixed static rules, cannot fully cover all potential problems in the code, and cannot personalize scanning according to the characteristics of a specific code base, resulting in the inability to accurately reflect the quality and security issues of the code.
By obtaining the code file to be scanned and determining its code type, the matching code scanning strategy is called for scanning processing. Specifically, a scanning strategy combining network model and static rules is selected based on the code type, or a scan is only performed using static rules.
It realizes the ability to comprehensively and accurately reflect code quality and security issues without reducing scanning efficiency, improves the accuracy and efficiency of code scanning, and provides a solid foundation for software development and maintenance.
Smart Images

Figure CN120066932A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to a code scanning and processing method, apparatus, electronic device, and storage medium. Background Art
[0002] During the process of software development and maintenance, code scanning, as an important quality assurance means, is widely used to identify potential security vulnerabilities, coding standard violations, and other problems that may affect software stability and reliability.
[0003] Traditional code scanning techniques mainly rely on fixed static rules. This traditional code scanning method based on fixed static rules has obvious limitations. Since the rules are preset, the scanning results are often limited by these rules, resulting in the possibility that the scanning results may not comprehensively cover all potential problems in the code and cannot perform corresponding scanning according to the characteristics of a specific code library, thus unable to reflect the quality and security problems of each unique code in a personalized and accurate manner.
[0004] Therefore, finding a code scanning and processing method that can comprehensively and accurately reflect the quality and security problems of each code has become a current research hotspot. Summary of the Invention
[0005] The present invention provides a code scanning and processing method, apparatus, electronic device, and storage medium, which can improve the code scanning efficiency on the premise of comprehensively and accurately reflecting the quality and security problems of each code, and lay a foundation for efficient software development and maintenance in the future.
[0006] The present invention provides a code scanning and processing method, the method includes: obtaining a code file to be scanned, and determining the code type of the code file to be scanned; based on the code type of the code file to be scanned, invoking a code scanning strategy matching the code type to perform scanning processing on the code file to be scanned, and obtaining a scanning result of the code file to be scanned.
[0007] A code scanning and processing method provided by the present invention, wherein the code type includes a first code type; the code scanning strategy includes a first code scanning strategy; determining the code type of the code file to be scanned is implemented in the following manner: when the code file to be scanned is for implementing an operation business logic function, determining that the code type of the code file to be scanned is the first code type; based on the code type of the code file to be scanned, invoking a code scanning strategy matching the code type to perform a scanning process on the code file to be scanned to obtain a scanning result of the code file to be scanned, specifically including: based on the first code type of the code file to be scanned, invoking the first code scanning strategy matching the first code type to perform a scanning process on the code file to be scanned to obtain a scanning result of the code file to be scanned, wherein the first code scanning strategy is a scanning strategy for performing a scanning process on the code file to be scanned based on a network model and based on static rules respectively.
[0008] A code scanning and processing method provided by the present invention, wherein invoking the first code scanning strategy matching the first code type to perform a scanning process on the code file to be scanned to obtain a scanning result of the code file to be scanned specifically includes: invoking the network model, and inputting the code file to be scanned into the network model to obtain a first scanning result corresponding to the code file to be scanned output by the network model, wherein the network model is a network model pre-trained; and based on the static rules, performing a scanning process on the code file to be scanned to obtain a second scanning result of the code file to be scanned; based on the first scanning result and the second scanning result, obtaining a scanning result of the code file to be scanned.
[0009] A code scanning and processing method provided by the present invention, before inputting the code file to be scanned into the network model to obtain a first scanning result corresponding to the code file to be scanned output by the network model, the method further includes: performing a context code information supplementation process on the code file to be scanned to obtain a processed code file to be scanned; inputting the code file to be scanned into the network model to obtain a first scanning result corresponding to the code file to be scanned output by the network model specifically includes: inputting the processed code file to be scanned into the network model to obtain a first scanning result corresponding to the code file to be scanned output by the network model.
[0010] A code scanning and processing method provided by the present invention, wherein the context code information of the code file to be scanned is supplemented and processed to obtain the processed code file to be scanned, which specifically includes: based on the code file to be scanned, a context code file is extracted from the context of the target code file library, wherein the context code file is a code file having a reference relationship with the code file to be scanned, and the target code file library is a code file library containing the code file to be scanned; based on the context code file, the context code information of the code file to be scanned is supplemented and processed to obtain the processed code file to be scanned.
[0011] A code scanning and processing method provided by the present invention, wherein the code type includes a second code type; the code scanning strategy includes a second code scanning strategy; determining the code type of the code file to be scanned is implemented in the following manner: when the code file to be scanned is used to describe an object and / or define an object, determining that the code type of the code file to be scanned is the second code type; based on the code type of the code file to be scanned, a code scanning strategy matching the code type is called to scan the code file to be scanned to obtain the scanning result of the code file to be scanned, which specifically includes: based on the second code type of the code file to be scanned, the second code scanning strategy matching the second code type is called to scan the code file to be scanned to obtain the scanning result of the code file to be scanned, wherein the second code scanning strategy is a scanning strategy for scanning the code file to be scanned based on static rules.
[0012] A code scanning and processing method provided by the present invention, wherein calling the second code scanning strategy matching the second code type to scan the code file to be scanned to obtain the scanning result of the code file to be scanned specifically includes: calling the static rules and, based on the static rules, scanning the code file to be scanned to obtain the scanning result of the code file to be scanned.
[0013] A code scanning and processing method provided by the present invention, after obtaining the scanning result of the code file to be scanned, the method further includes: performing a display process on the scanning result.
[0014] The present invention also provides a code scanning and processing device, which includes: an acquisition module for acquiring a code file to be scanned and determining the code type of the code file to be scanned; a processing module for, based on the code type of the code file to be scanned, calling a code scanning strategy matching the code type to scan the code file to be scanned to obtain the scanning result of the code file to be scanned.
[0015] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the code scanning processing method described in any one of the above is implemented.
[0016] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the code scanning processing method described in any one of the above is implemented.
[0017] The present invention also provides a computer program product, including a computer program. When the computer program is executed by a processor, the code scanning processing method described in any one of the above is implemented.
[0018] The code scanning processing method, device, electronic device, and storage medium provided by the present invention obtain a code file to be scanned and determine the code type of the code file to be scanned; based on the code type of the code file to be scanned, a code scanning strategy matching the code type is retrieved to perform scanning processing on the code file to be scanned, and a scanning result of the code file to be scanned is obtained. It can be realized that a corresponding code scanning strategy is retrieved according to the code characteristics or type of the code file to be scanned to perform scanning processing on the code file to be scanned, which can improve the code scanning efficiency on the premise of comprehensively and accurately reflecting the quality and security problems of each code, and lay a foundation for efficient software development and maintenance in the future. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0020] Figure 1 It is a flowchart of the code scanning processing method provided by the present invention.
[0021] Figure 2 It is one of the flowcharts of retrieving a code scanning strategy matching the code type of the code file to be scanned to perform scanning processing on the code file to be scanned and obtaining a scanning result of the code file to be scanned provided by the present invention.
[0022] Figure 3 It is a flowchart of retrieving the first code scanning strategy matching the first code type to perform scanning processing on the code file to be scanned and obtaining a scanning result of the code file to be scanned provided by the present invention.
[0023] Figure 4 It is the second schematic flow chart of the process of obtaining a code scanning strategy matching the code type based on the code type of the code file to be scanned, and performing a scanning process on the code file to be scanned to obtain a scanning result of the code file to be scanned provided by the present invention.
[0024] Figure 5 It is a schematic structural diagram of a code scanning processing device provided by the present invention.
[0025] Figure 6 It is a schematic structural diagram of an electronic device provided by the present invention. Detailed implementation manners
[0026] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below with reference to the accompanying drawings in the present invention. Apparently, the described embodiments are some but not all of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art without making creative efforts based on the embodiments in the present invention belong to the scope of protection of the present invention.
[0027] Figure 1 It is a schematic flow chart of a code scanning processing method provided by the present invention.
[0028] The following will be combined with Figure 1 to illustrate the process of the code scanning processing method provided by the present invention.
[0029] In an exemplary embodiment of the present invention, in combination with Figure 1 it can be seen that the code scanning processing method may include steps 110 to 120, and each step will be introduced separately below.
[0030] In step 110, obtain a code file to be scanned and determine the code type of the code file to be scanned.
[0031] In step 120, based on the code type of the code file to be scanned, retrieve a code scanning strategy matching the code type and perform a scanning process on the code file to be scanned to obtain a scanning result of the code file to be scanned.
[0032] In one embodiment, a code file to be scanned can be obtained. Among them, the code file to be scanned can be a part of the code files in an entire target code file library. It can be understood that this part of the code files can have a reference relationship with the context code files. During application, the code type of the code file to be scanned can be determined. Among them, the code type can at least include a first code type and a second code type. The first code type and the second code type will be introduced separately below and will not be elaborated in this embodiment.
[0033] In another embodiment, the code scanning policy matching the code type can be retrieved according to the code type of the code file to be scanned, and the code file to be scanned is scanned to obtain the scanning result of the code file to be scanned. In this embodiment, the corresponding code scanning policy is retrieved according to the code characteristics or type of the code file to be scanned to scan the code file to be scanned. Therefore, considering the code to be scanned in a personalized way, it can comprehensively and accurately reflect the quality and security issues of each piece of code, and can also improve the code scanning efficiency, laying a foundation for efficient software development and maintenance in the future.
[0034] Figure 2 It is one of the schematic flowcharts of retrieving the code scanning policy matching the code type based on the code type of the code file to be scanned, scanning the code file to be scanned, and obtaining the scanning result of the code file to be scanned provided by the present invention.
[0035] Next, in conjunction with Figure 2 the process of retrieving the code scanning policy matching the code type based on the code type of the code file to be scanned, scanning the code file to be scanned, and obtaining the scanning result of the code file to be scanned will be described.
[0036] In an exemplary embodiment of the present invention, the code type may include a first code type; the code scanning policy may include a first code scanning policy; in conjunction with Figure 2 it can be seen that retrieving the code scanning policy matching the code type based on the code type of the code file to be scanned, scanning the code file to be scanned, and obtaining the scanning result of the code file to be scanned may include step 210 and step 220. Each step will be introduced separately below.
[0037] In step 210, when the code file to be scanned is for implementing the operation business logic function, it is determined that the code type of the code file to be scanned is the first code type.
[0038] In step 220, based on the first code type of the code file to be scanned, the first code scanning policy matching the first code type is retrieved to scan the code file to be scanned, and the scanning result of the code file to be scanned is obtained. The first code scanning policy is a scanning policy for scanning the code file to be scanned based on the network model and based on static rules respectively.
[0039] In one embodiment, when it is determined that the code file to be scanned is for implementing the operation business logic function, it indicates that the content that needs to be scanned in the code file to be scanned is not limited to code bugs, but also needs to be scanned comprehensively from multiple aspects. Therefore, it can be determined that the code type of the code file to be scanned is the first code type.
[0040] Further, when the code type of the code file to be scanned is the first code type, based on the first code type of the code file to be scanned, a first code scanning strategy matching the first code type can be invoked to perform a scanning process on the code file to be scanned, and a scanning result of the code file to be scanned is obtained, where the first code scanning strategy is a scanning strategy for performing a scanning process on the code file to be scanned based on a network model and based on static rules respectively.
[0041] In another embodiment, the code file to be scanned can be scanned according to the first code scanning strategy, so that a scanning result of the code file to be scanned can be obtained. The scanning result includes, in addition to the scanned code bugs, code optimization suggestions, etc. In this embodiment, according to the code type of the code file to be scanned, a code scanning strategy matching the code type of the code file to be scanned can be specifically invoked for scanning, which can improve the code scanning efficiency on the premise of comprehensively and accurately reflecting the quality and security issues of each code, and lay a foundation for efficient software development and maintenance in the future.
[0042] Figure 3 It is a schematic flow chart of invoking the first code scanning strategy matching the first code type to perform a scanning process on the code file to be scanned and obtaining the scanning result of the code file to be scanned provided by the present invention.
[0043] The following will be combined with Figure 3 to describe the process of invoking the first code scanning strategy matching the first code type to perform a scanning process on the code file to be scanned and obtaining the scanning result of the code file to be scanned.
[0044] In an exemplary embodiment of the present invention, combined with Figure 3 it can be known that the process of invoking the first code scanning strategy matching the first code type to perform a scanning process on the code file to be scanned and obtaining the scanning result of the code file to be scanned may include steps 310 to 330, and each step will be introduced separately below.
[0045] In step 310, a network model is invoked, and the code file to be scanned is input into the network model, and a first scanning result corresponding to the code file to be scanned output by the network model is obtained.
[0046] In one embodiment, a network model can be retrieved, and the code file to be scanned is input into the network model, so that a first scan result corresponding to the code file to be scanned output by the network model can be obtained. Among them, the network model can be a pre-trained network model. In one example, the network model can be a GPT-4 model or other large language models. In this embodiment, no specific limitation is imposed on the network model.
[0047] In step 520, based on static rules, the code file to be scanned is scanned to obtain a second scan result of the code file to be scanned.
[0048] In step 530, based on the first scan result and the second scan result, the scan result of the code file to be scanned is obtained.
[0049] In another embodiment, the code file to be scanned can also be scanned based on static rules, so that a second scan result of the code file to be scanned can be obtained. Further, based on the first scan result and the second scan result together, the scan result of the code file to be scanned is obtained. Since the scan result is jointly determined according to the first scan result and the second scan result, the accuracy and comprehensiveness of the scan result of the code file to be scanned can be improved.
[0050] In another embodiment, the process of implementing the retrieval of the first code scanning strategy matching the first code type to scan the code file to be scanned and obtain the scan result of the code file to be scanned can be introduced by taking the interaction between the IDE plugin and the server side as an example.
[0051] In another embodiment, the IDE plugin can be used to monitor the action of the user submitting code in the IDE, and can also communicate with the bottom webView and the right webView in the IDE to perform static rule scanning. Among them, the bottom webView is a web page displayed using webView, which can communicate bidirectionally with the plugin and can also send requests to the server to obtain the data to be displayed. It is a part of the plugin; the right webView is a web page displayed using webView, which can communicate bidirectionally with the plugin and can also send requests to the server to create tasks or request data. It is a part of the plugin. The server side is a web service that can create a code scanning task, call a large model for code analysis, and can communicate with the right webview and the bottom webview.
[0052] During the application process, when the user clicks commit or push the code, the plugin will monitor this event and send this information to the right webview. The right webView sends an HTTP request to the server side to create a task. The server side creates a code analysis task and returns the task ID (taskId). The right webView starts polling the instructions sent by the server side according to the task ID (taskId). Among them, the server side issues a local static code scanning instruction to the right webview of the IDE, and at the same time performs AI scanning on the code uploaded by the right webview. After receiving the instruction to scan the local code sent by the server side, the right webview notifies the plugin to perform code scanning. At the same time, the bottom webview polls the scanning results from the server side according to the task ID. Among them, the local IDE plugin starts to scan the code. After the scanning is completed, it sends an HTTP request to the server side to upload the results of the local scanning. The scanning of the local code depends on the sonar engine, and the sonar engine is open-source code and can be used directly. The bottom webView displays the results of the local scanning (corresponding to the second scanning result in the previous text) and the AI scanning (corresponding to the first scanning result in the previous text). When both the AI scanning and the local scanning have results, the task ends.
[0053] In another exemplary embodiment of the present invention, continuing with the example described above Figure 3 as the example for illustration, before inputting the code file to be scanned into the network model to obtain the first scanning result corresponding to the code file to be scanned output by the network model (corresponding to step 310), the code scanning processing method may further include the following steps: Perform context code information supplementation processing on the code file to be scanned to obtain the processed code file to be scanned; Among them, inputting the code file to be scanned into the network model to obtain the first scanning result corresponding to the code file to be scanned output by the network model can be implemented in the following manner: Input the processed code file to be scanned into the network model to obtain the first scanning result corresponding to the code file to be scanned output by the network model.
[0054] In one embodiment, context code information supplementation processing can be performed on the code file to be scanned to obtain the processed code file to be scanned. Since the code file to be scanned can be a part of the code files in an entire target code file library, it can be understood that this part of the code files can have a reference relationship with the context code files. During the application process, by performing context code information supplementation processing on the code file to be scanned, it can be ensured that the obtained processed code file to be scanned can include sufficient code information, thereby providing higher accuracy for code scanning of the code file to be scanned.
[0055] Further, the processed code file to be scanned can be input into the network model, so as to obtain a first scan result corresponding to the code file to be scanned output by the network model. Since the processed code file to be scanned not only includes the code file to be scanned, but also includes context code information having a reference relationship with the code file to be scanned, the accuracy of the scan result of the code file to be scanned can be improved.
[0056] In another exemplary embodiment of the present invention, continuing with the embodiment described above as an example, for the context code information supplement processing of the code file to be scanned to obtain the processed code file to be scanned, the following method can also be used: Based on the code file to be scanned, a context code file is extracted from the context of the target code file library, where the context code file is a code file having a reference relationship with the code file to be scanned, and the target code file library is a code file library containing the code file to be scanned; Based on the context code file, context code information supplement processing is performed on the code file to be scanned to obtain the processed code file to be scanned.
[0057] In one embodiment, based on the code file to be scanned, a context code file can be extracted from the context of the target code file library, where the context code file is a code file having a reference relationship with the code file to be scanned, and the target code file library is a code file library containing the code file to be scanned. Further, based on the context code file, context code information supplement processing is performed on the code file to be scanned, so as to obtain the processed code file to be scanned, thereby increasing the information richness of the code file to be scanned and laying a foundation for improving the accuracy and comprehensiveness of the first scan result corresponding to the code file to be scanned output by the network model. In another example, the combination of the code file to be scanned and the context code file can be used as the processed code file to be scanned.
[0058] Figure 4 It is the second flow diagram of the present invention for providing a code type based on the code file to be scanned, invoking a code scanning strategy matching the code type to perform scanning processing on the code file to be scanned, and obtaining a scan result of the code file to be scanned.
[0059] Next, in combination with Figure 4 Another process for providing a code type based on the code file to be scanned, invoking a code scanning strategy matching the code type to perform scanning processing on the code file to be scanned, and obtaining a scan result of the code file to be scanned will be described.
[0060] In another exemplary embodiment of the present invention, the code type may include a second code type; the code scanning strategy may include a second code scanning strategy. In combination withFigure 4 It can be seen that based on the code type of the code file to be scanned, a code scanning policy matching the code type is retrieved to perform a scanning process on the code file to be scanned, and the scanning result of the code file to be scanned can include step 410 and step 420. Each step will be introduced separately below.
[0061] In step 410, when the code file to be scanned is for describing an object and / or defining an object, the code type of the code file to be scanned is determined as the second code type.
[0062] In step 420, based on the second code type of the code file to be scanned, a second code scanning policy matching the second code type is retrieved to perform a scanning process on the code file to be scanned, and the scanning result of the code file to be scanned is obtained. Among them, the second code scanning policy is a scanning policy for performing a scanning process on the code file to be scanned based on static rules.
[0063] In one embodiment, when it is determined that the code file to be scanned is for describing an object and / or defining an object, it indicates that the content that needs to be scanned in the code file to be scanned may be a code bug. Therefore, the code type of the code file to be scanned can be determined as the second code type.
[0064] Further, when the code type of the code file to be scanned is the second code type, a second code scanning policy matching the second code type can be retrieved based on the second code type of the code file to be scanned to perform a scanning process on the code file to be scanned, and the scanning result of the code file to be scanned is obtained. Among them, the second code scanning policy is a scanning policy for performing a scanning process on the code file to be scanned based on static rules.
[0065] In another embodiment, the code file to be scanned can be scanned according to the second code scanning policy, so that the scanning result of the code file to be scanned can be obtained. In this embodiment, a code scanning policy matching the code type of the code file to be scanned can be retrieved according to the code type of the code file to be scanned, and a scanning process can be performed. On the premise of comprehensively and accurately reflecting the quality and security issues of each code, the code scanning efficiency can also be improved, laying a foundation for efficient software development and maintenance in the future.
[0066] In another exemplary embodiment of the present invention, continuing with the example described above, retrieving a second code scanning policy matching the second code type to perform a scanning process on the code file to be scanned, and obtaining the scanning result of the code file to be scanned can also be implemented in the following manner: Retrieve static rules, and based on the static rules, perform a scanning process on the code file to be scanned to obtain the scanning result of the code file to be scanned.
[0067] In one embodiment, static rules can be directly retrieved, and the code file to be scanned is scanned based on the static rules, so that the scan result of the code file to be scanned can be quickly obtained. In this embodiment, since the code file to be scanned is of the second code type, a fast static rule scanning scheme can be adopted for scanning, realizing the targeted retrieval of a code scanning strategy matching the code type of the code file to be scanned according to the code type of the code file to be scanned for scanning. On the premise of comprehensively and accurately reflecting the quality and security issues of each code, the code scanning efficiency can be improved, laying a foundation for efficient software development and maintenance in the future.
[0068] In another exemplary embodiment of the present invention, continuing with the example described above Figure 1 as an example, after obtaining the scan result of the code file to be scanned (corresponding to step 220), the code scanning processing method further includes the following steps: Perform display processing on the scan result.
[0069] In one embodiment, after obtaining the scan result of the code file to be scanned, the scan result can also be subjected to display processing, so that it is convenient for the user to directly obtain the scan result information, improving the user experience and satisfaction during use.
[0070] According to the foregoing description, the code scanning processing method provided by the present invention obtains a code file to be scanned and determines the code type of the code file to be scanned; based on the code type of the code file to be scanned, a code scanning strategy matching the code type is retrieved to scan the code file to be scanned, obtaining the scan result of the code file to be scanned. It can be realized that the corresponding code scanning strategy is retrieved according to the code characteristics or type of the code file to be scanned to scan the code file to be scanned. On the premise of comprehensively and accurately reflecting the quality and security issues of each code, the code scanning efficiency can be improved, laying a foundation for efficient software development and maintenance in the future.
[0071] The code scanning processing device provided by the present invention will be described below. The code scanning processing device described below can be correspondingly referred to the code scanning processing method described above.
[0072] Figure 5 is a schematic structural diagram of the code scanning processing device provided by the present invention.
[0073] Next, the code scanning processing device provided by the present invention will be described in conjunction with Figure 5 to illustrate the code scanning processing device provided by the present invention.
[0074] In one exemplary embodiment of the present invention, in conjunction with Figure 5It can be seen that the code scanning processing device may include an acquisition module 510 and a processing module 520. Each module will be introduced separately below.
[0075] The acquisition module 510 can be configured to acquire a code file to be scanned and determine the code type of the code file to be scanned. The processing module 520 can be configured to, based on the code type of the code file to be scanned, retrieve a code scanning policy matching the code type to perform a scanning process on the code file to be scanned, and obtain a scanning result of the code file to be scanned.
[0076] In an exemplary embodiment of the present invention, the code type includes a first code type; the code scanning policy includes a first code scanning policy. The acquisition module 510 can implement the determination of the code type of the code file to be scanned in the following manner: When the code file to be scanned is for implementing an operation business logic function, determine that the code type of the code file to be scanned is the first code type. The processing module 520 can implement the retrieval of a code scanning policy matching the code type based on the code type of the code file to be scanned to perform a scanning process on the code file to be scanned and obtain a scanning result of the code file to be scanned in the following manner: Based on the first code type of the code file to be scanned, retrieve the first code scanning policy matching the first code type to perform a scanning process on the code file to be scanned, and obtain a scanning result of the code file to be scanned, where the first code scanning policy is a scanning policy for performing a scanning process on the code file to be scanned based on a network model and based on static rules respectively.
[0077] In an exemplary embodiment of the present invention, the processing module 520 can implement the retrieval of the first code scanning policy matching the first code type to perform a scanning process on the code file to be scanned and obtain a scanning result of the code file to be scanned in the following manner: Retrieve the network model, and input the code file to be scanned into the network model to obtain a first scanning result corresponding to the code file to be scanned output by the network model, where the network model is a pre-trained network model; and Based on the static rules, perform a scanning process on the code file to be scanned to obtain a second scanning result of the code file to be scanned. Based on the first scanning result and the second scanning result, obtain a scanning result of the code file to be scanned.
[0078] In an exemplary embodiment of the present invention, the processing module 520 may further be configured to: perform context code information supplementation processing on the to-be-scanned code file to obtain a processed to-be-scanned code file; The processing module 520 may also implement inputting the to-be-scanned code file into the network model in the following manner to obtain a first scanning result corresponding to the to-be-scanned code file output by the network model: Input the processed to-be-scanned code file into the network model to obtain a first scanning result corresponding to the to-be-scanned code file output by the network model.
[0079] In an exemplary embodiment of the present invention, the processing module 520 may also implement performing context code information supplementation processing on the to-be-scanned code file to obtain a processed to-be-scanned code file in the following manner: Based on the to-be-scanned code file, context code files are extracted from the context of the target code file library, where the context code files are code files having a reference relationship with the to-be-scanned code file, and the target code file library is a code file library containing the to-be-scanned code file; Based on the context code files, perform context code information supplementation processing on the to-be-scanned code file to obtain a processed to-be-scanned code file.
[0080] In an exemplary embodiment of the present invention, the code type includes a second code type; the code scanning strategy includes a second code scanning strategy; The acquisition module 510 may implement determining the code type of the to-be-scanned code file in the following manner: When the to-be-scanned code file is for describing an object and / or defining an object, determine that the code type of the to-be-scanned code file is the second code type; The processing module 520 may also implement, based on the code type of the to-be-scanned code file, invoking a code scanning strategy matching the code type to perform scanning processing on the to-be-scanned code file to obtain a scanning result of the to-be-scanned code file in the following manner: Based on the second code type of the to-be-scanned code file, invoke the second code scanning strategy matching the second code type to perform scanning processing on the to-be-scanned code file to obtain a scanning result of the to-be-scanned code file, where the second code scanning strategy is a scanning strategy for performing scanning processing on the to-be-scanned code file based on static rules.
[0081] In an exemplary embodiment of the present invention, the processing module 520 may also implement the following method to retrieve the second code scanning policy that matches the second code type and perform a scanning process on the code file to be scanned, so as to obtain a scanning result of the code file to be scanned: Retrieve the static rules, and based on the static rules, perform a scanning process on the code file to be scanned, so as to obtain a scanning result of the code file to be scanned.
[0082] In an exemplary embodiment of the present invention, the processing module 520 may also be configured to: Perform a display process on the scanning result.
[0083] Figure 6 The following is a schematic diagram of the physical structure of an electronic device. As Figure 6 shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630, and a communication bus 640. Among them, the processor 610, the communication interface 620, and the memory 630 complete mutual communication through the communication bus 640. The processor 610 may call the logical instructions in the memory 630 to execute a code scanning processing method, and the method includes: obtaining a code file to be scanned, and determining the code type of the code file to be scanned; based on the code type of the code file to be scanned, retrieving a code scanning policy that matches the code type and performing a scanning process on the code file to be scanned, so as to obtain a scanning result of the code file to be scanned.
[0084] In addition, when the logical instructions in the above-mentioned memory 630 are implemented in the form of a software functional unit and sold or used as an independent product, they may be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk, or an optical disc that can store program codes.
[0085] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the code scanning processing method provided by each of the above methods. The method includes: obtaining a code file to be scanned and determining the code type of the code file to be scanned; based on the code type of the code file to be scanned, invoking a code scanning strategy matching the code type to perform scanning processing on the code file to be scanned, so as to obtain a scanning result of the code file to be scanned.
[0086] In another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is implemented to execute the code scanning processing method provided by each of the above methods. The method includes: obtaining a code file to be scanned and determining the code type of the code file to be scanned; based on the code type of the code file to be scanned, invoking a code scanning strategy matching the code type to perform scanning processing on the code file to be scanned, so as to obtain a scanning result of the code file to be scanned.
[0087] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without creative labor.
[0088] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, also by hardware. Based on such an understanding, the above technical solutions, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0089] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A code scanning processing method, characterized in that: The method comprises: Obtaining a code file to be scanned, and determining a code type of the code file to be scanned; Based on the code type of the code file to be scanned, a code scanning strategy matching the code type is retrieved to perform scanning processing on the code file to be scanned, so as to obtain a scanning result of the code file to be scanned.
2. The code scanning processing method according to claim 1, characterized in that: The code type includes a first code type; the code scanning strategy includes a first code scanning strategy; Determine the code type of the code file to be scanned, and implement it in the following manner: In a case where the code file to be scanned is used to implement an operation service logic function, determining that the code type of the code file to be scanned is the first code type; The step of retrieving a code scanning strategy matching the code type based on the code type of the code file to be scanned to scan the code file to be scanned, and obtaining a scanning result of the code file to be scanned specifically includes: Based on the first code type of the code file to be scanned, the first code scanning strategy matching the first code type is called to scan the code file to be scanned to obtain a scanning result of the code file to be scanned, wherein the first code scanning strategy is a scanning strategy that scans the code file to be scanned based on a network model and based on static rules respectively.
3. The code scanning processing method according to claim 2, characterized in that: The calling of the first code scanning strategy matching the first code type to scan the code file to be scanned to obtain the scanning result of the code file to be scanned specifically includes: Retrieving the network model, and inputting the code file to be scanned into the network model, to obtain a first scanning result output by the network model and corresponding to the code file to be scanned, wherein the network model is a pre-trained network model; and Based on the static rule, the code file to be scanned is scanned to obtain a second scanning result of the code file to be scanned; Based on the first scanning result and the second scanning result, a scanning result of the code file to be scanned is obtained.
4. The code scanning processing method according to claim 3, characterized in that: Before inputting the code file to be scanned into the network model to obtain a first scanning result output by the network model and corresponding to the code file to be scanned, the method further includes: Performing context code information supplementation processing on the code file to be scanned to obtain a processed code file to be scanned; The step of inputting the code file to be scanned into the network model to obtain a first scanning result output by the network model and corresponding to the code file to be scanned specifically includes: The processed code file to be scanned is input into the network model to obtain a first scanning result output by the network model and corresponding to the code file to be scanned.
5. The code scanning processing method according to claim 4, characterized in that: The process of supplementing the context code information of the code file to be scanned to obtain the processed code file to be scanned specifically includes: Based on the code file to be scanned, extract the context code file in the context of the target code file library, wherein the context code file is a code file having a reference relationship with the code file to be scanned, and the target code file library is a code file library including the code file to be scanned; Based on the context code file, the code file to be scanned is supplemented with context code information to obtain a processed code file to be scanned.
6. The code scanning processing method according to claim 1, characterized in that: The code type includes a second code type; the code scanning strategy includes a second code scanning strategy; Determine the code type of the code file to be scanned, and implement it in the following manner: In the case where the code file to be scanned is used to describe an object and / or define an object, determining that the code type of the code file to be scanned is the second code type; The step of retrieving a code scanning strategy matching the code type based on the code type of the code file to be scanned to scan the code file to be scanned, and obtaining a scanning result of the code file to be scanned specifically includes: Based on the second code type of the code file to be scanned, the second code scanning strategy matching the second code type is called up to scan the code file to be scanned to obtain a scanning result of the code file to be scanned, wherein the second code scanning strategy is a scanning strategy that scans the code file to be scanned based on static rules.
7. The code scanning processing method according to claim 6, characterized in that: The calling of the second code scanning strategy matching the second code type to scan the code file to be scanned to obtain the scanning result of the code file to be scanned specifically includes: The static rule is retrieved, and based on the static rule, the code file to be scanned is scanned to obtain a scanning result of the code file to be scanned.
8. The code scanning processing method according to any one of claims 1 to 7, characterized in that: After obtaining the scanning result of the code file to be scanned, the method further includes: The scanning result is displayed.
9. A code scanning processing device, characterized in that: The device comprises: An acquisition module, used for acquiring a code file to be scanned and determining a code type of the code file to be scanned; The processing module is used to retrieve a code scanning strategy matching the code type based on the code type of the code file to be scanned, perform scanning processing on the code file to be scanned, and obtain a scanning result of the code file to be scanned.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the code scanning processing method according to any one of claims 1 to 8 is implemented.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the code scanning processing method according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the code scanning processing method according to any one of claims 1 to 8 is implemented.