A method, system, electronic device, storage medium, and program product for automatic code verification and quality access control.

By building a containerized verification environment to perform static code verification when a merge request is detected in the code repository, and controlling merge permissions according to severity mapping rules, the problem of inconsistent static code verification results is solved, and automated code merge decision-making and quality control are achieved.

CN122132079APending Publication Date: 2026-06-02SHENZHEN FRIENDCOM TECH DEV +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN FRIENDCOM TECH DEV
Filing Date
2026-01-21
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing static code verification tools produce inconsistent results in different compilation environments, are difficult to reproduce, and lack effective linkage with the code repository merging process, resulting in low automation.

Method used

When a merge request is detected in the code repository, a containerized verification environment corresponding to the project is built to perform static code verification, generate verification result files, and aggregate the levels according to severity mapping rules to directly control the permissions of merge requests.

Benefits of technology

It achieves consistency and reproducibility of verification results across different projects and compilation toolchains, supports automated merge decisions, and improves the automation level of code quality control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122132079A_ABST
    Figure CN122132079A_ABST
Patent Text Reader

Abstract

This invention discloses a method, system, electronic device, storage medium, and program product for automatic code verification and quality access control. The method includes: when a new merge request is detected in the code repository, a trigger request is sent to the continuous integration server; the pipeline task automatically pulls the source code corresponding to the merge request; based on the project to which the source code belongs and the corresponding compilation toolchain information, a matching containerized verification environment is selected or built; static code verification is performed in the containerized verification environment, generating a verification result file containing multiple verification issues; the verification result file is parsed, and according to a preset severity mapping rule, the verification issues are aggregated from their original severity levels into multiple levels; the number of verification issues corresponding to each severity level is counted to generate a quality judgment result; based on the quality judgment result, the pipeline execution status is returned to the code repository. This invention improves the consistency of verification results and eliminates the need for manual intervention in merge decisions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of code management technology, and in particular to a method, system, electronic device, storage medium, and program product for automatic code verification and quality access control. Background Technology

[0002] In software development, static code analysis, as an important means of ensuring code quality, is usually integrated into continuous integration pipelines to identify potential defects before code merging or release. However, in existing technologies, static code analysis tools often depend on specific compilation environments during execution, including factors such as the compilation toolchain, compilation parameters, header file paths, and the version of the analysis rules.

[0003] Because different projects use different compilation toolchains and dependency environments, even for the same source code, static code verification may produce inconsistent results when performed in different verification environments. Furthermore, as compilation toolchains or verification rules are upgraded, verification results may change even without modifying the source code, making it difficult to reproduce historical verification results.

[0004] Moreover, static code verification results are mostly presented in the form of reports, lacking effective linkage with the code repository merging process. Verification results are difficult to directly participate in code merging decisions, resulting in code quality control still relying on manual judgment and having a low degree of automation.

[0005] Therefore, there is an urgent need for an automated code verification technology that can ensure the consistency of the verification environment under different projects and different compilation toolchains, and effectively apply the static code verification results to the code merging control process. Summary of the Invention

[0006] The purpose of this invention is to provide a web-based method, system, electronic device, storage medium, and program product for automatic code verification and quality access control, thereby overcoming the aforementioned limitations of the prior art. The numerous technical effects of the preferred solutions among the many technical solutions provided by this invention are detailed below.

[0007] To achieve the above objectives, the present invention provides the following technical solution: This invention provides a method for automatic code verification and quality access control, the steps of which include: When the code repository detects a new merge request, it sends a trigger request to the continuous integration server to start the pipeline task corresponding to the merge request. The pipeline task automatically pulls the source code corresponding to the merge request; Based on the source code's project and its corresponding compilation toolchain information, select or build a matching containerized verification environment; Perform static code verification in the containerized verification environment to generate a verification result file containing multiple verification questions; The verification result file is parsed, and the verification issues are aggregated from their original severity levels into multiple levels according to the preset severity mapping rules; The number of issues to be checked for each severity level is counted and compared with a pre-set quantity threshold to generate a quality judgment result. Based on the quality assessment result, the pipeline execution status is sent back to the code repository. The pipeline execution status is used to control whether the merge request is allowed to perform the merge operation.

