Code testing method and device, equipment, storage medium and program product

By performing security scanning and quality access control detection of the source code, combined with the CICD system, the problem of high false alarm rate of static code scanning is solved, accurate vulnerability detection and prevention is achieved, and the efficiency and security of code testing are improved.

CN118940264APending Publication Date: 2024-11-12CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410986960.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

In the prior art, static code scanning tools are prone to misdiagnosis of software memory leakage and concurrent errors, resulting in a high false alarm rate.

Method used

By obtaining the source code to be tested, using code analysis tools for security scans, and performing quality access control detection on the scan results. Testing is only carried out when the source code passes quality access control detection and is compiled and deployed, combined with continuous integration, Coverity analysis tools in Continuous Delivery and Continuous Deployment (CICD) systems perform secure scanning and compilation deployment, reducing false positive rates.

Benefits of technology

Effectively detect existing memory leaks and concurrent error problems, reduce the false alarm rate of code security detection, improve testing efficiency, and promptly update vulnerabilities in source code or code analysis tools through quality access control detection, and discover and prevent vulnerability risks in advance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118940264A_ABST
    Figure CN118940264A_ABST
Patent Text Reader

Abstract

The invention provides a code testing method and device, equipment, a storage medium and a program product, and relates to the technical field of communication, and the method comprises the following steps: obtaining a to-be-tested source code; performing security scanning on the source code by utilizing a code analysis tool to obtain a scanning result; performing quality access control detection on the scanning result; and under the condition that the source code passes the quality access control detection and the source code is compiled and deployed, testing the source code. According to the embodiment of the invention, the problem of high false alarm rate of static code scanning in the prior art can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a code testing method, device, equipment, storage medium and program product. Background Art

[0002] In the information age, network security issues frequently occur, mostly due to malicious exploitation of security vulnerabilities in the software itself. In the prior art, vulnerabilities are mainly tested by manually using static code scanning tools to perform security scans on the code offline. However, static code scanning can easily misdiagnose problems such as memory leaks and concurrency errors in the software, resulting in a high false alarm rate. Summary of the invention

[0003] The embodiments of the present application provide a code testing method, apparatus, device, storage medium and program product to solve the problem of high false alarm rate of static code scanning in the prior art.

[0004] To solve the above technical problems, this application is implemented as follows:

[0005] In a first aspect, an embodiment of the present application provides a code testing method, the method comprising:

[0006] Get the source code to be tested;

[0007] Using a code analysis tool to perform a security scan on the source code to obtain a scan result;

[0008] Performing quality access control detection on the scanning result;

[0009] When the source code passes the quality gate detection and the source code passes the compilation and completes the deployment, the source code is tested.

[0010] Optionally, the scanning result indicates a vulnerability risk level of the source code;

[0011] The performing quality gate control detection on the scanning result includes:

[0012] Determining whether the vulnerability risk level of the source code is higher than a preset risk level;

[0013] When the vulnerability risk level of the source code is lower than the preset risk level, determining that the source code passes the quality gate detection;

[0014] When the vulnerability risk level of the source code is higher than the preset risk level, it is determined that the source code fails the quality gate detection.

[0015] Optionally, the method further comprises:

[0016] In the case where the source code fails to pass the quality gate detection, at least one processing option is provided, wherein the at least one processing option includes at least one option of rectification, appeal and special release;

[0017] According to the selected target processing method option, the source code is processed using a corresponding processing method.

[0018] Optionally, the method further comprises at least one of the following:

[0019] When the target processing mode option is a rectification option, obtaining the rectified source code, and returning to execute the security scan of the source code using the code analysis tool to obtain the scan result;

[0020] When the target processing method option is an appeal option, the vulnerability library in the code analysis tool is updated according to the review result of the source code, and the code analysis tool is used to perform a security scan on the source code to obtain the scan result;

[0021] When the target processing mode option is special release, the source code is tested.

[0022] Optionally, the using a code analysis tool to perform security scanning on the source code includes:

[0023] Make the Coverity analysis tool into a Jenkins plug-in and integrate the Jenkins plug-in into the continuous integration, continuous delivery and continuous deployment CICD system;

[0024] The source code is scanned for security using the Coverity analysis tool in the CICD system.

[0025] Optionally, obtaining the source code to be tested includes:

