Historical result tracking method and device for code static scanning

By receiving instructions in static code scans, building scanning tasks, storing results using SonarQube and ElasticSearch, comparing and storing differential data, the problem that the existing technology cannot continuously manage multiple scan results is solved, and continuous tracking and monitoring of code quality is achieved , meet the management needs of agile development projects.

CN119065960APending Publication Date: 2024-12-03CHINA PETROLEUM & CHEMICAL CORP +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410969709.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

Existing code static scanning solutions cannot continuously store and track management of multiple scan results, and cannot meet the continuous tracking requirements of agile development projects for code quality.

Method used

By receiving the start command, building a code scanning task, using SonarQube for static code scanning, saving the scan results, comparing the differences from the previous round of results, storing the differential data, and repeating the above steps when necessary, using ElasticSearch and database for information storage and manage.

Benefits of technology

It realizes continuous tracking and monitoring of code quality, meets the management needs of agile development projects, and can dynamically track and monitor defects and vulnerabilities in the code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119065960A_ABST
    Figure CN119065960A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a historical result tracking method and device for code static scanning. The problem that in an existing method, storage and tracking management cannot be continuously conducted on multiple code static scanning results is solved. The historical result tracking method for code static scanning comprises the following steps: receiving a start instruction, constructing a code scanning task, and scanning a code to obtain a current round of code scanning result; storing complete information of the code scanning result of the round; comparing the current round of code scanning result with the previous round of code scanning result to obtain difference data of scanning change; and storing the difference data of the scanning change.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software development, and in particular to a method and device for tracking historical results of static code scanning. Background Art

[0002] The existing static code scanning solution focuses on a single scanning task, using SonarQube to scan the code once and obtain a code quality report at a certain point in time. Since the existing method focuses on a single scanning task, there is no way to track the quality of the code over a period of time. For projects using agile development, the project code will be continuously updated iteratively. When the project performs code scanning, in addition to paying attention to the execution results of this round, it will also pay attention to the difference between the results of this round and the previous round. For such software development projects, code quality management is one of the important components of project management and is a continuous action. The existing solution lacks dynamic associations between multiple scanning results and cannot meet the needs of project management. Summary of the invention

[0003] In view of this, an embodiment of the present invention provides a method and device for tracking historical results of static code scanning, which solves the problem that the existing method cannot continuously store and track the results of multiple static code scanning.

[0004] In a first aspect, an embodiment of the present invention provides a method for tracking historical results of static code scanning, comprising:

[0005] Step 01: Receive the start instruction, build a code scanning task, scan the code, and obtain the results of this round of code scanning.

[0006] Step 02: Save the complete information of the current round of code scanning results;

[0007] Step 03: Compare the difference between the current round code scanning result and the previous round code scanning result to obtain the difference data of the scanning change;

[0008] Step 04: Storing the difference data of the scan changes.

[0009] In one embodiment, scanning the code includes: using SonarQube to perform static code scanning, wherein static code scanning refers to checking for vulnerabilities by scanning source code with a tool without running the program.

[0010] In one implementation, the saving of the complete information of the current round of code scanning results includes: using ElasticSearch to store the complete information of the current round of code scanning results.

[0011] In one embodiment, storing the difference data of the scan changes includes: storing the difference data of the scan changes in a database.

[0012] In one embodiment, after storing the difference data of the scan changes, the method further includes: determining whether it is necessary to continue tracking the historical results of the static code scan, and if so, repeating step 01 to step 04.

[0013] In one embodiment, before receiving the start instruction and constructing the code scanning task, it also includes: developing the code based on agile development.

[0014] In a second aspect, an embodiment of the present invention provides a device for tracking historical results of static code scanning, comprising:

[0015] The instruction receiving module is used to receive the start instruction and build the code scanning task;

[0016] The scanning module is used to scan the code to obtain the current round of code scanning results;

[0017] A scanning result storage module is used to store the complete information of the current round of code scanning results;

[0018] A comparison module, used to compare the difference between the current round code scanning result and the previous round code scanning result to obtain difference data of scanning changes;

[0019] The difference data storage module is used to store the difference data of the scan changes.

[0020] In one embodiment, the device for tracking historical results of static code scanning further includes: a judgment module, which is used to judge whether it is necessary to continue tracking historical results of static code scanning.

[0021] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the above-mentioned method for tracking historical results of static code scanning.

[0022] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by one or more processors, it is used to implement the historical result tracking method of static code scanning described above.