[0008] In one or more embodiments, when a new merge request is detected in the code repository, a trigger request is sent to the continuous integration server via a pre-configured Webhook mechanism.

[0009] In one or more embodiments, the pipeline task automatically pulls the source code corresponding to the merge request and obtains the identity information of the merge request submitter. When the pipeline task is completed, the continuous integration server automatically sends a notification message containing the pipeline execution log and a summary of the verification results to the merge request submitter based on the identity information.

[0010] In one or more embodiments, the verification result file is synchronously uploaded to a centralized quality management server after it is generated, for use in visualizing and analyzing the trend of changes in the number of verification issues, the distribution of severity, and historical data.

[0011] In one or more embodiments, the containerized verification environment includes static code verification tools, a compilation toolchain, and verification rule files, which are installed or copied via image.

[0012] In one or more embodiments, the original verification issues output by the static code verification tool are divided into multiple severity levels; the pipeline task merges the multiple original severity levels into three categories—high, medium, and low—according to a preset severity mapping rule, and sets an independent quantity threshold for each level; when the number of generated verification issues corresponding to any level exceeds the corresponding threshold, the pipeline task is deemed to have failed.

[0013] According to another aspect of the present invention, an automatic code verification and quality access control system is also provided, for implementing the above-described automatic code verification and quality access control method, comprising: The trigger module is used to trigger continuous integration pipeline tasks via Webhook when a new merge request is detected in the code repository. The source code acquisition module is used to control the pipeline task to pull the source code corresponding to the merge request from the code repository; The environment selection module is used to select or build the corresponding containerized verification environment based on the project to which the source code belongs and the compilation toolchain information. The verification execution module performs static code verification in the containerized verification environment and generates a verification result file containing multiple verification questions. The result parsing module is used to parse the verification result file and aggregate the verification issues from the original severity level into multiple levels according to the preset severity mapping rules; The quality assessment module is used to count the number of the inspection issues corresponding to each severity level, compare them with a pre-set quantity threshold, and generate a quality assessment result. The merge control module is used to control the merge permissions of the merge requests in the code repository based on the quality assessment results.

[0014] According to another aspect of the invention, an electronic device is also provided, comprising: at least one processor; and at least one memory for storing processor-executable instructions. The at least one processor executes the executable instructions to implement a code automatic verification and quality access control method as described above.

[0015] According to another aspect of the present invention, a computer-readable storage medium is also provided, on which computer instructions are stored, which, when executed by at least one processor, implement the code automatic verification and quality access control method described above.

[0016] According to another aspect of the present invention, a computer program product is also provided, including a computer program or instructions, which, when executed by a processor, implement the code automatic verification and quality access control method described above.

[0017] Implementing one of the above-described technical solutions of the present invention has the following advantages or beneficial effects: This invention ensures that static code verification is performed in a unified environment by building corresponding containerized verification environments for different projects and compilation toolchains, thereby improving the consistency and reproducibility of verification results. Simultaneously, by directly linking verification results to the code repository's merge control process, it enables automatic merge decisions based on quality assessment results. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings: Figure 1 This is a flowchart of an automatic code verification and quality access control method according to an embodiment of the present invention; Figure 2 This is a block diagram of an automatic code verification and quality access control system according to an embodiment of the present invention; Figure 3 This is a schematic diagram of an electronic device structure according to an embodiment of the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of the present invention clearer, various exemplary embodiments described below will be referenced to the accompanying drawings, which form part of the exemplary embodiments, illustrating various exemplary embodiments that may be used to implement the present invention. Unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. It should be understood that they are merely examples of processes, methods, and apparatuses consistent with some aspects of the present invention disclosed as detailed in the appended claims, and other embodiments may be used, or structural and functional modifications may be made to the embodiments listed herein without departing from the scope and spirit of the present invention.