[0026] Obtain source code to be tested from the first repository branch of the first code repository;

[0027] The method further comprises:

[0028] The source code is compiled, and the compiled source code is deployed.

[0029] Optionally, the using a code analysis tool to perform security scanning on the source code includes:

[0030] An intermediate file is generated for the source code by a code analysis tool, and the intermediate file is transmitted to an analysis machine for analysis to obtain an analysis result; a scan report is generated according to the analysis result, and the scan report includes the scan result.

[0031] In a second aspect, an embodiment of the present application further provides a code testing device, including:

[0032] A first acquisition module is used to acquire source code to be tested;

[0033] A second acquisition module is used to perform a security scan on the source code using a code analysis tool to obtain a scan result;

[0034] A door access detection module, used for performing a quality door access detection on the scanning result;

[0035] The test execution module is used to test the source code when the source code passes the quality gate detection and the source code passes the compilation and completes the deployment.

[0036] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, and a program stored in the memory and executable on the processor, wherein the program, when executed by the processor, implements the steps of the code testing method described in the first aspect above.

[0037] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the code testing method described in the first aspect are implemented.

[0038] In a fifth aspect, a computer program product is provided, comprising computer instructions, which, when executed by a processor, implement the steps of the code testing method as described in the first aspect.

[0039] In an embodiment of the present application, a code testing method is provided, in which a security scan is performed on the source code to be tested to obtain the scanning results, and then the scanning results are subjected to a quality access control test. The source code is tested only when the quality access control test of the source code passes and the deployment is completed through compilation. The security scan and compilation deployment can be carried out in parallel to save code testing time and improve testing efficiency. In an embodiment of the present application, not only can a security scan be performed on the source code, but the scanning results can also be re-detected and updated according to the quality access control, so as to facilitate the update of vulnerabilities in the source code or code analysis tools at any time, discover and prevent vulnerability risks in advance, and reduce the false alarm rate of scanning. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0041] Figure 1 This is one of the flow charts of a code testing method provided in an embodiment of the present application;

[0042] Figure 2 This is the second flowchart of a code testing method provided in an embodiment of the present application;

[0043] Figure 3 It is a structural schematic diagram of a code testing device provided in an embodiment of the present application;

[0044] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0045] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0046] In order to make the embodiments of the present application clearer, the relevant technical knowledge involved in the embodiments of the present application is first introduced as follows:

[0047] In the field of code security scanning, code analysis tools usually include SonarQube, Programming Mistake Detector (PMD), Coverity, etc. Among them, SonarQube is used to analyze code in multiple dimensions, including code volume, security risks, writing standard risks, duplication, code increment, test coverage, etc., covering the static scanning rules of programming languages. PMD is a static code detection tool for a programming language (Java), which is used in code development. It can check whether the Java code contains unused variables, empty capture blocks, unnecessary objects, etc.

[0048] In the following, in conjunction with the accompanying drawings, a code testing method, device, electronic device and readable storage medium provided in an embodiment of the present application are described in detail through specific embodiments and their application scenarios.

[0049] See also Figure 1 , Figure 1 This is one of the flowcharts of a code testing method provided in an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:

[0050] Step 101: Obtain source code to be tested.

[0051] It should be noted that the source code to be tested can be obtained from a code repository, which stores multiple versions of source code. The code repository can be managed through a version control system. The code in the code repository can have multiple branches, each of which represents a different version or development status of the code.

[0052] In the embodiments of the present application, the source code for compilation and deployment and the source code for security scanning can be in the same warehouse branch of the same code warehouse. Specifically, the same code warehouse refers to a code base stored in the same location, and the same warehouse branch refers to a code branch in this code warehouse. In the same code warehouse, there can be multiple branches, each of which may be used for different purposes, such as developing new features, fixing bugs, releasing versions, etc. Different branches can be developed in parallel without affecting each other, and can eventually be merged into the main branch.

[0053] Therefore, the source code to be tested obtained in the embodiment of the present application can be obtained from a specific branch in the same code repository, so that developers can make code changes and development work on the branch, so that compilation deployment and security scanning can be carried out in parallel, ensuring that the code actually released for testing is consistent with the code for security scanning, thereby reducing the test error rate.

[0054] Step 102: Use a code analysis tool to perform a security scan on the source code to obtain a scan result.

