Automatic and semi-automatic improvement of remediation strategies for static analysis violations
The system enhances software program repair by refining and user-interactive improvement of repair patterns, effectively addressing uncorrected violations in static code analysis, thereby improving software development efficiency.
Patent Information
- Application Number
- CN202010806722.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-12
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2040-08-12
AI Technical Summary
Existing static code analysis tools struggle to effectively address all detected software program violations, particularly uncorrected or unseen ones, due to insufficient repair patterns and limited repair operations, leading to inefficiencies in software development and performance.
A computing system is configured to execute a training model that improves repair patterns by storing and refining them based on uncorrected violations, removing ineffective patterns, and incorporating user feedback to generate accurate repair strategies for unseen issues.
Enhances the accuracy and effectiveness of software program repair by iteratively improving repair patterns, ensuring a higher success rate in addressing uncorrected violations and reducing development time.
Smart Images

Figure CN114077447B_ABST
Abstract
Description
Technical Field
[0001] Implementations discussed in this disclosure relate to improvements in repair patterns for static analysis violations in software programs. Background Art
[0002] Many new techniques are being developed for software programs to identify and flag suspicious code patterns that may affect the performance and correctness of the software program or violate the style guidelines of the project. Suspicious code patterns or violations may not only affect the operations to be performed by the software program, but may also affect the overall development time of the software program. Certain solutions have been developed to fix different violations identified from various software programs in different fields. Such solutions are referred to as fixes or fix examples that address the corresponding violations.
[0003] The subject matter claimed in this disclosure is not limited to implementations that solve any disadvantages or that operate only in environments such as described above. Rather, this background is provided merely to illustrate one example technology area where some implementations described in this disclosure may be practiced. Summary of the invention
[0004] According to one aspect of the embodiment, an operation may include retrieving a set of repair patterns. Each repair pattern in the set of repair patterns may be learned based on a first set of repair examples associated with a first set of violations of a software program. The operation may also include retrieving a second set of violations of the software program. Each violation in the second set of violations may be an uncorrected violation. The operation may also include: selecting an uncorrected violation of the first software program from the second set of violations of the retrieved software program, and selecting a repair pattern from the set of repair patterns. The operation may also include performing a first set of operations to improve the set of repair patterns. The first set of operations may include applying the selected repair pattern to the selected uncorrected violation to generate a repair result. The first set of operations may also include: determining whether the generated repair result corresponds to a violation, and removing the applied repair pattern from the set of repair patterns based on determining that the generated repair result corresponds to a violation. The first set of operations may also include reselecting the next repair pattern in the set of repair patterns as the selected repair pattern. The operation may also include obtaining an improved set of repair patterns by iteratively performing the first set of operations for the set of repair patterns based on the selected repair pattern.
[0005] The objects and advantages of the embodiments will be realized and achieved by at least the elements, features, and combinations particularly pointed out in the claims.
[0006] Both the foregoing general description and the following detailed description are presented by way of example and are explanatory and are not restrictive of the invention, as claimed. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] Example embodiments will be described and illustrated with additional explanation and detail through the use of the accompanying drawings, in which:
[0008] Figure 1 is a diagram representing an example environment related to improvement of a repair pattern for static analysis violations in a software program;
[0009] Figure 2 is a block diagram illustrating an exemplary electronic device for improving a repair mode for static analysis violations in a software program;
[0010] Figure 3A An example of a defective software program including a violation and a repaired software program is shown;
[0011] Figure 3B An exemplary repair mode for repairing violations in a software program is shown;
[0012] Figure 4 is a flow chart of an example method for improving a repair mode for static analysis violations in a software program;
[0013] Figure 5A and Figure 5B Flowcharts collectively illustrating an example method for improving a repair pattern based on applying the repair pattern to a violation in a software program; and
[0014] Fig. 6A and Figure 6B and a flowchart showing an example method for improving a repair pattern based on human feedback.
[0015] All of these figures are in accordance with at least one embodiment described in the present disclosure. DETAILED DESCRIPTION
[0016] Some embodiments described in the present disclosure relate to improvements in repair patterns for violations that can be identified based on static code analysis of the program code of a software program. Typically, software programs are developed in different domain-specific languages to provide various solutions. During the development or deployment of a software program, multiple problems (e.g., failures, errors, suspicious code, or violations) may be detected. These problems may not only affect the required operation or performance of the software program, but may also affect the total time to complete the development of the software program.
[0017] Some static analyzers or static code analysis tools can be used to automatically detect different violations in software programs. These static code analysis tools can detect one or more syntax violations and / or semantic violations. These static code analysis tools can detect different attributes (e.g., type, line number, node name or node attribute) of the violations identified. In addition, these static code analysis tools can also detect style violations, common software shortcomings, security holes and / or other style criteria violations. The example of static code analyzer or static code analysis tool can include but is not limited to FindBugs, SpotBugs, PMD, Coverity, Facebook Infer, Google error-prone, SonarQube, Splint, cppcheck or Clang static analyzer. Such static code analysis tools can automatically detect violations in software programs using different domain specific languages (DSLs).
[0018] Typically, repair operations or modifications can be used to repair violations and convert a defective software program into an improved software program. As software program development increases, the number of detected violations also increases significantly. However, the number of repair operations is still limited and insufficient compared to the increase in the number of detected violations.
[0019] Certain solutions have been developed that consider several repair operations as repair examples to automatically learn and generate repair strategies (or general repair patterns) through different learning techniques (e.g., machine learning). Such solutions are called repair pattern learning or generation systems based on "Example Programming (PbE)". For example, U.S. Patent Application No. 16 / 109,434, filed on August 22, 2018 (the entire contents of which are incorporated herein by reference), discusses generating and learning correction patterns (hereinafter referred to as repair patterns) based on different detected defects (i.e., violations) in one or more software programs and based on editing operations (i.e., repair examples) associated with the detected defects. It should be noted that the method of generating correction patterns (or repair patterns) by the referenced application is only an example. Nevertheless, there may be different other ways to generate or learn repair patterns based on different repair examples or editing operations performed to repair violations.
[0020] The generated repair pattern can be used to perform repair operations on the defective software program. The repair pattern can also correspond to, summarize or represent one or more editing operations (as repair examples) performed on the detected violation to repair the detected violation or obtain a repaired software program. Similarly, several improved software programs can identify one or more editing operations for different defective software programs (including violations) to learn or generate different repair patterns. The repair pattern can be generated in a format compatible with the source code of the software program including the violation repaired using the repair pattern. In e.g. Figure 3A and Figure 3B Some examples of repair examples and repair patterns are described in detail in.
[0021] The generated repair patterns may be able to repair some reported violations. There may still be some uncorrected or unseen violations that may not have been tested for the generic repair patterns or have not been attempted to be repaired using the generic repair patterns. This may be due to the fact that the number of repair examples is insufficient to generate repair patterns (or repair patterns or repair strategies) that may not be common or sufficient to repair the uncorrected or unseen violations. Therefore, in order to address different uncorrected violations, the automatically generated repair patterns need to be improved or enhanced.
[0022] According to one or more embodiments of the present disclosure, the technical field of software project management including software security, software debugging, and software verification and validation (V&V) can be improved by configuring a computing system in the following manner: the computing system is capable of executing a training model that stores various repair patterns (or strategies) for various uncorrected or unseen violations, and further improving the stored repair patterns based on executing the training model for various uncorrected or unseen violations.
[0023] The system can be configured to retrieve a stored repair pattern that can be generated / learned based on various repair examples. The system can also be configured to retrieve a set of uncorrected violations from a database, and apply each of the repair patterns retrieved to each of the uncorrected violations retrieved. The system can also be configured to determine whether applying each of the repair patterns to each of the uncorrected violations results in the repair of the uncorrected violations. In the case of determining that the repair pattern cannot repair the corresponding uncorrected violation, the determined repair pattern can be removed from the learning system of the repair pattern to obtain an improved repair pattern system. The improved repair pattern can show improved accuracy (or quality) for repairing some uncorrected or newly discovered violations. In some embodiments, the improved system may include a repair pattern that can repair all uncorrected violations of a specific type (as "one best" repair pattern). In another embodiment, the improved system may include a set of repair patterns that are accurate enough to repair a threshold number (e.g., "90%" or more) of violations of a specific type.
[0024] Embodiments of the present disclosure are described with reference to the drawings.
[0025] Figure 1 is a diagram showing an example environment associated with improving a repair mode for static analysis violations in a software program, arranged in accordance with at least one embodiment described in the present disclosure. Figure 1 , an environment 100 is shown. The environment 100 may include an electronic device 102, a database 104, a user end device 106, and a communication network 108. The electronic device 102, the database 104, and the user end device 106 may be communicatively coupled to each other via the communication network 108. Figure 1 1, a set 110 of repair patterns stored in the database 104, a first set 112 of violations, a first set 114 of repair examples, and a second set 116 of violations are also shown. The second set 116 of violations may correspond to unseen or uncorrected violations stored in the database 104. A user 118 who may be associated with or operate the electronic device 102 is also shown. The user 118 may be a person with software development, debugging, or testing experience.
[0026] The electronic device 102 may include appropriate logic, circuitry, and interfaces that may be configured to retrieve a set 110 of repair patterns from the database 104. The set 110 of repair patterns may be learned or generated based on an analysis of a first set 114 of repair examples associated with a first set 112 of violations of a different software program. The first set 112 of violations may correspond to a portion of the defective code for which a set of repair examples 114 are available, thus referred to as fixed violations. The second set of violations may correspond to a portion of the defective code for which no repair examples are available, thus referred to as unfixed violations.
[0027] The first violation set 112 and the second violation set 116 may correspond to faults or errors detected from the software program by various static code analysis tools known in the art. In addition, each of the first violation set 112 and the second violation set may be associated with a violation description and a violation category. Examples of violation descriptions and associated violation categories are provided in Table 1, as follows:
[0028]
[0029]
[0030] Table 1: Example violation descriptions and categories
[0031] The electronic device 102 may be configured to retrieve a second set of violations 116 (i.e., uncorrected or unseen violations) from the database 104 and apply each repair pattern in the retrieved set of repair patterns 110 to the second set of violations 116. The electronic device 102 may be configured to determine whether the set of repair patterns 110 automatically learned from the first set of repair examples 114 is able to repair or resolve each violation in the second set of violations 116 stored in the database 104. The electronic device 102 may be configured to determine a repair pattern from the set of repair patterns 110 that is unable to repair each violation in the second set of violations 116. The electronic device 102 may also be configured to remove the determined repair pattern and further improve the set of repair patterns 110 based on removing the determined repair pattern. In some embodiments, the second set of violations 116 (i.e., to which the set of repair patterns 110 are applied for improvement) may correspond to violations of the same type or category. Examples of types of violations may include, but are not limited to, NULL pointer dereference, out-of-bounds, security issues or malicious code vulnerabilities, dodgy code, performance issues, and code specifications.
[0032] In one or more embodiments, the electronic device 102 may be configured to generate various repair examples by applying different repair patterns to the second violation set 116 (i.e., uncorrected violations). The electronic device 102 may also be configured to receive user input from the user 118. The user input may be a selection of one or more of the generated repair examples. The electronic device 102 may be configured to add the selected repair example as a repair pattern to the first repair example set 114 to further improve the repair pattern based on human feedback or selection.
[0033] Examples of electronic device 102 may include, but are not limited to, integrated development environment (IDE) devices, software testing devices, mobile devices, desktop computers, laptop computers, computer workstations, computing devices, mainframes, servers (e.g., cloud servers), and server groups. In one or more embodiments, electronic device 102 may include a user-side terminal device and a server communicatively coupled to the user-side terminal device. Examples of user-side terminal devices may include, but are not limited to, mobile devices, desktop computers, laptop computers, and computer workstations. Electronic device 102 may be implemented using hardware including a processor, a microprocessor (e.g., to execute or control the execution of one or more operations), a field programmable gate array (FPGA), or an application specific integrated circuit (ASIC). In some other cases, electronic device 102 may be implemented using a combination of hardware and software.
[0034] In one or more embodiments, the electronic device 102 may include a neural network or a machine learning system that is trained to automatically learn and generate a set 110 of repair patterns based on the generated repair examples that repair one or more violations in the second violation set 116 (uncorrected violations). Examples of neural networks may include, but are not limited to, a deep neural network (DNN), a recurrent neural network (RNN), an artificial neural network (ANN), a convolutional neural network (CNN), a CNN recurrent neural network (CNN-RNN), R-CNN, a RNN-based long short-term memory (LSTM) network, a fully connected neural network, a RNN-based connection temporal classification (CTC), a deep Bayesian neural network, a generative adversarial network (GAN), and / or a combination of such networks.
[0035] The database 104 (e.g., Big Code) may include appropriate logic, interfaces, and / or code that may be configured to store the set of repair patterns 110, the first set of violations 112, the first set of repair examples 114, and the second set of violations 116 (i.e., uncorrected violations). In some implementations, the database 104 may store different software programs, codes, libraries, applications, scripts, or routines associated with the first set of violations 112, the first set of repair examples 114, and the second set of violations 116.
[0036] The database 104 may be a relational database or a non-relational database. In addition, in some cases, the database 104 may be stored on a server such as a cloud server or may be cached and stored on the electronic device 102. The server of the database 104 may be configured to receive a request to provide data, violations, or programs from the electronic device 102 via the communication network 108. In response, the server of the database 104 may be configured to retrieve the data, violations, or programs based on the received request and provide them to the electronic device 102 via the communication network 108. Additionally or alternatively, the database 104 may be implemented using hardware including a processor, a microprocessor (e.g., to execute or control the execution of one or more operations), a field programmable gate array (FPGA), or an application specific integrated circuit (ASIC). In some other cases, the database 104 may be implemented using a combination of hardware and software.
[0037] The client device 106 may include appropriate logic, circuitry, interfaces, and / or code in which the generated or improved set 110 of repair patterns may be deployed. The client device 106 may include one or more of the following: an integrated development environment (IDE), a code editor, a software debugger, a software development kit, or a testing application that may recommend and / or apply the deployed set 110 of repair patterns to a user 118 to repair different violations that may be identified in a software program during various software development phases, particularly during code testing or verification and validation (V&V) phases. Examples of client devices 106 may include, but are not limited to, mobile devices, desktop computers, laptop computers, computer workstations, computing devices, mainframes, servers such as cloud servers, and server groups. Although in Figure 1 In the embodiment, the user terminal device 106 is separated from the electronic device 102; however, in some embodiments, the user terminal device 106 can be integrated with the user terminal device 102 without departing from the scope of the present disclosure.
[0038] The communication network 108 may include a communication medium through which the electronic device 102 can communicate with a server and a user device 106 that can store the database 104. Examples of the communication network 108 may include, but are not limited to, the Internet, a cloud network, a wireless fidelity (Wi-Fi) network, a personal area network (PAN), a local area network (LAN), and / or a metropolitan area network (MAN). Various devices in the environment 100 may be configured to connect to the communication network 108 according to various wired and wireless communication protocols. Examples of such wired and wireless communication protocols may include, but are not limited to, at least one of the transmission control protocol and Internet protocol (TCP / IP), the user datagram protocol (UDP), the hypertext transfer protocol (HTTP), the file transfer protocol (FTP), ZigBee, EDGE, IEEE 802.11, light fidelity (Li-Fi), 802.16, IEEE 802.11s, IEEE 802.11g, multi-hop communication, a wireless access point (AP), inter-device communication, a cellular communication protocol, and / or a Bluetooth (BT) communication protocol, or a combination thereof.
[0039] The Figure 1 The environment 100 may include more or fewer elements than those shown and described in the present disclosure. For example, in some embodiments, the environment 100 may include the electronic device 102, but not the database 104 and the user-end device 106. In addition, in some embodiments, the functionality of each of the database 104 and the user-end device 106 may be incorporated into the electronic device 102 without departing from the scope of the present disclosure.
[0040] Figure 2 is a block diagram illustrating an exemplary electronic device configured to improve a repair mode for static analysis violations in a software program according to at least one embodiment described in the present disclosure. Figure 1 Elements to illustrate Figure 2 . Reference Figure 2 , a block diagram 200 of the electronic device 102 is shown. The electronic device 102 may include a processor 204, a memory 206, a permanent data storage device 208, an input / output (I / O) device 210, a display screen 212, and a network interface 214.
[0041] The processor 204 may include appropriate logic, circuitry, and / or interfaces that may be configured to execute program instructions associated with different operations to be performed by the electronic device 102. For example, some operations may include: retrieving the set of repair patterns 110 and the second set of violations 116 from the database 104, applying the set of repair patterns 110 to the second set of violations 116, generating repair examples, receiving user input to select one or more generated repair examples, and further improving the set of repair patterns 110 based on the application and selection. The processor 204 may include any suitable special or general purpose computer, computing entity, or processing device including various computer hardware or software modules, and may be configured to execute instructions stored on any applicable computer-readable storage medium. For example, the processor 204 may include a microprocessor, a microcontroller, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or any other digital or analog circuit configured to interpret and / or execute program instructions and / or process data.
[0042] Despite Figure 2 204 is shown as a single processor, but the processor 204 may include any number of processors configured to individually or collectively perform or direct the execution of any number of operations of the electronic device 102 as described in the present disclosure. In addition, one or more of the processors may be present on one or more different electronic devices (e.g., different servers). In some embodiments, the processor 204 may be configured to interpret and / or execute program instructions and / or process data stored in the memory 206 and / or the permanent data storage device 208. In some embodiments, the processor 204 may extract program instructions from the permanent data storage device 208 and load the program instructions into the memory 206. After the program instructions are loaded into the memory 206, the processor 204 may execute the program instructions. Some examples of the processor 204 may be a GPU, a CPU, a RISC processor, an ASIC processor, a CISC processor, a coprocessor, and / or a combination thereof.
[0043] The memory 206 may include appropriate logic, circuits, interfaces and / or codes that can be configured to store program instructions that can be executed by the processor 204. In some embodiments, the memory 206 may be configured to store an operating system and associated specific application information. The memory 206 may include a computer-readable storage medium for carrying or storing computer-executable instructions or data structures. Such a computer-readable storage medium may include any available medium that can be accessed by a general-purpose or special-purpose computer (e.g., processor 204). As an example and not limitation, such a computer-readable storage medium may include a tangible or non-transient computer-readable storage medium, including a random access memory (RAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a compact disk read-only memory (CD-ROM) or other optical disk storage devices, magnetic disk storage devices or other magnetic storage devices, flash memory devices (e.g., solid-state memory devices) or any other storage medium that can be used to carry or store specific program codes in the form of computer-executable instructions or data structures and can be accessed by a general-purpose or special-purpose computer. The above combination may also be included in the scope of the computer-readable storage medium. For example, computer-executable instructions may include instructions and data configured to cause the processor 204 to perform a particular operation or group of operations associated with the electronic device 102 .
[0044] The persistent data storage device 208 may include suitable logic, circuitry, interfaces, and / or code that may be configured to store program instructions, operating system, and / or application-specific information (e.g., logs), and application-specific databases that may be executed by the processor 204. The persistent data storage device 208 may include a computer-readable storage medium for carrying or having computer-executable instructions or data structures stored thereon. Such computer-readable storage media may include any available media that may be accessed by a general or special purpose computer (e.g., the processor 204).
[0045] By way of example and not limitation, such computer-readable storage media may include tangible or non-transitory computer-readable storage media, including compact disk read-only memory (CD-ROM) or other optical disk storage devices, magnetic disk storage devices or other magnetic storage devices (e.g., hard disk drives (HDD)), flash memory devices (e.g., solid-state drives (SSD), secure digital (SD) cards, other solid-state memory devices), or any other storage medium that can be used to carry or store specific program code in the form of computer-executable instructions or data structures and can be accessed by general-purpose or special-purpose computers. Combinations of the above may also be included within the scope of computer-readable storage media. For example, computer-executable instructions may include instructions and data configured to cause the processor 204 to perform a specific operation or group of operations associated with the electronic device 102.
[0046] In some embodiments, any one or a combination of the memory 206, the persistent data storage device 208 can store the set of repair patterns 110 retrieved from the database 104 and the second set of violations 116. In some embodiments, any one or a combination of the memory 206, the persistent data storage device 208 can store one or more repair examples generated during the application of the set of repair patterns 110 to the second set of violations 116 (i.e., uncorrected violations). In some embodiments, any one or a combination of the memory 206, the persistent data storage device 208 can store a neural network to learn more repair patterns based on the generated repair examples to repair one or more violations in the second set of violations 116.
[0047] The I / O device 210 may include appropriate logic, circuitry, interfaces, and / or code that may be configured to receive user input (e.g., user input for selecting a generated repair example). The I / O device 210 may also be configured to provide output in response to the user input. The I / O device 210 may include various input and output devices that may be configured to communicate with the processor 204 and other components (e.g., a network interface 214). Examples of input devices may include, but are not limited to, a touch screen, a keyboard, a mouse, a joystick, and / or a microphone. Examples of output devices may include, but are not limited to, a display and a speaker.
[0048] The display screen 212 may include appropriate logic, circuitry, interfaces and / or code that may be configured to present the generated repair examples to the user 118 for selecting one or more repair examples as repair patterns for improving the set 110 of repair patterns. The display screen 212 may be configured to receive user input from the user 118 to select one or more repair examples. In such a case, the display screen 212 may be a touch screen that receives user input. The display screen 212 may be implemented by several known technologies, such as, but not limited to, liquid crystal display (LCD) display technology, light emitting diode (LED) display technology, plasma display technology, and / or organic LED (OLED) display technology and / or other display technology.
[0049] The network interface 214 may include suitable logic, circuitry, interfaces and / or code that may be configured to establish communication between the electronic device 102, the database 104 and the user end device 106 via the communication network 108. The network interface 214 may be implemented using various known technologies to support wired or wireless communication of the electronic device 102 via the communication network 108. The network interface 214 may include, but is not limited to, an antenna, a radio frequency (RF) transceiver, one or more amplifiers, a tuner, one or more oscillators, a digital signal processor, a coder-decoder (CODEC) chipset, a subscriber identity module (SIM) card and / or a local buffer.
[0050] The network interface 214 can communicate with a network such as the Internet, an intranet, and / or a wireless network such as a cellular telephone network, a wireless local area network (LAN), and / or a metropolitan area network (MAN) via wireless communication. The wireless communication can use any of a variety of communication standards, protocols, and technologies, such as, for example, Global System for Mobile Communications (GSM), Enhanced Data GSM Environment (EDGE), Wideband Code Division Multiple Access (W-CDMA), Long Term Evolution (LTE), Code Division Multiple Access (CDMA), Time Division Multiple Access (TDMA), Bluetooth, Wireless Fidelity (Wi-Fi) (e.g., IEEE 802.11a, IEEE 802.11b, IEEE 802.11g, and / or IEEE 802.11n), Voice over Internet Protocol (VoIP), Light Fidelity (Li-Fi), or Wi-MAX.
[0051] Without departing from the scope of the present disclosure, modifications, additions, or omissions may be made to the example electronic device 102. For example, in some implementations, the example electronic device 102 may include any number of additional components that may not be expressly shown or described for the sake of brevity.
[0052] Figure 3A An example of a defective software program including a violation and a repaired software program is shown in accordance with at least one embodiment described in the present disclosure. Figure 1 and Figure 2 Element Description Figure 3A . Reference Figure 3A, an example of a defective software program 302 is shown. The defective software program 302 may include code, scripts, or routines associated with a domain specific language (DSL) (e.g., Java). The defective software program 302 may include a violation at a master node 306 (e.g., "doc.get(field);" as shown). The violation may represent a fault or error that may affect the performance of the defective software program 302. In some embodiments, the defective software program 302 may include multiple violations including a violation at the master node 306. Violations may be identified by static code analysis tools known in the art. The violation may also correspond to the location of the violation detected in the defective software program 302. The location of the violation may be referred to as a master node 306 (or main node), relative to which different editing nodes may be identified or different editing operations may be performed.
[0053] exist Figure 3A , an improved software program 304 is also shown. The improved software program 304 may be a repaired version of the defective software program 302. The defective software program 302 may be repaired based on the repair example applied to the defective software program 302 to obtain the improved software program 304. The repair example may correspond to one or more editing operations performed on the defective software program 302 in order to obtain the improved software program 304. Figure 3A , a set of edit nodes 308A to 308D is shown. Also shown is a set of edit operations (i.e., modifications or transformations performed on one or more instructions / commands) performed on the set of edit nodes 308A to 308D of the defective software program 302 in order to obtain the improved software program 304. In general, the edit operation for a given edit node may correspond to one or more of the following: replacement / exchange, additional code, correction, new addition, deletion, position shift, or other modification of a portion of the code associated with the given edit node. For example, Figure 3A As shown, the first edit operation ("Map.Entry<String,Object> entry”) can be added to the first edit node 308A, the second operation (“doc.entrySet()”) can be modified at the second edit node 308B, the third edit operation (“String field=entry.getKey();”) can be added to the third edit node 308C, and the fourth edit operation (“entry.getValue();”) can be added to the fourth edit node 308D (or the main node 306).
[0054] exist Figure 3A, a set of locators 310A to 310C is also shown, which can indicate the relationship between the main node 306 of the violation and each of the edit nodes 308A to 308D (i.e., the location where the code must be repaired). In some embodiments, the set of locators 310A to 310C or the relationship between the main node 306 and the edit nodes 308A to 308D can be analyzed to generate a set of repair patterns 110 (also called correction patterns). The generated set of repair patterns 110 can indicate the edit nodes 308A to 308D and the corresponding editing operations to repair the violation and obtain the improved software program 304.
[0055] Figure 3B An exemplary repair mode for repairing violations in a software program is shown according to at least one embodiment described in the present disclosure. Figure 1 , Figure 2 and Figure 3A Elements to illustrate Figure 3B . Reference Figure 3B , an example of a first software program 312 is shown. The first software program 312 may include a violation at the master node 314 (as shown in “insQueries.get(name)”). The violation may be detected from the first software program 312 using a static code analysis tool on the first software program 312. Figure 3B , a second software program 316 is also shown. The second software program 316 may correspond to a first repair mode or (correction mode) generated based on identifying the edit node and the edit operation performed on the edit node. Figure 3B As shown, the second software program 316 may include a first edit node 320, at which a first edit operation (as shown as "String name = entry.getKey()") may be performed. The first edit node 320 may be located at a line before the first parent node 318 (i.e., defined by "if (!params.isEmpty()){") of the offending statement at the main node 314 in the second software program 316. Therefore, a first repair pattern may be generated based on the main node 314, the first parent node 318, and the first edit node 320. The second software program 316 may indicate an edit operation ("entry.getValue()") at the main node 314.
[0056] The first repair mode may correspond to a first locator, which may represent a relationship between the main node 314 and the first edit node 320, such as Figure 3BAs shown in the second software program 316 of FIG. 314 , the first edit node 320 may be at a line before the first parent node 318 of the statement at the main node 314. The edit operation (i.e., “String name=entry.getKey()”) performed on the first edit node 320 may be further analyzed by a static code analyzer tool to confirm the repair of the violation 314.
[0057] exist Figure 3B , a third software program 322 that can be repaired based on the second repair mode is also shown. For example, in the case where the static code analysis of the second software program 316 indicates a violation, the second locator can be identified as the second repair mode. The second locator can represent the relationship between the main node 314 and an edit node (not shown), which can be at the start position of the body of the second parent node, and the second parent node can be before the first parent node 318 of the statement of the violation at the main node 314. As shown, since the second parent node of the statement does not exist in the third software program 322, the static code analysis tool can mark the violation after analyzing the third software program 322.
[0058] exist Figure 3B , a fourth software program 324 that can be repaired based on the third repair mode is also shown. The third repair mode can indicate a third locator as a relationship between the main node 314 and the second edit node 328. For example, the third repair mode can indicate the following processing: identifying the first parameter 326 ("name") of the violation at the main node 314, and further declaring the first parameter 326 ("String name = entry.getKey()") at the second edit node 328 as an edit operation, and the second edit node 328 can be at the beginning position of the body of the first parent node 318 of the violation statement at the main node 314.
[0059] It can be noted here that Figure 3B The first repair mode, the second repair mode, and the third repair mode described in the above may be provided as examples only. However, without departing from the scope of the present disclosure, there may be several types of repair modes to define edit nodes and edit operations performed at corresponding edit nodes.
[0060] Figure 4 is a diagram of an example method for improving a repair mode for static analysis violations in a software program according to at least one embodiment described in the present disclosure. Figure 1 , Figure 2 , Figure 3A and Figure 3B Element Description Figure 4 . Reference Figure 4, a flowchart 400 is shown. The method shown in flowchart 400 can start at 402 and can be performed by any suitable system, device, or apparatus (e.g., by Figure 1 or Figure 2 Although shown with separate blocks, the steps and operations associated with one or more of the blocks in flowchart 400 may be divided into additional blocks, combined into fewer blocks, or eliminated depending on the specific implementation.
[0061] At block 402, a set of repair patterns 110 may be retrieved. In some implementations, the processor 204 may be configured to retrieve the set of repair patterns 110 from the database 104. In another implementation, the processor 204 may retrieve the set of repair patterns 110 stored in any one of the memory 206, the persistent data storage device 208, or a combination thereof. The set of repair patterns 110 may be learned or generated based on a first set of repair examples 114 (or edit operations) that can repair a first set of violations 112. In some implementations, the processor 204 may be configured to retrieve the first set of violations 112 and the first set of repair examples 114 from the database 104, and automatically generate the set of repair patterns 110 based on an analysis of the first set of repair examples 114.
[0062] At block 404, a second set of violations 116 (i.e., unseen or uncorrected violations) is retrieved. In some implementations, the processor 204 may be configured to retrieve the second set of violations 116 from a database 104 stored in the memory 206 and / or the persistent data storage device 208. The second set of violations 116 may be faults or errors of the software program that have not been repaired using a repair example or edit operation that repairs the violations. In some implementations, all violations in the second set of violations 116 may have the same violation type.
[0063] At block 406, each repair pattern in the set of repair patterns 110 may be applied to each violation in the second set of violations 116. In some implementations, the processor 204 may be configured to execute or apply each repair pattern in the set of repair patterns 110 to each violation in the retrieved second set of violations 116. The processor 204 may be configured to apply a different repair pattern or edit operation defined by the set of repair patterns 110 to the second set of violations 116 (uncorrected violations) to repair the second set of violations 116. Figure 3B Some examples of set 110 of repair patterns are described in .
[0064] At block 408, the set of repair patterns 110 may be refined. The processor 204 may determine a repair pattern for the second set of violations 116 that fails to repair every violation or a threshold number (e.g., greater than "90%) of the violations in the second set of violations 116. The processor 204 may be configured to determine a repair pattern from the set of repair patterns 110 based on applying the set of repair patterns 110 to the second set of violations 116 according to block 406.
[0065] The processor 204 may also be configured to remove or delete a determined repair pattern from the set 110 of repair patterns because the determined repair pattern cannot repair one or more uncorrected violations in the second violation set 116. The processor 204 may be configured to improve the set 110 of repair patterns based on removing the determined repair pattern from the set 110 of repair patterns. Thus, the processor 204 of the disclosed electronic device 102 is able to determine whether the set 110 of repair patterns automatically learned based on the set 110 of repair patterns is also able to repair uncorrected or unseen violations (i.e., the second violation set 116). If not, such repair patterns are also removed to improve the set 110 of repair patterns, so that the improved set of repair patterns provides improved accuracy for repairing violations in the software program. In some embodiments, the improved set of repair patterns may include a repair pattern (as a "best" repair pattern) that is able to repair all uncorrected violations of a particular type.
[0066] At block 410, one or more repair examples may be generated based on applying the set of repair patterns 110 to the second set of violations 116. In some embodiments, the processor 204 may be configured to generate a repair result based on applying each repair pattern in the set of repair patterns 110 to each violation in the second set of violations 116. The repair result may indicate whether a corresponding uncorrected violation is repaired or resolved by applying a repair pattern in the set of repair patterns 110. In some embodiments, the static code analysis tool may generate a repair result (i.e., a repair or violation) based on an analysis of a software program obtained by applying each repair pattern in the set of repair patterns 110 to each violation in the second set of violations 116. In the case of determining that the corresponding uncorrected violation is repaired, the processor 204 may be configured to generate a repair example associated with the corresponding uncorrected violation that is repaired (i.e., different from the first set of repair examples 114). Therefore, the processor 204 may generate a second set of repair examples by iteratively executing or applying the set of repair patterns 110 to the second set of violations 116.
[0067] At block 412, user input may be received to select one or more repair examples from the second set of repair examples. In some implementations, the processor 204 may be configured to receive user input from the user 118 via the I / O device 210 or the display screen 212. The processor 204 may be configured to select one or more repair examples from the second set of repair examples (as generated at block 412).
[0068] At block 414, the set of repair patterns 110 may be improved based on the user input. In some implementations, the processor 204 may be configured to further improve the set of repair patterns 110 (as previously improved at block 408). The processor 204 may add the selected one or more repair examples (as additional repair patterns or strategies) to the improved set of repair patterns 110 based on the user input received from the user 118 at block 412. Thus, the improvement of the set of repair patterns 110 may be further based on intervention or feedback received from the user 118 (e.g., an experienced software developer).
[0069] At box 416, the improved set of repair patterns 110 can be applied to the newly received or discovered violation. In some embodiments, the processor 204 can be configured to retrieve or receive the newly discovered violation from the database 104. The newly discovered violation can be included in the second software program. The processor 204 can also be configured to apply the improved set of repair patterns 110 (as improved at boxes 408 and boxes 414) to the newly received violation to repair the newly discovered violation or further test whether the improved set of repair patterns 110 can be used to repair the newly discovered violation in the database 104. In the case of repair, applying the improved set of repair patterns 110 to the newly received violation can generate a repaired second software program. Therefore, the improvement of the set of repair patterns 110 due to one or a combination of uncorrected violations, human feedback or newly discovered violations can improve the accuracy or quality of the set of repair patterns 110 learned to repair uncorrected violations. Control can end.
[0070] Although flowchart 400 is shown as discrete operations, such as 402, 404, 406, 408, 410, 412, 414, and 416. However, in some embodiments, such discrete operations may be divided into additional operations, combined into fewer operations, or eliminated depending on the specific implementation without departing from the essence of the disclosed embodiments.
[0071] Figure 5A and Figure 5B1 and 2 collectively illustrate a flow chart of an example method for improving a repair mode based on applying a repair mode to a violation in a software program according to at least one embodiment described in the present disclosure. Figure 1 , Figure 2 , Figure 3A , Figure 3B and Figure 4 Elements to illustrate Figure 5A and Figure 5B . Reference Figure 5A and Figure 5B , a flowchart 500 is shown. The method shown in flowchart 500 can start at 502 and can be performed by any suitable system, device, or apparatus (e.g., by Figure 1 or Figure 2 Although shown with separate blocks, the steps and operations associated with one or more of the blocks in flowchart 500 may be divided into additional blocks, combined into fewer blocks, or eliminated depending on the specific implementation.
[0072] At block 502, a set of repair patterns 110 and a second set of violations 116 may be retrieved from the database 104. In some implementations, the processor 204 may be configured to retrieve a set of repair patterns 110 (or corrected patterns) and a second set of violations 116 (uncorrected violations) from the database 104 as described in blocks 402 and 404.
[0073] At block 504, it may be determined whether the number or size of the set 110 of repair patterns is equal to "1". The processor 204 may be configured to determine whether the number or size of the set 110 of repair patterns is "1". In the case where the determined number is "1", there may be only one repair pattern available or generated based on the first set of repair examples 114. Therefore, it may not be possible to further improve one repair pattern, control ends, and no further improvement is performed. Otherwise, control proceeds to block 506.
[0074] At block 506, an uncorrected violation (e.g., a first uncorrected violation) may be selected from the second set of violations 116. In some implementations, the processor 204 may be configured to select the first uncorrected violation from the second set of violations 116 retrieved from the database 104. The selected first uncorrected violation may be associated with a particular software program in a particular DSL.
[0075] At block 508, a repair mode (eg, a first repair mode) may be selected from the set 110 of repair modes (as retrieved from the database 104 in block 502). In some implementations, the processor 204 may be configured to select the first repair mode from the set 110 of repair modes.
[0076] At block 510, the selected repair mode may be applied to the selected uncorrected violation. The processor 204 may be configured to apply or execute the repair mode selected from the set of repair modes 110 to the selected uncorrected violation to repair or resolve the selected uncorrected violation of the software program. The selected repair mode may correspond to one or more editing operations that may be applied to the selected uncorrected violation, such as in Figure 3A and Figure 3B Described in detail in .
[0077] At block 512, a repair result may be generated based on applying the selected repair mode to the selected uncorrected violation. In some implementations, the processor 204 may be configured to generate the repair result to determine whether the selected repair mode is able to repair the selected uncorrected violation. In another implementation, the repair result is generated using a static code analysis tool associated with the disclosed electronic device 102.
[0078] At block 514, it may be determined whether the generated repair result corresponds to a violation or a repair of the selected uncorrected violation. In some implementations, the processor 204 may be configured to determine whether the repair result generated at block 512 corresponds to a violation. In the event that the repair result corresponds to a violation, this indicates that the applied repair mode cannot repair the selected uncorrected violation. Control passes to block 516. Otherwise, in the event that the generated repair result corresponds to a repair of the selected uncorrected violation, control passes to block 518.
[0079] At block 516, the repair pattern that applies to the selected uncorrected violation may be removed from the set of repair patterns 110. In some implementations, the processor 204 may be configured to remove repair patterns (i.e., that cannot repair the selected uncorrected violation) from the set of repair patterns 110 for improving the set of repair patterns 110.
[0080] At block 518, it may be determined whether the set of all repair patterns 110 are applied to the selected uncorrected violation. The processor 204 may be configured to determine whether the set of all repair patterns 110 are applied to the selected uncorrected violation. In the event that the set of all repair patterns 110 are not applied to the selected uncorrected violation, control passes to block 520. Otherwise, control passes to block 522.
[0081] At block 520, a next repair pattern in the set 110 of repair patterns may be selected. In some implementations, the processor 204 may be configured to select a next repair pattern from the set 110 of repair patterns. Control proceeds to block 510 so that each repair pattern in the set 110 of repair patterns may be applied to the selected uncorrected violation. Thus, the operations of blocks 510 to 520 may be iteratively performed by the electronic device 102 or the processor 204 based on applying the set 110 of repair patterns to the selected uncorrected violation.
[0082] At block 522, it may be determined whether all second violation sets 116 have been processed using the set of repair patterns 110. In some implementations, the processor 204 may be configured to determine whether all second violation sets 116 have been processed using the set of repair patterns 110. In the event that all second violation sets have not been processed, control passes to block 524. Otherwise, control passes to block 526.
[0083] At block 524, a next uncorrected violation may be selected from the second set of violations 116. In some implementations, the processor 204 may be configured to select the next uncorrected violation from the second set of violations 116. Control passes to block 508 so that each repair pattern in the set of repair patterns 110 may be applied to each violation in the second set of violations 116. Thus, operations from block 508 to block 524 may be iteratively performed by the electronic device 102 or the processor 204 based on applying the set of repair patterns 110 to the second set of violations 116.
[0084] At block 526, the improved set of repair patterns can be stored and output on the display screen 212. In one embodiment, the improved set of repair patterns can be stored in the memory 206 or the persistent data storage device 208. In some embodiments, the processor 204 can submit the improved set of repair patterns to the database 104. In some embodiments, the improved set of repair patterns can be displayed to the user 118 via the display screen 212. In some embodiments, the improvement of the set of repair patterns 110 performed from block 502 to block 526 can be performed on a second violation set 116 of the same violation type or a different violation type.
[0085] Although flowchart 500 is illustrated as discrete operations, such as 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, and 526. However, in some embodiments, such discrete operations may also be divided into additional operations, combined into fewer operations, or eliminated depending on the particular implementation without departing from the essence of the disclosed embodiments.
[0086] Fig. 6A and Figure 6B 1 and 2 collectively show a flow chart of an example method for improving a repair mode based on human feedback according to at least one embodiment described in the present disclosure. Figure 1 , Figure 2 , Figure 3A , Figure 3B , Figure 4 , Figure 5A and Figure 5B Elements to illustrate Fig. 6A and Figure 6B . Reference Fig. 6A and Figure 6B , a flowchart 600 is shown. The method shown in flowchart 600 can start at 602 and can be performed by any suitable system, device, or apparatus (e.g., by Figure 1 or Figure 2 Although shown with separate blocks, the steps and operations associated with one or more of the blocks in flowchart 600 may be divided into additional blocks, combined into fewer blocks, or eliminated depending on the specific implementation.
[0087] At block 602, the set of repair patterns 110 and the second set of violations 116 may be retrieved from the database 104 (as also performed at block 502). At block 604, as also performed at block 504, it may be determined whether the number or size of the set of repair patterns 110 is equal to "1".
[0088] At block 606, a NULL value may be assigned to the second set of repair examples. The processor 204 may be configured to assign a NULL value to the second set of repair examples (e.g., referred to as "E"). The NULL value may indicate that the second set of repair examples does not include any repair examples. In some implementations, the processor 204 may be configured to initialize the first number or first size of the second set of repair examples to "0".
[0089] At block 608, an uncorrected violation (e.g., a first uncorrected violation) may be selected from the second set of violations 116 (as also performed at block 506). At block 610, a repair mode (e.g., a first repair mode) may be selected from the set of repair modes 110 (as also performed at block 508).
[0090] At block 612, a null value may be assigned to the third set of repair examples. The processor 204 may be configured to assign a null value to the third set of repair examples (e.g., referred to as E'). The null value may indicate that the third set of repair examples does not include any repair examples. In some implementations, the processor 204 may be configured to initialize the second number or second size of the second set of repair examples to "0".
[0091] At block 614, the selected repair mode may be applied to the selected uncorrected violation (as also performed at block 510). At block 616, a repair result may be generated based on applying the selected repair mode to the selected uncorrected violation (as also performed at block 512).
[0092] At block 618, it may be determined whether the generated repair result corresponds to a repair for the selected uncorrected violation. In one embodiment, the processor 204 may be configured to determine whether the generated repair result corresponds to a repair for the selected uncorrected violation. In another embodiment, a static code analysis tool associated with the electronic device 102 may detect whether the generated repair result corresponds to a repair. In the event that the generated repair result corresponds to a repair for the selected uncorrected violation, control proceeds to block 620. Otherwise, control proceeds to block 624.
[0093] At block 620, a repair example associated with the selected uncorrected violation may be generated. In some implementations, the processor 204 may be configured to generate the repair example, which may reference an edit node or one or more edit operations performed on the selected uncorrected violation based on the applied repair mode, resulting in a repair of the selected uncorrected violation.
[0094] At block 622, the generated repair example may be added to a third set of repair examples (referred to as E'). In some implementations, the processor 204 may be configured to add the generated repair example to the third set of repair examples. The processor 204 may also be configured to increase the second number or size of the third set of repair examples by "1".
[0095] At block 624, it may be determined whether all of the sets of repair patterns 110 are applied to the selected uncorrected violation (as also performed at block 518). In the event that all of the sets of repair patterns 110 are not applied to the selected uncorrected violation, control passes to block 626. Otherwise, control passes to block 628.
[0096] At block 626, a next repair pattern in the set of repair patterns 110 may be selected (as also performed at block 520). Control passes to block 614 so that each repair pattern in the set of repair patterns 110 may be applied to the selected uncorrected violation and a third set of repair examples is generated that generates a repair result at block 620 as a repair for the selected uncorrected violation.
[0097] At block 628, a determination may be made as also performed at block 522 whether all second violation sets 116 have been processed using the set of repair patterns 110. In the event that all second violation sets have not been processed, control passes to block 630. Otherwise, control passes to block 636.
[0098] At block 630, (as also performed at block 524) a next uncorrected violation may be selected from the second set of violations 116. At 632, a determination may be made whether a second number (or second size) of the third set of repair examples (referred to as E') is greater than a first number (or first size) of the second set of repair examples (referred to as E). If the second number is less than the first number, control passes to block 610. Otherwise, control passes to block 634.
[0099] At block 634, the second set of repair examples may be assigned a third set of repair examples. In some implementations, the processor 204 may assign the generated repair examples in the third set of repair examples (referred to as E') to the second set of repair examples (referred to as E). The assignment may indicate that when the set 110 of repair patterns is applied to one uncorrected violation, a greater number of repair examples are generated than when applied to other uncorrected violations, and a greater number of repair examples should be considered. This may also indicate identifying the set 110 of repair patterns for which the greatest number of uncorrected violations were successfully repaired. Control proceeds to 610.
[0100] At block 636, user input may be received to select one or more repair examples from the generated second set of repair examples. In some embodiments, the processor 204 (as also performed at block 412) may be configured to receive user input from the user 118 through the I / O device 210 or the display screen 212 to select one or more repair examples. The one or more repair examples selected by the user 118 as human feedback may also be used to improve the set 110 of repair patterns and improve the accuracy of the set 110 of repair patterns based on the human feedback or selection received from the user 118.
[0101] At block 638, the selected one or more repair examples may be added as repair patterns to the set of repair patterns 110 to further improve the set of repair patterns 110. In some implementations, the processor 204 may be configured to add the selected one or more repair examples as repair patterns to the set of repair patterns 110 as an improvement based on human feedback.
[0102] At block 640, the improved set of repair patterns (as also performed at block 526) may be stored and output at display screen 212. Control ends.
[0103] Although flowchart 600 is illustrated as discrete operations, such as 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, and 640. However, in some embodiments, such discrete operations may also be divided into additional operations, combined into fewer operations, or eliminated depending on the particular implementation without departing from the essence of the disclosed embodiments.
[0104] Various embodiments of the present disclosure may provide one or more non-transitory computer-readable storage media configured to store instructions that, in response to being executed, cause a system (e.g., an example electronic device 102) to perform operations. The operations may include retrieving a set of repair patterns, wherein each repair pattern in the set of repair patterns is learned based on a first set of repair examples associated with a first set of violations of a software program. The operations may also include retrieving a second set of violations of the software program, wherein each violation in the second set of violations is an uncorrected violation. The operations may also include: selecting an uncorrected violation of the first software program from the retrieved second set of violations of the software program, and selecting a repair pattern from the set of repair patterns. The operations may also include performing a first set of operations to improve the set of repair patterns. The first set of operations may include applying the selected repair pattern to the selected uncorrected violation to generate a repair result. The first set of operations may also include: determining whether the generated repair result corresponds to a violation, and based on determining that the generated repair result corresponds to a violation, removing the applied repair pattern from the set of repair patterns. The first set of operations may also include reselecting the next repair pattern in the set of repair patterns as the selected repair pattern. The operations may also include obtaining a refined set of repair patterns by iteratively performing a first set of operations on the set of repair patterns based on the selected repair pattern.
[0105] As used in the present disclosure, the term "module" or "component" may refer to a specific hardware implementation configured to perform the actions of a module or component and / or a software object or software routine that may be stored on and / or executed by the general hardware of a computing system (e.g., a computer-readable medium, a processing device, etc.). In some embodiments, the different components, modules, engines, and services described in the present disclosure may be implemented as objects or processes executed on a computing system (e.g., as separate threads). Although some systems and methods described in the present disclosure are generally described as being implemented in software (stored on and / or executed by general hardware), a specific hardware implementation or a combination of software and a specific hardware implementation is also feasible and expected. In this specification, a "computing entity" may be any computing system as previously defined in the present disclosure or any module or combination of modules running on a computing system.
[0106] The terms used in this disclosure and especially in the appended claims (e.g., the bodies of the appended claims) are generally intended to be “open” terms (e.g., the term “including” should be interpreted as “including but not limited to,” the term “having” should be interpreted as “having at least,” the term “comprising” should be interpreted as “including but not limited to,” etc.).
[0107] Additionally, if a specific number of introduced claim recitations is contemplated, such an intent will be expressly recited in the claim, and in the absence of such a recitation, no such intent is present. For example, to aid understanding, the following appended claims may contain the use of the introductory phrases "at least one" and "one or more" to introduce claim recitations. However, the use of such phrases should not be interpreted as implying that a claim recitation introducing the indefinite article "a" or "an" will limit any particular claim containing such introduced claim recitation to embodiments containing only one such recitation, even when the same claim includes the introductory phrases "one or more" or "at least one" and an indefinite article such as "a" or "an" (e.g., "a" and / or "an" should be interpreted to mean "at least one" or "one or more"); the same applies to the use of definite articles used to introduce claim recitations.
[0108] In addition, even if a specific number of an introduced claim recitation is explicitly stated, one skilled in the art will recognize that such recitation should be interpreted to mean at least the recited number (e.g., the unmodified recitation of "two recitations" without other modifiers means at least two recitations, or two or more recitations). Moreover, in those instances where similar conventions like "at least one of A, B, C, etc." or "one or more of A, B, C, etc." are used, generally speaking, such constructions are intended to include A alone, B alone, C alone, A and B together, A and C together, B and C together, or A, B and C together, etc.
[0109] In addition, any disjunctive word or phrase presenting two or more alternative terms, whether in the specification, claims or drawings, should be understood to contemplate the possibility of including one of these terms, any of these terms, or both of these terms. For example, the phrase "A or B" should be understood to include the possibility of "A" or "B" or "A and B".
[0110] All examples and conditional language described in this disclosure are intended for teaching purposes to help readers understand the disclosure and the concepts contributed by the inventors to promote the art, and should be interpreted as not being limited to such specific examples and conditions. Although the embodiments of the disclosure have been described in detail, various changes, substitutions and modifications may be made to the embodiments without departing from the spirit and scope of the disclosure.
Claims
1. A method for improving a repair mode for static analysis violations, comprising: retrieving a set of repair patterns, wherein each repair pattern in the set of repair patterns is learned based on a first set of repair examples associated with a first set of violations of the software program; retrieving a second set of violations for the software program, wherein each violation in the second set of violations is an uncorrected violation; selecting an uncorrected violation of the first software program from the retrieved second set of violations of the software programs; Selecting a repair mode from the repair mode set; Performing a first set of operations for improving the set of repair modes, wherein the first set of operations comprises: applying the selected repair mode to the selected uncorrected violation to generate a repair result, Determine whether the generated repair result corresponds to a violation, Based on determining that the generated repair result corresponds to a violation, removing the applied repair pattern from the set of repair patterns, and reselecting the next repair mode in the repair mode set as the selected repair mode; and An improved set of repair patterns is obtained by iteratively performing the first set of operations on the set of repair patterns based on the selected repair pattern.
2. The method according to claim 1, wherein: The second violation sets have the same violation type.
3. The method according to claim 1, wherein: Each repair mode in the set of repair modes corresponds to one or more editing operations as repair examples, the one or more editing operations being used to repair corresponding violations of the first violation set or the second violation set in the software program.
4. The method according to claim 1, further comprising: for each violation in the retrieved second set of violations of the software program, iteratively performing the first set of operations for the set of repair patterns; as well as The improved set of repair patterns is obtained based on iteratively performing the first set of operations for each violation in the retrieved second set of violations.
5. The method according to claim 1, further comprising: A second set of repair examples is generated by iteratively executing the first set of operations on the set of repair patterns, wherein the first set of operations further includes: determining whether the generated repair result corresponds to a repair of the selected uncorrected violation based on the applied repair mode, generating a repair example associated with the selected uncorrected violation based on determining that the generated repair result corresponds to a repair for the selected uncorrected violation, and The generated repair example is added to the second repair example set.
6. The method according to claim 5, further comprising: receiving a user input for selecting at least one repair example from the generated second set of repair examples; as well as The improved repair pattern set is obtained by adding the selected at least one repair example as a repair pattern to the repair pattern set.
7. The method according to claim 5, further comprising: generating the second set of repair examples by iteratively performing the first set of operations for each violation in a second set of violations of the retrieved software program; receiving a user input for selecting, for each violation in a second set of violations of the retrieved software program, at least one remediation example from the generated second set of remediation examples; as well as The improved repair pattern set is obtained by adding at least one repair example selected for each violation in the retrieved second violation set of the software program as a repair pattern to the repair pattern set.
8. The method according to claim 1, further comprising: receiving a newly discovered violation of a second software program from a database; Applying a repair pattern from the improved set of repair patterns to the received newly discovered violation; as well as A repaired second software program is generated based on applying one of the improved set of repair patterns to the received newly discovered violation.
9. The method according to claim 1, wherein: A second set of violations for the software program is retrieved from the database.
10. One or more non-transitory computer-readable storage media configured to store instructions that, in response to being executed, cause a system to perform operations comprising: retrieving a set of repair patterns, wherein each repair pattern in the set of repair patterns is learned based on a first set of repair examples associated with a first set of violations of the software program; retrieving a second set of violations for the software program, wherein each violation in the second set of violations is an uncorrected violation; selecting an uncorrected violation of the first software program from the retrieved second set of violations of the software programs; Selecting a repair mode from the repair mode set; Performing a first set of operations for improving the set of repair modes, wherein the first set of operations comprises: applying the selected repair mode to the selected uncorrected violation to generate a repair result, Determine whether the generated repair result corresponds to a violation, Based on determining that the generated repair result corresponds to a violation, removing the applied repair pattern from the set of repair patterns, and reselecting the next repair mode in the repair mode set as the selected repair mode; and An improved repair pattern set is obtained by iteratively performing the first set of operations on the repair pattern set based on the selected repair pattern.
11. One or more non-transitory computer-readable storage media according to claim 10, wherein: The second violation sets have the same violation type.
12. The one or more non-transitory computer-readable storage media of claim 10, wherein: Each repair mode in the set of repair modes corresponds to one or more editing operations as the repair examples, the one or more editing operations being used to repair corresponding violations of the first violation set in the software program.
13. The one or more non-transitory computer-readable storage media of claim 10, further comprising: for each violation in the retrieved second set of violations of the software program, iteratively performing the first set of operations for the set of repair patterns; as well as The improved set of repair patterns is obtained based on iteratively performing the first set of operations for each violation in the retrieved second set of violations.
14. The one or more non-transitory computer-readable storage media of claim 10, further comprising: A second set of repair examples is generated by iteratively executing the first set of operations on the set of repair patterns, wherein the first set of operations further includes: determining whether the generated repair result corresponds to a repair of the selected uncorrected violation based on the applied repair mode, generating a repair example associated with the selected uncorrected violation based on determining that the generated repair result corresponds to a repair for the selected uncorrected violation, and The generated repair example is added to the second repair example set.
15. The one or more non-transitory computer-readable storage media of claim 14, further comprising: receiving a user input for selecting at least one repair example from the generated second set of repair examples; as well as The improved repair pattern set is obtained by adding the selected at least one repair example as a repair pattern to the repair pattern set.
16. The one or more non-transitory computer-readable storage media of claim 14, further comprising: generating the second set of repair examples by iteratively performing the first set of operations for each violation in a second set of violations of the retrieved software program; receiving a user input for selecting at least one remediation example from the generated second set of remediation examples for each violation in the retrieved second set of violations of the software program; as well as The improved repair pattern set is obtained by adding at least one repair example selected for each violation in the retrieved second violation set of the software program as a repair pattern to the repair pattern set.
17. The one or more non-transitory computer-readable storage media of claim 10, further comprising: receiving a newly discovered violation of a second software program from a database; Applying a repair pattern from the improved set of repair patterns to the received newly discovered violation; as well as A repaired second software program is generated based on applying one of the improved set of repair patterns to the received newly discovered violation.
18. The one or more non-transitory computer-readable storage media of claim 10, wherein: The second set of violations for the software program is retrieved from a database.
19. An electronic device comprising: A processor configured to: retrieving a set of repair patterns, wherein each repair pattern in the set of repair patterns is learned based on a first set of repair examples associated with a first set of violations of the software program; retrieving a second set of violations for the software program, wherein each violation in the second set of violations is an uncorrected violation; selecting an uncorrected violation of the first software program from the retrieved second set of violations of the software programs; Selecting a repair mode from the repair mode set; Performing a first set of operations for improving the set of repair modes, wherein the first set of operations comprises: applying the selected repair mode to the selected uncorrected violation to generate a repair result, Determine whether the generated repair result corresponds to a violation, Based on determining that the generated repair result corresponds to a violation, removing the applied repair pattern from the set of repair patterns, and reselecting the next repair mode in the repair mode set as the selected repair mode; and An improved repair pattern set is obtained by iteratively performing the first set of operations on the repair pattern set based on the selected repair pattern.
20. The electronic device according to claim 19, wherein: The second set of violations for the software program is retrieved from a database.
Citation Information
Patent Citations
Image retrieval using interactive natural language dialog
CN110297890A
Automatic repair method and system for software code quality problem based on code change history and medium
CN111026433A
Refinement of repair patterns for static analysis violations in software programs
US10782941B1
Data-driven synthesis of fix patterns
US20200065219A1
Detection and correction of coding errors in software development
US20200183818A1