[0020] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," etc., indicate the orientation or positional relationship based on the accompanying drawings, and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the referred element must have a specific orientation, or be constructed and operated in a specific orientation. The terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. The term "multiple" means two or more. The terms "connected" and "linked" should be interpreted broadly, for example, they can be fixed connections, detachable connections, integral connections, mechanical connections, electrical connections, communication connections, direct connections, indirect connections through an intermediate medium, and can be the internal connection of two elements or the interaction relationship between two elements. The term "and / or" includes any and all combinations of one or more of the related listed items. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0021] To illustrate the technical solution described in this invention, specific embodiments are described below, showing only the parts related to the embodiments of this invention.

[0022] Example 1: like Figure 1 As shown in the figure, the automatic code verification and quality access control method provided in this embodiment includes the following steps: S100. When a new merge request is detected in the code repository, a trigger request is sent to the continuous integration server to start the pipeline task corresponding to the merge request.

[0023] To put it simply, continuous integration servers like Jenkins CI / CD servers automatically trigger scans of GitLab server code to identify defects and improve code quality. GitLab, on the other hand, is a web-based (World Wide Web) Git repository management system that provides hosting for Git (distributed version control system) code repositories, as well as functions such as code review, project management, activity tracking, and continuous integration / continuous deployment (CI / CD) pipelines.

[0024] Continuous integration: Continuously update pipeline scripts and plugins, and continuously optimize the automatic scanning process.

[0025] In one or more embodiments, when a new merge request is detected in the code repository, a trigger request is sent to the continuous integration server via a pre-configured Webhook mechanism.

[0026] The webhooks mentioned above are user-defined HTTP callbacks, typically triggered by events such as pushing code to a repository or creating a merge request. When this event occurs, the source application sends an HTTP request to the URI configured for the webhook. A common use case is to trigger builds in continuous integration systems or to notify bug tracking systems.

[0027] S200, the pipeline task automatically pulls and merges the source code corresponding to the request.

[0028] In one or more embodiments, to facilitate timely understanding of code verification and merge control status by relevant personnel, the pipeline task automatically pulls the source code corresponding to the merge request and simultaneously obtains the identity information of the merge request submitter. Upon completion of the pipeline task, the continuous integration server automatically sends a notification message containing the pipeline execution log and a summary of the verification results to the merge request submitter based on the identity information. This provides an effective notification and feedback mechanism.

[0029] The aforementioned identity information includes, but is not limited to, the email address and personal ID of the person submitting the merge request.

[0030] S300. Based on the source code's project and its corresponding compilation toolchain information, select or build a matching containerized verification environment.

[0031] It should be noted that the above projects have pre-defined project management personnel, usually project managers, who are pre-configured within the project. The merge requester automatically obtains the verification results and pipeline logs, and then sends them to the merge requester's email address, as well as the project manager's email address.

[0032] In one or more embodiments, the containerized verification environment includes static code verification tools, a build toolchain, and verification rule files. The static code verification tools, build toolchain, and verification rule files are installed or copied via an image.

[0033] It's understandable that containers are generated from Docker images, and that static code verification tools, build toolchains, and verification rule files are installed or copied within the image. Containerized environments are characterized by fast startup, multiple instances, and short lifecycles.

[0034] In a containerized environment, the core of verification is to ensure compliant environment configuration, controlled resource usage, stable application performance, and effective enforcement of security policies. This is typically achieved through continuous verification using automated static code analysis tools, build toolchains, and verification rule files. The corresponding static code analysis tools, build toolchains, and verification rule files are installed in a Docker image (an open-source containerization platform). The image then generates a container, which is deleted after the code scan is complete, thus not occupying any space.

[0035] S400: Perform static code verification in a containerized verification environment to generate a verification result file containing multiple verification issues.

[0036] The specific verification result files are "Manager Report" report.html and "Developer Report" report_dev1.html.

[0037] S500: Parse the verification result file and, according to the preset severity mapping rules, aggregate the verification issues from the original severity level into multiple levels.

[0038] In a specific embodiment, a severity mapping rule is as follows: The original severity levels of Severity 1 and Severity 2 are combined into High Severity; the original severity level of Severity 3 is combined into Medium Severity; and the original severity levels of Severity 4 and Severity 5 are combined into Low Severity.