[0055] It is understandable that the code analysis tool used may be Coverity, or may be SonarQube, PMD, etc., and this application does not specifically limit this. In the embodiment of this application, Coverity is used as the code analysis tool for illustration.

[0056] Specifically, Coverity can be integrated with the test system of continuous integration (CI), continuous delivery (CD), and continuous deployment (CD) (in other words, it can be a CICD pipeline), and Coverity can be set in the CICD system as a necessary process for code security scanning. In this way, Coverity can be used to complete the security scan of the source code and generate the scan results. Among them, the scan result can display the security level of the source code. For example, the scan result can be one of five security levels, and the five security levels can be very low, low, medium, high, and very high.

[0057] Step 103: Perform quality access control detection on the scanning result.

[0058] In a specific embodiment, the acquired scanning results may be subjected to a quality gate check. Setting a quality gate can discover vulnerabilities in source code or code analysis tools in advance, perform vulnerability updates in a timely manner, play a risk prevention role, and improve the quality of the source code that is ultimately tested.

[0059] Specifically, the risk level of the vulnerability can be determined based on the risk security level of the source code displayed in the scan result. For example, if the scan result shows that the security level is very low, the vulnerability risk level can correspond to very high. When the vulnerability risk level is high or very high, the quality gate is not passed. When the vulnerability risk level is displayed as any of very low, low, and medium, the quality gate is passed and the next step can be performed on the source code.

[0060] Furthermore, if the quality gate fails, the tester can be required to update the source code in a timely manner or fix the vulnerabilities in the code analysis tool in a timely manner to ensure the security of the source code that finally enters the test. In this way, through the two steps of security scanning and quality gate detection, the compiled source code files can be tested to effectively detect existing memory leaks, concurrency errors and other problems, reducing the false positive rate of source code security detection.

[0061] Step 104: When the source code passes the quality gate detection and the source code passes the compilation and deployment is completed, the source code is tested.

[0062] It is worth mentioning that the embodiment of the present application can apply the CICD system to perform code testing, which can be divided into a process in which source code compilation and construction, task deployment are executed in sequence, and a process in which source code security scanning and quality access are executed in sequence. The two processes can be carried out in parallel to ensure the consistency of the actual test release code and the code that passes the security scan.

[0063] In the specific implementation, the same source code can only be tested and released when it has passed the quality gate, compiled and deployed. The connection between code security scanning and CICD system is strengthened, and source code that has not passed security scanning is not allowed to enter the testing process to ensure the consistency of source code compilation deployment, security scanning and test release.

[0064] Optionally, the scanning result indicates a vulnerability risk level of the source code;

[0065] The performing quality gate control detection on the scanning result includes:

[0066] Determining whether the vulnerability risk level of the source code is higher than a preset risk level;

[0067] When the vulnerability risk level of the source code is lower than the preset risk level, determining that the source code passes the quality gate detection;

[0068] When the vulnerability risk level of the source code is higher than the preset risk level, it is determined that the source code fails the quality gate detection.

[0069] In some embodiments, the scan result may indicate the vulnerability risk level of the source code, for example, any one of the three vulnerability risk levels of low, medium, and high. The preset risk level may be set to medium, and when the vulnerability risk level of the source code is indicated as low, it is determined that the source code has passed the quality gate detection. When the vulnerability risk level of the source code is indicated as high, it is determined that the source code has not passed the quality gate detection. In this way, by determining whether the source code has passed the quality gate detection based on the vulnerability risk level, high-risk vulnerabilities in the source code can be effectively prevented and repaired in a timely manner.

[0070] In addition, you can set up quality gate detection in the CICD system. After the security scan, the quality gate detection is performed based on the scan results. The vulnerability risk level is determined based on the scan results. Different responses are made according to different vulnerability risk levels, reducing alerts for lower vulnerability risk levels and reducing the false alarm rate of code security scans.

[0071] Optionally, the method further comprises:

[0072] In the case where the source code fails to pass the quality gate detection, at least one processing option is provided, wherein the at least one processing option includes at least one option of rectification, appeal and special release;

[0073] According to the selected target processing method option, the source code is processed using a corresponding processing method.