[0023] The embodiment of the present invention provides a method and device for tracking historical results of static code scanning. Through this method, the results of multiple static code scanning are stored and tracked. In agile development software projects, the code quality can be continuously tracked, and the defects and vulnerabilities in the code can be dynamically tracked and monitored, thereby meeting the management requirements of the software project. During the agile development process, the historical information recording and historical information change tracking of the static code scanning are realized, the code quality can be continuously tracked and managed, and the code quality in the entire agile development process can be well monitored and managed. This enables the project team to better manage the code quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 The figure is a flow chart of a method for tracking historical results of static code scanning provided by an embodiment of the present invention.

[0025] Figure 2 FIG. 1 is a schematic diagram of the structure of a device for tracking historical results of static code scanning provided by an embodiment of the present invention. DETAILED DESCRIPTION

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

[0027] The present invention is used in the field of software development (agile development). Its main function is to continuously track the quality of the code and dynamically track and monitor the changes of defects and vulnerabilities in the code, so as to meet the management requirements of the software project. Agile development is one of the industry trends and has a very wide range of applications. Software projects based on agile development can use this method to achieve continuous tracking and management of the quality of the software project code. The specific implementation method is described in the following embodiment.

[0028] This embodiment provides a method for tracking historical results of static code scanning, such as Figure 1 As shown, the historical result tracking method of the code static scanning includes:

[0029] Step 01: Receive the start instruction, build a code scanning task, scan the code, and obtain the results of this round of code scanning.

[0030] Furthermore, scanning the code includes: using SonarQube to perform static code scanning. SonarQube is an automated code review tool that detects and reports defects, vulnerabilities, bad coding habits, and security risks in the code. It can analyze code in multiple programming languages ​​and evaluate code quality and security through a series of rules and indicators to help developers identify and fix potential code problems.

[0031] Step 02: Save the complete information of the current round of code scanning results.

[0032] Furthermore, the storing of the complete information of the current round of code scanning results includes: using ElasticSearch to store the complete information of the current round of code scanning results. ElasticSearch is an open source distributed full-text search and analysis engine developed based on the Apache Lucene search engine library. It can quickly store, search and analyze large amounts of data, and provides powerful search and query functions.

[0033] Step 03: Compare the difference between the current round code scanning result and the previous round code scanning result to obtain the difference data of the scanning change.

[0034] Step 04: Storing the difference data of the scan changes.

[0035] Further, storing the difference data of the scan changes includes: storing the difference data of the scan changes in a database.

[0036] In addition to the above steps, before receiving the start instruction and constructing the code scanning task, the method further includes step 04: developing the code based on agile development, wherein agile development is an iterative, step-by-step development method.

[0037] After storing the difference data of the scan changes, the step 06 is also included: determining whether it is necessary to continue tracking the historical results of the static code scan, and if so, repeating the steps 01 to 04.

[0038] Through the method provided in this embodiment, the storage and tracking management of multiple code static scanning results can be realized, and the code quality can be continuously tracked in agile development software projects, and the defects and vulnerabilities in the code can be dynamically tracked and monitored, thereby meeting the management requirements of the software project. During the agile development process, the historical information recording and historical information change tracking of the code static scanning are realized, and the code quality can be continuously tracked and managed, and the code quality in the whole agile development process can be well monitored and managed. This enables the project team to better manage the code quality.

[0039] This embodiment provides a device 100 for tracking historical results of static code scanning. Figure 2 As shown, the historical result tracking device 100 for static code scanning includes: an instruction receiving module 10, a scanning module 20, a scanning result storage module 30, a comparison module 40 and a difference data storage module 50.

[0040] The instruction receiving module 10 is used to receive a start instruction and construct a code scanning task.

[0041] The scanning module 20 is used to scan the code to obtain the current round of code scanning results.

[0042] The scanning result storage module 30 is used to store the complete information of the current round of code scanning results.

[0043] The comparison module 40 is used to compare the difference between the current round code scanning result and the previous round code scanning result to obtain the difference data of the scanning change.

[0044] The difference data storage module 50 is used to store the difference data of the scan changes.

[0045] In addition, the device for tracking historical results of static code scanning also includes: a judgment module 60. The judgment module 60 is used to judge whether it is necessary to continue tracking historical results of static code scanning. If the judgment result is that it is necessary to continue tracking historical results of static code scanning, the steps 01 to 04 are repeated.

[0046] Furthermore, the scanning module 20 is also used to perform static code scanning using SonarQube.

[0047] Furthermore, the scanning result storage module 30 is also used to use ElasticSearch to store the complete information of the current round of code scanning results.

[0048] Furthermore, the difference data storage module 50 is further configured to store the difference data of the scan changes in a database.

[0049] In addition, the historical result tracking device for static code scanning also includes a development module 70, and the development module 70 is also used to develop the code based on agile development.