[0039] In one or more embodiments, the original verification issues output by the static code verification tool are divided into multiple severity levels; the pipeline task merges the multiple original severity levels into three categories—high, medium, and low—according to a preset severity mapping rule, and sets an independent quantity threshold for each level, thereby determining whether the pipeline task has failed based on the threshold.

[0040] Furthermore, the verification result file is synchronously uploaded to a centralized quality management server after generation, used for visualization and analysis of the trend of changes in the number of verification issues, severity distribution, and historical data. This, in turn, supports continuous analysis and tracing of code quality trends, enabling efficient centralized management of verification results.

[0041] S600: Count the number of issues to be checked for each severity level and compare them with the pre-set quantity threshold to generate a quality judgment result.

[0042] It should be noted that when the number of generated verification issues for any level exceeds the corresponding threshold, the pipeline task is deemed to have failed.

[0043] Furthermore, the follow-up handling for failures could be: sending a scan report to the submitter of the merge request and the administrator; or, not merging the code corresponding to the failure.

[0044] S700: Based on the quality assessment results, return the pipeline execution status to the code repository. The pipeline execution status is used to control whether the merge request is allowed to perform the merge operation.

[0045] In a specific embodiment, one way to control whether a merge request is allowed to perform a merge operation is: when the pipeline fails and cannot be merged, the "merge" button will not appear on the GitLab "Merge Request" interface.

[0046] In summary, this embodiment ensures that static code verification is performed in a unified environment by building corresponding containerized verification environments for different projects and compilation toolchains, thereby improving the consistency and reproducibility of verification results. By directly linking the verification results to the code repository's merge control process, automatic merge decisions based on quality assessment results are achieved.

[0047] Example 2: like Figure 2 As shown, this embodiment also provides an automatic code verification and quality access control system for implementing the automatic code verification and quality access control method described in Embodiment 1, including: The trigger module is used to trigger continuous integration pipeline tasks via Webhook when a new merge request is detected in the code repository.

[0048] The source code retrieval module is used to control the pipeline tasks to pull and merge the source code corresponding to the code repository.

[0049] The environment selection module is used to select or build the corresponding containerized verification environment based on the source code's project and compilation toolchain information.

[0050] The verification execution module performs static code verification in a containerized verification environment and generates a verification result file containing multiple verification issues.

[0051] The results parsing module is used to parse the verification results file and aggregate the verification issues from the original severity level into multiple levels according to the preset severity mapping rules.

[0052] The quality assessment module is used to count the number of issues to be checked for each severity level, compare them with a pre-set threshold, and generate a quality assessment result.

[0053] The merge control module is used to control the merge permissions of merge requests in the code repository based on the quality assessment results.

[0054] It should be noted that the specific steps and related technical features involved in this embodiment are consistent with those in Embodiment 1.

[0055] Example 3: like Figure 3 As shown, this embodiment also provides an electronic device, including: One or more processors; One or more memories are used to store one or more computer programs, and one or more processors are used to execute the one or more computer programs stored in the memories, so that the one or more processors perform the features / steps of an automatic code verification and quality access control method as described in Embodiment 1.

[0056] Furthermore, at the hardware level, the device includes a processor, an internal bus, a network interface, memory, and non-volatile memory, and may also include other necessary hardware. One or more embodiments of this application can be implemented in software, for example, by the processor reading the corresponding computer program from the non-volatile memory into memory and then running it.

[0057] Of course, in addition to the software implementation, one or more embodiments of this application do not exclude other implementation methods, such as logic devices or a combination of hardware and software. That is to say, the execution subject of the above processing flow is not limited to each logic module, but can also be hardware or logic devices.

[0058] Example 4: Those skilled in the art will understand that all or part of the features / steps of the above-described method embodiments can be implemented by methods, data processing systems, or computer programs. These features may be implemented without hardware, entirely in software, or in a combination of hardware and software. The aforementioned computer program may be stored in one or more computer-readable storage media. When the computer program is executed (e.g., by a processor), it performs the steps of the above-described embodiment of an automatic code verification and quality access control method.

[0059] The aforementioned storage media capable of storing program code include: static disks, solid-state drives, random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), optical storage devices, magnetic storage devices, flash memory, magnetic disks or optical disks, and / or combinations of the above devices, that is, they can be implemented by any type of volatile or non-volatile storage devices or combinations thereof.