[0074] In some other embodiments of the present application, when the quality gate detection fails, multiple processing methods can be provided for source code testing users or source code testing systems, etc. By selecting one of the processing methods, the source code can be repaired or rectified in time to improve the reliability and security of the source code.

[0075] Optionally, the method further comprises at least one of the following:

[0076] When the target processing mode option is a rectification option, obtaining the rectified source code, and returning to execute the security scan of the source code using the code analysis tool to obtain the scan result;

[0077] When the target processing method option is an appeal option, the vulnerability library in the code analysis tool is updated according to the review result of the source code, and the code analysis tool is used to perform a security scan on the source code to obtain the scan result;

[0078] When the target processing mode option is special release, the source code is tested.

[0079] Specifically, the processing method may include at least one of rectification, appeal and special release. Among them, rectification can be to require the source code provider (which can be a compiler, tester, etc.) to rectify and repair the current source code, repair the high-risk vulnerabilities in the source code, resubmit the source code after the repair is completed, and re-perform security scanning and quality gate detection until the quality gate detection is passed. The appeal can be made by compilers, testers, etc., and can be an appeal due to inaccurate Coverity scanning or false positives. In response to this appeal, a professional review of the source code is conducted. When the review is passed, it can be determined in time whether the code analysis tool has vulnerabilities, and the vulnerabilities can be updated and fixed in time. At this time, the source code can be tested after the compilation and deployment are completed. In addition, when the review fails, the source code can be rectified and repaired in time to facilitate security scanning and quality gate detection again.

[0080] Special release can be set for source code with special application scenarios or pre-set source code. By selecting the special release processing method, you can directly enter the code testing step, saving the code security detection process and improving code detection efficiency.

[0081] Optionally, the using a code analysis tool to perform security scanning on the source code includes:

[0082] Make the Coverity analysis tool into a Jenkins plug-in and integrate the Jenkins plug-in into the continuous integration, continuous delivery and continuous deployment CICD system;

[0083] The source code is scanned for security using the Coverity analysis tool in the CICD system.

[0084] In some specific embodiments of the present application, security scanning of source code can be achieved through the Coverity analysis tool. Before performing the security scan, the Coverity analysis tool can be made into a Jenkins plug-in to facilitate its integration into the CICD system for continuous integration, continuous delivery, and continuous deployment.

[0085] Specifically, the process of using the Coverity analysis tool to perform security scanning may include creating a Coverity project, generating intermediate files, creating data streams, and analyzing results. Among them, the creation of a Coverity project can be performed through the cov-manage-im--mode projects command. The name of the created project needs to be unified and can be named after the product corresponding to the source code. The generation of intermediate files can be processed according to the different languages ​​used in the source code. The compiled language can pass in the corresponding compilation command, and the non-compiled language can be identified by --no-command, so as to perform cov-build on the source code to generate intermediate files. Subsequently, the creation of data streams can be performed based on modules, versions, code repositories, etc. The command to create data streams can be specifically cov-manage-im--mode streams--add--setname.

[0086] It can be seen that the embodiment of the present application can effectively reduce the time consumed by the Coverity analysis tool itself for cloning and compiling codes by integrating the Coverity analysis tool and the CICD system, save process time, and improve code testing efficiency.

[0087] Optionally, obtaining the source code to be tested includes:

[0088] Obtain source code to be tested from the first repository branch of the first code repository;

[0089] The method further comprises:

[0090] The source code is compiled, and the compiled source code is deployed.

[0091] In some embodiments, compiling the source code is the process of translating the source code into machine code so that the product corresponding to the source code can support different programming languages. During the compilation, a label for the source code can be created first. Since the label under the same product is unique, the label can be used to specify the warehouse path for the product corresponding to the source code to be stored. The Jenkins plug-in can be integrated into the CICD system to facilitate scheduling the final compilation process to be executed on the Jenkins plug-in. Subsequently, the compilation build script can be written according to the different languages ​​of the source code and in combination with the business scenarios of the corresponding products. The script source can support two methods: Jenkinsfile and page writing. In this way, the deployment method of the Jenkins plug-in makes the test process highly portable and lightweight.