[0050] This embodiment provides an electronic device, which may include a memory and a processor, wherein a computer program is stored on the memory, and when the computer program is executed by the processor, the historical result tracking method of static code scanning as described in the above embodiment is implemented. It can be understood that the electronic device may also include an input / output (I / O) interface and a communication component.

[0051] The processor is used to execute all or part of the steps in the historical result tracking method of code static scanning in the embodiment. The memory is used to store various types of data, which may include instructions of any application or method in the electronic device, as well as data related to the application.

[0052] The processor can be an application specific integrated circuit (ASIC), a digital signal processor (DSP), a programmable logic device (PLD), a field programmable gate array (FPGA), a controller, a microcontroller, a microprocessor or other electronic components, and is used to execute the historical result tracking method of static code scanning in the above embodiment.

[0053] The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static 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), magnetic storage, flash memory, magnetic disk or optical disk.

[0054] This embodiment also provides a computer-readable storage medium. Each functional unit in each embodiment of the present invention may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium.

[0055] Based on such understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.

[0056] The aforementioned storage media include: flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, server, APP application store, etc. Various media that can store program verification codes, on which computer programs are stored, and the computer program can implement the above method steps when executed by the processor.

[0057] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0058] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the scheme of this embodiment.

[0059] The basic principles of the present application are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present application are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present application. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, not for limitation, and the above details do not limit the present application to being implemented by adopting the above specific details.

[0060] The block diagrams of devices, apparatuses, equipment, and systems involved in this application are only illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems may be connected, arranged, or configured in any manner.

[0061] It should also be noted that in the apparatus, device and method of the present application, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present application.

[0062] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present application. Therefore, the present application is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

[0063] In the description of the application, the meaning of "multiple" is at least two, for example, two, three, etc., unless otherwise clearly and specifically limited. In the embodiment of the present application, all directional indications (such as up, down, left, right, front, back, top, bottom ...) are only used to explain the relative position relationship, motion conditions, etc. between the components under a certain specific posture (as shown in the drawings). If the specific posture changes, the directional indication also changes accordingly. In addition, the terms "including" and "having" and any of their deformations are intended to cover non-exclusive inclusions. For example, the process, method, system, product or equipment comprising a series of steps or units are not limited to the steps or units listed, but optionally also include the steps or units not listed, or optionally also include other steps or units inherent to these processes, methods, products or equipment.

[0064] In addition, the reference to "embodiment" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0065] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims. The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention. The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for tracking historical results of static code scanning, It is characterized in that include: Step 01: Receive the start instruction, build a code scanning task, scan the code to obtain the results of this round of code scanning; Step 02: Save the complete information of the current round of code scanning results; Step 03: Compare the difference between the current round code scanning result and the previous round code scanning result to obtain the difference data of the scanning change; Step 04: Storing the difference data of the scan changes.

2. The method for tracking historical results of static code scanning according to claim 1, It is characterized in that The scanning of the code includes: using SonarQube to perform static scanning of the code.

3. The method for tracking historical results of static code scanning according to claim 1, It is characterized in that The saving of the complete information of the current round of code scanning results includes: using ElasticSearch to store the complete information of the current round of code scanning results.

4. The method for tracking historical results of static code scanning according to claim 1, It is characterized in that The storing the difference data of the scan changes includes: storing the difference data of the scan changes in a database.

5. The method for tracking historical results of static code scanning according to claim 1, It is characterized in that After storing the difference data of the scan changes, the method further includes: determining whether it is necessary to continue tracking the historical results of the static code scan, and if so, repeating step 01 to step 04.

6. The method for tracking historical results of static code scanning according to claim 1, It is characterized in that Before receiving the start instruction and constructing the code scanning task, the method further includes: developing the code based on agile development.

7. A device for tracking historical results of static code scanning, It is characterized in that include: The instruction receiving module is used to receive the start instruction and build the code scanning task; The scanning module is used to scan the code to obtain the current round of code scanning results; A scanning result storage module is used to store the complete information of the current round of code scanning results; A comparison module, used to compare the difference between the current round code scanning result and the previous round code scanning result to obtain difference data of scanning changes; The difference data storage module is used to store the difference data of the scan changes.

8. The device for tracking historical results of static code scanning according to claim 7, It is characterized in that Also includes: The judgment module is used to judge whether it is necessary to continue tracking the historical results of the static code scan.

9. An electronic device, It is characterized in that It comprises a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein when the one or more computer instructions are executed by the processor, the historical result tracking method of static scanning of codes as described in any one of claims 1-6 is implemented.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by one or more processors, it is used to implement the historical result tracking method of static code scanning according to any one of claims 1 to 6.