[0060] Example 5: This embodiment provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the steps of an automatic code verification and quality access control method as described in Embodiment 1.

[0061] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the processes of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0062] The above description is merely a preferred embodiment of the present invention. Those skilled in the art will understand that various changes or equivalent substitutions can be made to these features and embodiments without departing from the spirit and scope of the present invention. Furthermore, under the teachings of the present invention, these features and embodiments can be modified to adapt to specific situations and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the protection scope of the present invention.

Claims

1. A method for automatic code verification and quality access control, characterized in that, The steps include: When the code repository detects a new merge request, it sends a trigger request to the continuous integration server to start the pipeline task corresponding to the merge request. The pipeline task automatically pulls the source code corresponding to the merge request; Based on the source code's project and its corresponding compilation toolchain information, select or build a matching containerized verification environment; Perform static code verification in the containerized verification environment to generate a verification result file containing multiple verification questions; The verification result file is parsed, and the verification issues are aggregated from their original severity levels into multiple levels according to the preset severity mapping rules; The number of issues to be checked for each severity level is counted and compared with a pre-set quantity threshold to generate a quality judgment result. Based on the quality assessment result, the pipeline execution status is sent back to the code repository. The pipeline execution status is used to control whether the merge request is allowed to perform the merge operation.

2. The method for automatic code verification and quality access control according to claim 1, characterized in that, When the code repository detects a new merge request, a trigger request is sent to the continuous integration server through a pre-configured webhook mechanism.

3. The method for automatic code verification and quality access control according to claim 1, characterized in that, The pipeline task automatically pulls the source code corresponding to the merge request, and at the same time, obtains the identity information of the person who submitted the merge request. Once the pipeline task is completed, the continuous integration server automatically sends a notification message containing the pipeline execution log and a summary of the verification results to the submitter of the merge request based on the identity information.

4. The method for automatic code verification and quality access control according to claim 1, characterized in that, The verification result file is uploaded synchronously to the centralized quality management server after it is generated, and is used to visualize and analyze the trend of the number of verification issues, the distribution of severity, and historical data.

5. The method for automatic code verification and quality access control according to claim 1, characterized in that, The containerized verification environment includes static code verification tools, a compilation toolchain, and verification rule files, which are installed or copied via image.

6. The method for automatic code verification and quality access control according to claim 1, characterized in that, The raw verification issues output by the static code verification tool are divided into multiple severity levels. The pipeline task merges the multiple raw severity levels into three categories: high, medium, and low, according to the preset severity mapping rules, and sets an independent quantity threshold for each level. When the number of generated verification issues corresponding to any level exceeds the corresponding threshold, the pipeline task is judged to have failed.

7. A code automatic verification and quality access control system, characterized in that, A method for implementing an automatic code verification and quality access control system as described in any one of claims 1-6 includes: The trigger module is used to trigger continuous integration pipeline tasks via Webhook when a new merge request is detected in the code repository; The source code acquisition module is used to control the pipeline task to pull the source code corresponding to the merge request from the code repository; The environment selection module is used to select or build the corresponding containerized verification environment based on the project to which the source code belongs and the compilation toolchain information. The verification execution module performs static code verification in the containerized verification environment and generates a verification result file containing multiple verification questions. The result parsing module is used to parse the verification result file and aggregate the verification issues from the original severity level into multiple levels according to the preset severity mapping rules; The quality assessment module is used to count the number of the inspection issues corresponding to each severity level, compare them with a pre-set quantity threshold, and generate a quality assessment result. The merge control module is used to control the merge permissions of the merge requests in the code repository based on the quality assessment results.

8. An electronic device, characterized in that, include: At least one processor; At least one memory used to store processor-executable instructions; The at least one processor executes the executable instructions to implement a code automatic verification and quality access control method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, It stores computer instructions that, when executed by at least one processor, implement a code automatic verification and quality access control method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, It includes a computer program or instructions that, when executed by a processor, implement an automatic code verification and quality access control method as described in any one of claims 1 to 6.