[0092] Further, after the compilation process is completed, the source code can be deployed, and the software packages or images of various versions of the compiled build can be deployed from the product warehouse to a group of automated configuration tasks of the machine or container platform. The deployment task can be that the CICD system pulls the corresponding software package or image from the product warehouse, performs corresponding parameter packaging, and executes the deployment script. In addition, the product source of the deployment task can be in two ways, the first is from the aforementioned compilation and construction product, and the second can be from the release warehouse, which can contain software packages manually uploaded by the user. The deployment method can support one-to-one, one-to-many, and no product and other deployment modes. Among them, one-to-one deployment means that one deployment task corresponds to one product, one-to-many means that one deployment task corresponds to multiple products, and no product means that one deployment task corresponds to 0 products. The deployment script in the embodiment of the present application can support ANSIBLE and SHELL and other methods, which are not specifically limited in the present application.

[0093] Optionally, the using a code analysis tool to perform security scanning on the source code includes:

[0094] An intermediate file is generated for the source code by a code analysis tool, and the intermediate file is transmitted to an analysis machine for analysis to obtain an analysis result; a scan report is generated according to the analysis result, and the scan report includes the scan result.

[0095] In a specific embodiment, after the code analysis tool generates an intermediate file based on the source code, the intermediate file can be analyzed, and the intermediate file can be transferred to the analysis machine for analysis (cov-analyze). After the analysis is completed, the analysis result can be captured. It is worth mentioning that this analysis result can only be used when the scanning completion progress (Scanning archives complete) reaches a preset threshold (for example, 98%). Finally, the scanning result can be output according to the analysis result, and the scanning result can be a distinction between various security levels of the source code.

[0096] In addition, the Coverity analysis tool in the embodiment of the present application can generate a report through cov-generate-security-report report.yaml-output, and the CICD system can also archive files through archive.

[0097] like Figure 2 As shown, the embodiment of the present application also provides a code testing method, which specifically includes the following steps:

[0098] Step 201: Obtain source code to be tested;

[0099] Step 202: Use a code analysis tool to perform a security scan on the source code to obtain a scan result;

[0100] Step 203: determine whether the scanning result of the source code passes the quality gate detection;

[0101] Step 204: if the source code fails to pass the quality gate detection, provide at least one processing option, wherein the at least one processing option includes at least one of rectification, appeal, and special release;

[0102] Step 205: when the target processing mode option is a rectification option, obtain the rectified source code, and return to execute the security scan of the source code using the code analysis tool to obtain the scan result;

[0103] Step 206: When the target processing method option is the appeal option, the vulnerability library in the code analysis tool is updated according to the review result of the source code, and the code analysis tool is used to perform a security scan on the source code to obtain the scan result.

[0104] Step 207: When the target processing mode option is special release, test the source code;

[0105] Step 208: compile the source code, and deploy the compiled source code;

[0106] Step 209: When the source code passes the quality gate detection and the source code passes the compilation and deployment, the source code is tested.

[0107] It should be noted that the specific implementation of this embodiment can achieve Figure 1 The same beneficial effects of the illustrated embodiment can be specifically referred to the relevant description of the above embodiment. In order to avoid repeated description, this embodiment will not be described in detail.

[0108] See also Figure 3 , Figure 3 The schematic diagram of the structure of a code testing device provided in an embodiment of the present application is as follows. The code testing device 300 in an embodiment of the present application specifically includes:

[0109] A first acquisition module 301 is used to acquire source code to be tested;

[0110] The second acquisition module 302 is used to perform a security scan on the source code using a code analysis tool to obtain a scan result;

[0111] The access control detection module 303 is used to perform a quality access control detection on the scanning result;

[0112] The test execution module 304 is used to test the source code when the source code passes the quality gate detection and the source code passes the compilation and completes the deployment.

[0113] Optionally, the scanning result indicates a vulnerability risk level of the source code;

[0114] The access control detection module 303 includes:

[0115] A first determining unit, configured to determine whether the vulnerability risk level of the source code is higher than a preset risk level;

[0116] A second determining unit, configured to determine that the source code passes the quality gate detection if the vulnerability risk level of the source code is lower than the preset risk level;

[0117] The third determining unit is configured to determine that the source code fails the quality gate detection if the vulnerability risk level of the source code is higher than the preset risk level.

[0118] Optionally, the code testing device 300 further includes:

[0119] A selection unit, configured to provide at least one processing option when the source code fails to pass the quality gate detection, wherein the at least one processing option includes at least one of rectification, appeal and special release;

[0120] The processing unit is used to process the source code in a corresponding processing manner according to the selected target processing manner option.

[0121] Optionally, the code testing device 300 further includes at least one of the following:

[0122] A first acquisition unit is used to acquire the rectified source code when the target processing mode option is the rectification option, and return to execute the security scan of the source code using the code analysis tool to obtain the scanning result;

[0123] an updating unit, configured to update the vulnerability library in the code analysis tool according to the review result of the source code when the target processing mode option is the appeal option, and return to execute the security scan of the source code using the code analysis tool to obtain the scan result;

[0124] The testing unit is used to test the source code when the target processing mode option is special release.

[0125] Optionally, the second acquisition module 302 includes:

[0126] An integration unit, which is used to make the Coverity analysis tool into a Jenkins plug-in and integrate the Jenkins plug-in into the continuous integration, continuous delivery and continuous deployment CICD system;

[0127] The security scanning unit is used to perform a security scan on the source code through the Coverity analysis tool in the CICD system.

[0128] Optionally, the first acquisition module 301 includes:

[0129] A second acquisition unit is used to acquire source code to be tested from a first warehouse branch of the first code warehouse;

[0130] The code testing device 300 further includes:

[0131] The compiling unit is used to compile the source code and deploy the compiled source code.

[0132] Optionally, the second acquisition module 302 includes:

[0133] The third acquisition unit is used to generate an intermediate file for the source code through a code analysis tool, and transmit the intermediate file to an analysis machine for analysis to obtain an analysis result; based on the analysis result, a scan report is generated, and the scan report includes the scan result.

[0134] It should be noted that this embodiment is Figure 1 The corresponding device side implementation in the embodiment shown in the figure can be found in the specific implementation Figure 1 In order to avoid repeated description, the relevant description of the embodiment shown will not be repeated in this embodiment, and the same beneficial effects can still be achieved.

[0135] The embodiment of the present application also provides an electronic device. Since the principle of solving the problem by the electronic device is similar to the code testing method in the embodiment of the present application, the implementation of the electronic device can refer to the implementation of the method, and the repeated parts will not be repeated. Figure 4 , Figure 4 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 4 As shown, the electronic device includes:

[0136] The processor 410 is used to read the program in the memory 420 and execute the following process:

[0137] Get the source code to be tested;

[0138] Using a code analysis tool to perform a security scan on the source code to obtain a scan result;

[0139] Performing quality access control detection on the scanning result;

[0140] When the source code passes the quality gate detection and the source code passes the compilation and completes the deployment, the source code is tested.

[0141] Among them, Figure 4 In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically linking various circuits of one or more processors represented by processor 410 and memory represented by memory 420. The bus architecture may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface. The processor 410 is responsible for managing the bus architecture and general processing, and the memory 420 may store data used by the processor 410 when performing operations.

[0142] Optionally, the processor 410 is further configured to read a program in the memory 420 and execute the following steps:

[0143] The performing quality gate control detection on the scanning result includes:

[0144] Determining whether the vulnerability risk level of the source code is higher than a preset risk level;

[0145] When the vulnerability risk level of the source code is lower than the preset risk level, determining that the source code passes the quality gate detection;

[0146] When the vulnerability risk level of the source code is higher than the preset risk level, it is determined that the source code fails the quality gate detection.

[0147] Optionally, the processor 410 is further configured to read a program in the memory 420 and execute the following steps:

[0148] In the case where the source code fails to pass the quality gate detection, at least one processing option is provided, wherein the at least one processing option includes at least one option of rectification, appeal and special release;

[0149] According to the selected target processing method option, the source code is processed using a corresponding processing method.

[0150] Optionally, the processor 410 is further configured to read a program in the memory 420 and execute the following steps:

[0151] When the target processing mode option is a rectification option, obtaining the rectified source code, and returning to execute the security scan of the source code using the code analysis tool to obtain the scan result;

[0152] When the target processing method option is an appeal option, the vulnerability library in the code analysis tool is updated according to the review result of the source code, and the code analysis tool is used to perform a security scan on the source code to obtain the scan result;

[0153] When the target processing mode option is special release, the source code is tested.

[0154] Optionally, the processor 410 is further configured to read a program in the memory 420 and execute the following steps:

[0155] Make the Coverity analysis tool into a Jenkins plug-in and integrate the Jenkins plug-in into the continuous integration, continuous delivery and continuous deployment CICD system;

[0156] The source code is scanned for security using the Coverity analysis tool in the CICD system.

[0157] Optionally, the processor 410 is further configured to read a program in the memory 420 and execute the following steps:

[0158] Obtain source code to be tested from the first repository branch of the first code repository;

[0159] The method further comprises:

[0160] The source code is compiled, and the compiled source code is deployed.

[0161] Optionally, the processor 410 is further configured to read a program in the memory 420 and execute the following steps:

[0162] An intermediate file is generated for the source code by a code analysis tool, and the intermediate file is transmitted to an analysis machine for analysis to obtain an analysis result; a scan report is generated according to the analysis result, and the scan report includes the scan result.

[0163] It should be noted that the electronic device 400 in the embodiment of the present application can achieve Figure 1 The various processes implemented in the code testing method embodiment shown can achieve the same beneficial effects, and will not be described again here to avoid repetition.

[0164] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned code testing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0165] The present application also provides a computer program product, including computer instructions, which, when executed by a processor, implement the above Figure 1 or Figure 2 The various processes of the method embodiment shown can achieve the same technical effect, and will not be described again here to avoid repetition.

[0166] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0167] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0168] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A code testing method, characterized in that: include: Get the source code to be tested; Using a code analysis tool to perform a security scan on the source code to obtain a scan result; Performing quality access control detection on the scanning result; When the source code passes the quality gate detection and the source code passes the compilation and completes the deployment, the source code is tested.

2. The method according to claim 1, characterized in that: The scanning result indicates the vulnerability risk level of the source code; The performing quality gate control detection on the scanning result includes: Determining whether the vulnerability risk level of the source code is higher than a preset risk level; When the vulnerability risk level of the source code is lower than the preset risk level, determining that the source code passes the quality gate detection; When the vulnerability risk level of the source code is higher than the preset risk level, it is determined that the source code fails the quality gate detection.

3. The method according to claim 1, characterized in that The method further comprises: In the case where the source code fails to pass the quality gate detection, at least one processing option is provided, wherein the at least one processing option includes at least one option of rectification, appeal and special release; According to the selected target processing method option, the source code is processed using a corresponding processing method.

4. The method according to claim 3, characterized in that The method further comprises at least one of the following: When the target processing mode option is a rectification option, obtaining the rectified source code, and returning to execute the security scan of the source code using the code analysis tool to obtain the scan result; When the target processing method option is an appeal option, the vulnerability library in the code analysis tool is updated according to the review result of the source code, and the code analysis tool is used to perform a security scan on the source code to obtain the scan result; When the target processing mode option is special release, the source code is tested.

5. The method according to any one of claims 1 to 4, characterized in that The using a code analysis tool to perform security scanning on the source code includes: Make the Coverity analysis tool into a Jenkins plug-in and integrate the Jenkins plug-in into the continuous integration, continuous delivery and continuous deployment CICD system; The source code is scanned for security using the Coverity analysis tool in the CICD system.

6. The method according to any one of claims 1 to 4, characterized in that The obtaining of source code to be tested includes: Obtain source code to be tested from the first repository branch of the first code repository; The method further comprises: The source code is compiled, and the compiled source code is deployed.

7. The method according to any one of claims 1 to 4, characterized in that The using a code analysis tool to perform security scanning on the source code includes: An intermediate file is generated for the source code by a code analysis tool, and the intermediate file is transmitted to an analysis machine for analysis to obtain an analysis result; a scan report is generated according to the analysis result, and the scan report includes the scan result.

8. A code testing device, characterized in that: include: A first acquisition module is used to acquire source code to be tested; A second acquisition module is used to perform a security scan on the source code using a code analysis tool to obtain a scan result; A door access detection module, used for performing a quality door access detection on the scanning result; The test execution module is used to test the source code when the source code passes the quality gate detection and the source code passes the compilation and completes the deployment.

9. An electronic device, characterized in that: include: A processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the code testing method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the code testing method according to any one of claims 1 to 7 are implemented.

11. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the code testing method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Software research and development security access control implementation method, device and equipment and storage medium

    CN121614408A

  • A software research and development security access control implementation method, device and equipment and storage medium

    CN121614408B