WO2023169368A1 - 一种程序缺陷数据特征提取方法、电子设备及存储介质 - Google Patents

一种程序缺陷数据特征提取方法、电子设备及存储介质 Download PDF

Info

Publication number
WO2023169368A1
WO2023169368A1 PCT/CN2023/079878 CN2023079878W WO2023169368A1 WO 2023169368 A1 WO2023169368 A1 WO 2023169368A1 CN 2023079878 W CN2023079878 W CN 2023079878W WO 2023169368 A1 WO2023169368 A1 WO 2023169368A1
Authority
WO
WIPO (PCT)
Prior art keywords
information
node
program
code
data
Prior art date
Application number
PCT/CN2023/079878
Other languages
English (en)
French (fr)
Inventor
彭星海
薛志宏
程圣宇
曹继承
何美华
熊英飞
朱琪豪
肖元安
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2023169368A1 publication Critical patent/WO2023169368A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/77Software metrics

Definitions

  • the present application relates to the technical field of program repair, and in particular to a method for extracting program defect data features, electronic equipment and storage media.
  • Embodiments of the present application provide a method for extracting program defect data features, an electronic device, and a storage medium.
  • embodiments of the present application provide a method for extracting program defect data features.
  • the method includes: obtaining abstract syntax tree information of program code, wherein the program code includes defective program code and patch code;
  • the abstract syntax tree information is standardized to obtain standardized information; data flow information is obtained according to the standardized information; the standardized information is converted into sequence information; according to the sequence information of the defective program code and the patch code
  • the sequence information is used to obtain program patch information; and the defect data characteristics of the defective program code are extracted according to the data flow information, the sequence information and the program patch information.
  • embodiments of the present application provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the present application is implemented.
  • Example Provided program defect data feature extraction method When the processor executes the computer program, the present application is implemented.
  • embodiments of the present application provide a computer-readable storage medium that stores a computer program.
  • the computer program is executed by a processor, the program defect data feature extraction method provided by the embodiment of the present application is implemented.
  • Figure 1 is a schematic flow chart of a program defect data feature extraction method provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of the implementation process of another embodiment of step S2000 in Figure 1;
  • FIG. 3 is a schematic diagram of the implementation process of another embodiment of step S2300 in Figure 2;
  • FIG. 4 is a schematic diagram of the implementation process of another embodiment of step S3000 in Figure 1;
  • FIG. 5 is a schematic diagram of the implementation process of another embodiment of step S4000 in Figure 1;
  • Figure 6 is a schematic diagram of the implementation process of another embodiment of step S5000 in Figure 1;
  • FIG. 7 is a schematic diagram of the implementation process of another embodiment of step S6000 in Figure 1;
  • Figure 8 is a structural diagram of a program defect data feature extraction device provided by an embodiment of the present application.
  • Figure 9 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • At least one of the following and similar expressions refers to any combination of these items, including any combination of single or plural items.
  • at least one of a, b and c can mean: a, b, c, a and b, a and c, b and c or a and b and c, where a, b, c can be single, also Can be multiple.
  • the program defect data feature extraction method involved in the embodiments of this application is based on the abstract representation of the program code by AST, and then normalizes the AST to extract standardized information that is convenient for neural network reading and analysis.
  • AST expresses the grammatical structure of program code in the form of a tree, and each node on the tree represents a structure in the program code.
  • literals, identifiers, expressions, statements, module syntax, and class syntax have their own ASTs.
  • AST needs to be used in conjunction with DFG to fully characterize program code. Therefore, the method of extracting program defect data features can quickly and accurately extract program patch information and data flow information, which facilitates defect repair and analysis and synthesis operations on program codes, and is especially suitable for automatic analysis of program defects.
  • the existing program defect data feature extraction method is: obtain AST and DFG that characterize program code features, and perform difference search and difference analysis on defective programs and patch programs. This method cannot extract program defect data features based on the characteristics of different programming languages, and because the abstract syntax tree information is not optimized, it cannot achieve efficient and accurate program code features in scenarios where program defects are automatically repaired. analyze.
  • embodiments of the present application provide a method, device, electronic equipment and computer-readable storage medium for extracting program defect data features.
  • the standardized information is obtained; and the standardized information is converted into sequence information.
  • the program patch information is obtained, and finally the defect data characteristics of the defective program code are extracted from the sequence information, program patch information and data flow information to achieve rapid and accurate extraction
  • the purpose of extracting program patch information and data flow information is to improve the efficiency of software defect analysis and user experience.
  • Figure 1 shows the flow of a program defect data feature extraction method provided by an embodiment of the present application.
  • the program defect data feature extraction method according to the embodiment of the present application includes the following steps:
  • the program code includes defective program code and patch code.
  • the process of program defect data feature extraction is to quickly modify the abnormalities and errors in the defective program code by quickly comparing and analyzing the different characteristics between the defective program code and the patch code. Therefore, the defective program code and patch code need to be processed separately to obtain their respective abstract syntax tree information for analysis and processing.
  • the abstract syntax tree information obtained directly from the program code has the characteristics of large amount of information and long processing time.
  • the abstract syntax tree information needs to be refined and optimized, especially in different language environments, to accurately Extract grammatical features of program code.
  • step S2000 at least includes the following steps:
  • S2100 First traverse each abstract syntax tree node of the abstract syntax tree information in order.
  • each abstract syntax tree node needs to be traversed in order to avoid data loss and incorrect contextual relationships.
  • S2200 When syntax information exists in the abstract syntax tree node, create a specification corresponding to the abstract syntax tree node. Normalized node, where the normalized node includes: identification number, parent node pointer, child node pointer and node name. The node name is consistent with the syntax information.
  • a normalized node can be created for the current abstract syntax tree node.
  • create a normalized node to store the identification number, parent node pointer, child node pointer, and node name.
  • the identification number is an integer that numbers the normalized nodes starting from 0 in preorder traversal order.
  • step S2300 includes at least the following steps:
  • the type name is a data type defined by the system or the user, and is the type of value required to be returned during function execution. Therefore, when a type name exists in a node name, a normalization node needs to be inserted between the normalization node and the parent node of the normalization node to record the return value corresponding to the type name.
  • the loop control instruction normalization node must be equipped with a matching loop control sub-node and a condition judgment sub-node to ensure the integrity of data related to the loop control instruction.
  • an identifier is a symbol used to identify an entity and has different meanings in different application environments.
  • identifiers are names used by users when programming. They are used to name variables, constants, functions, statement blocks, etc., to establish a relationship between name and use. Therefore, when the node name has an identifier, it is necessary to create a corresponding child node to record the variables, constants or functions related to it.
  • function instructions often contain various operation objects and conversion relationships.
  • the program code can be segmented according to functions.
  • the embodiment of this application uses a set of simple defect program codes and patch program codes as an example to describe.
  • the program code is as follows:
  • the defective program code implements a function of calculating factorial.
  • the defect is that the variable production is not initialized correctly.
  • the patch code initializes the variable production to 1, fixing the flaw.
  • the node relationships can be recorded using the pre-order traversal sequence and adjacency matrix with backtracking symbols.
  • the first 6 nodes form a sequence of: [function_definition, type, primitive_type, int, ⁇ , ⁇ , ⁇ , declarator, function_declarator]. It can be understood that recording node relationships using a pre-order traversal sequence is a well-known technology, and will not be described again here.
  • an adjacency matrix with node relationships is obtained, where the number of rows and columns of the matrix are the same, both being the number of normalized nodes.
  • the elements in the i-th row and j-th column of the matrix are assigned according to the following rules: if the i-th node is the parent node of the j-th node, then the assignment is a "parent-child relationship"; if the i-th node is a child node of the j-th node, Then assign the value to "son and father" Relationship"; if the i-th node is the node immediately to the left of the j-th node, then the assignment is "brother relationship"; if the i-th node is the node immediately to the right of the j-th node, then the assignment is "brother relationship"; If any of the above relationships does not exist between the i-th node and the j-th node, then the assignment is "no relationship". It can be understood that
  • step S3000 at least includes the following steps:
  • the data node data set at least includes variable creation instructions, data transfer instructions and data control instructions.
  • variable creation instructions usually indicate that a new variable is introduced into the program code for the first time.
  • the variable declaration and parameter declaration nodes in C language namely "declaration” and "parameter_declaration”. This type of node creates a sourceless data flow relationship, that is, the variable name is created but the data source is empty.
  • a data transfer instruction usually means that the data of one variable is updated by some calculation of another variable or variables.
  • assignment nodes such as assignment nodes, variable definition nodes, auto-increment nodes and auto-decrement nodes in C language, namely "assignment_expression”, “init_declarator” and "update_expression”.
  • This type of node creates a single data flow relationship, that is, the created variable data flow comes from one or more original variables.
  • Data control instructions usually indicate that the data update path may be different under different conditions. Examples include conditional statement nodes, multi-branch statement nodes, and conditional loop statement nodes in C language, namely "if_statement”, “case_statement”, “switch_statement”, “for_statement” and “while_statement”. This type of node will establish a multi-branch flow relationship of the data flow, that is, the data of all variables after the statement can come from the variables before the current statement, or from the variables in the current statement.
  • S3300 Determine the adjacent relationship between multiple data node information according to the node name of the data node information to form data flow information.
  • Non-grammatical feature defects such as logical errors, incorrect order and other defects, can be quickly compared and analyzed.
  • the data flow information is extracted from the normalized information of the above-mentioned defective program code, and 53:n->17:n is obtained, indicating that the data of variable n corresponding to node 53 in the normalized information depends on the variable n corresponding to node 17.
  • 75: production->26: production and 75: production->66: production indicate that the data of the variable production corresponding to node 75 comes from the variable production of node 26 or the variable production of node 66, or a combination of the two.
  • the data flow information can also store the adjacent relationship between the data node information through the adjacency matrix, which will not be described again here.
  • step S4000 at least includes the following steps:
  • the subtree of the code line node can represent a line of code with the format control symbol removed and the syntax complete.
  • code line nodes include but are not limited to nodes with the following node names: “continue_statement”, “break_statement”, “return_statement”, “declaration”, “goto_statement”, “parameters”, “expression_statement”, “for_condition” and “if_condition”.
  • the obtained code line node information represents the entire program code, and each node in the code line node information corresponds to the abstract syntax tree information.
  • the root node, and the code line node information subtree represents a line in the program code.
  • the code line node information Linenodes1 of the above defective program code is: [9:parameters,20:declaration,28:for_condition,62:expression_statement,72:return_statement];
  • the code line node information Linenodes2 of the above patch code is: [9: parameters, 20: declaration, 34: for_condition, 67: expression_statement, 78: return_statement].
  • Each number in the code line node information represents the identification number of the code line node in the abstract syntax tree information.
  • S4300 Create a dictionary sequence based on the code line node data set.
  • a dictionary sequence is created based on the code line node data set, so as to convert the type of the code line node into the corresponding number in the dictionary sequence, thereby further simplifying the data processing.
  • S4400 Convert the code line node information into sequence information according to the dictionary sequence.
  • converting the code line node information into sequence information that is, expressing the elements of the code line node information with corresponding numbers in the dictionary sequence, facilitates the neural network's data acquisition and analysis of the sequence information.
  • sequence information Dictnodes1 of the above defective program code is [0,1,2,3,4]
  • sequence information Dictnodes2 of the patch code is [0,5,2,3,4].
  • "0" in the sequence information means that the number of the code line node "9:parameters" in the dictionary sequence is "0", and so on.
  • S5000 Obtain program patch information based on the sequence information of the defective program code and the sequence information of the patch code.
  • step S5000 includes at least the following steps:
  • S5100 Compare the sequence information of the defective program code with the sequence information of the patch code.
  • step S4000 the sequence information of the defective program code and the sequence information of the patch code can be compared quickly and accurately.
  • S5200 Calculate the difference value between the sequence information of the defective program code and the sequence information of the patch code, and obtain the program patch information; wherein the program patch information includes: the sequence information identification number of the defective program code, operating instructions and patch The sequence information identification number of the program code.
  • the minimum edit operation number of Dictnodes1 and Dictnodes2 can be calculated through the minimum edit distance algorithm as 1.
  • the example operation is ⁇ [1]:1modify 1 ⁇ , that is, the identification number of Dictnodes1 is 1
  • the element value is 1
  • the element value is 5
  • It is equivalent to modifying the code line represented by the code line node information corresponding to the identification number 1 in the sequence information of the defective program code (the third line of the defective program code) to the code line corresponding to the identification number 1 in the sequence information of the patch code.
  • the code line represented by the code line node information (the third line of the patch code), in this way, the defect that the variable "production" in the defective program code is not correctly initialized can be removed, and the result consistent with the patch code can be obtained.
  • calculating the difference value between the sequence information of the defective program code and the sequence information of the patch code through the minimum edit distance algorithm is a well-known technology, which will not be described again here.
  • S6000 Extract the defect data characteristics of the defective program code based on the data flow information, sequence information and program patch information.
  • step S6000 includes at least the following steps:
  • S6100 Obtain data flow information and sequence information corresponding to the program patch information.
  • S6200 Extract the distinguishing features of the data flow information and the distinguishing features of the sequence information to obtain defect data features.
  • sequence information and data flow information can be learned by neural networks as program features; program patch information can also be used to quickly repair program defects.
  • information such as defective lines and repair operations can be used as features.
  • related defect data features can also be used for tasks such as defect location and defect classification.
  • Figure 8 is a schematic structural diagram of a program defect data feature extraction device 700 provided by an embodiment of the present application.
  • the entire process of the program defect data feature extraction method provided by an embodiment of the present application involves the steps in the program defect data feature extraction device 700.
  • the acquisition module 710 is configured to obtain the abstract syntax tree information of the program code, where the program code includes defective program code and patch code;
  • the conversion module 720 is configured to normalize the abstract syntax tree information to obtain the standardized information. ; Convert the normalized information into sequence information; obtain the data flow information according to the normalized information;
  • the calculation module 730 is configured to obtain the program patch information according to the sequence information of the defective program code and the sequence information of the patch code;
  • the extraction module 740 is It is set to extract defective programs based on sequence information, program patch information and data flow information. Defect data characteristics of program code.
  • FIG. 9 shows an electronic device 800 provided by an embodiment of the present application.
  • the electronic device 800 includes but is not limited to:
  • Memory 801 is configured to store programs
  • the processor 802 is configured to execute the program stored in the memory 801.
  • the processor 802 executes the program stored in the memory 801, the processor 802 is configured to execute the above-mentioned program defect data feature extraction method.
  • the processor 802 and the memory 801 may be connected through a bus or other means.
  • the memory 801 can be configured to store non-transitory software programs and non-transitory computer executable programs, such as the program defect data feature extraction method described in any embodiment of this application.
  • the processor 802 implements the above-mentioned program defect data feature extraction method by running non-transient software programs and instructions stored in the memory 801 .
  • the memory 801 may include a program storage area and a data storage area, where the program storage area may store an operating system and an application program required for at least one function; the storage data area may store the execution of the above-mentioned program defect data feature extraction method.
  • the memory 801 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device.
  • memory 801 may include memory located remotely relative to processor 802, and these remote memories may be connected to the processor 802 through a network. Examples of the above-mentioned networks include but are not limited to the Internet, intranets, local area networks, mobile communication networks and combinations thereof.
  • the non-transient software programs and instructions required to implement the above method for extracting program defect data features are stored in the memory 801. When executed by one or more processors 802, the program defect data feature extraction provided by any embodiment of the present application is performed. method.
  • Embodiments of the present application also provide a storage medium that stores computer-executable instructions, and the computer-executable instructions are used to execute the above method for extracting program defect data features.
  • the storage medium stores computer-executable instructions, which are executed by one or more control processors 802, such as by one processor 802 in the electronic device 800, so that the above-mentioned One or more processors 802 execute the program defect data feature extraction method provided by any embodiment of this application.
  • the abstract syntax tree information of the program code is obtained; the abstract syntax tree information is standardized to obtain standardized information; the data flow information is obtained according to the standardized information; and the standardized information is converted into sequence information. ;According to the sequence information of the defective program code and the sequence information of the patch code, obtain program patch information;According to the data flow information, the sequence information and the program patch information, extract the program patch information of the defective program code Defect data characteristics.
  • the solution of the embodiment of the present application can quickly and accurately extract program patch information and data flow information, facilitate defect repair and analysis and synthesis operations on the program code, and improve the user experience.
  • Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, Digital Versatile Disk (DVD) or other optical disk storage, magnetic cassettes, tapes, disk storage or other magnetic storage devices, or may Any other medium used to store the desired information and that can be accessed by a computer.
  • communication media typically includes computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

本申请实施例公开了一种程序缺陷数据特征提取方法、电子设备及存储介质,所述方法包括:获取程序代码的抽象语法树信息,其中,程序代码包括缺陷程序代码和补丁程序代码(S1000);对抽象语法树信息进行规范化处理,得到规范化信息(S2000);根据规范化信息,得到数据流信息(S3000);把规范化信息转化为序列信息(S4000);根据缺陷程序代码的序列信息和补丁程序代码的序列信息,得到程序补丁信息(S5000);根据数据流信息、序列信息和程序补丁信息,提取得到缺陷程序代码的缺陷数据特征(S6000)。

Description

一种程序缺陷数据特征提取方法、电子设备及存储介质
相关申请的交叉引用
本申请基于申请号为202210239269.X、申请日为2022年03月08日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。
技术领域
本申请涉及程序修复技术领域,特别是涉及一种程序缺陷数据特征提取方法、电子设备及存储介质。
背景技术
随着深度学习技术的快速发展,软件自动修复技术与深度学习技术的交叉成为了一种趋势。现阶段基于深度学习的软件自动修复技术大多数借鉴了自然语言处理技术将程序简单的看作文本序列,然后利用神经网络来提取其特征并完成后端的缺陷修复。这种方式的缺点也很明显,就是这种表示失去了代码语言自身的特征,如语法特征,数据特征等。因此在一些情形中提出了采用抽象语法树(Abstract Syntax Tree,AST)作为代码的一种特征表示,这样代码语言的语法特征就能够很好地被AST所表征。但是对软件自动修复来说,仅将语法树作为程序的表征,只能够反应出代码中各个标志符之间的语法结构关系。而对于程序中出现的缺陷,语法错误仅仅是其中的一部分,更多的是程序中隐藏的逻辑错误。为了更好地表示程序中逻辑错误的特征,部分情形中也提出了将数据流程图(Data Flow Graph,DFG)作为程序的特征。这样通过获取程序中数据流动的过程,能从侧面反映出程序中的逻辑错误。
虽然现阶段有多种方式来表征程序,但是由于不同的编程语言自身的特性各不相同,AST与DFG的表示也没有统一的规范,并且针对不同编程语言或者同一编程语言在实现不同任务时所需要的特征也各不相同的。因此现有的程序缺陷数据特征提取方法无法高效、准确地提取出程序特征,后端任务的准确率也无法得到保证。
发明内容
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。
本申请实施例提供一种程序缺陷数据特征提取方法、电子设备及存储介质。
第一方面,本申请实施例提供一种程序缺陷数据特征提取方法,所述方法包括:获取程序代码的抽象语法树信息,其中,所述程序代码包括缺陷程序代码和补丁程序代码;对所述抽象语法树信息进行规范化处理,得到规范化信息;根据所述规范化信息,得到数据流信息;把所述规范化信息转化为序列信息;根据所述缺陷程序代码的所述序列信息和所述补丁程序代码的所述序列信息,得到程序补丁信息;根据所述数据流信息、所述序列信息和所述程序补丁信息,提取得到所述缺陷程序代码的缺陷数据特征。
第二方面,本申请实施例提供一种电子设备,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现本申请实施例 提供的程序缺陷数据特征提取方法。
第三方面,本申请实施例提供一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时,实现本申请实施例提供的程序缺陷数据特征提取方法。
本申请的其它特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本申请而了解。本申请的目的和其他优点可通过在说明书、权利要求书以及附图中所特别指出的结构来实现和得到。
附图说明
附图用来提供对本申请技术方案的进一步理解,并且构成说明书的一部分,与本申请的实施例一起用于解释本申请的技术方案,并不构成对本申请技术方案的限制。
图1是本申请实施例提供的一种程序缺陷数据特征提取方法的流程示意图;
图2是图1中步骤S2000的另一实施例的实现过程示意图;
图3是图2中步骤S2300的另一实施例的实现过程示意图;
图4是图1中步骤S3000的另一实施例的实现过程示意图;
图5是图1中步骤S4000的另一实施例的实现过程示意图;
图6是图1中步骤S5000的另一实施例的实现过程示意图;
图7是图1中步骤S6000的另一实施例的实现过程示意图;
图8是本申请实施例提供的一种程序缺陷数据特征提取装置的结构图;
图9是本申请实施例提供的一种电子设备的结构示意图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。
应了解,在本申请实施例的描述中,如果有描述到“第一”、“第二”等只是用于区分技术特征为目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量或者隐含指明所指示的技术特征的先后关系。“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示单独存在A、同时存在A和B、单独存在B的情况。其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项”及其类似表达,是指的这些项中的任意组合,包括单项或复数项的任意组合。例如,a,b和c中的至少一项可以表示:a,b,c,a和b,a和c,b和c或a和b和c,其中a,b,c可以是单个,也可以是多个。
此外,下面所描述的本申请各个实施方式中所涉及到的技术特征只要彼此之间未构成冲突就可以相互组合。
本申请实施例涉及的程序缺陷数据特征提取方法,是基于AST对程序代码的抽象表示,再对AST进行规范化处理,提取出便于神经网络读取和分析的规范化信息。AST以树状的形式表现程序代码的语法结构,树上的每个节点都表示程序代码中的一种结构。其中,字面量、标识符、表达式、语句、模块语法、class语法都有各自的AST。而在程序自动修复的应用中, AST需要与DFG结合使用,才能充分地表征程序代码。因此,采用程序缺陷数据特征提取的方式能快速、精准地提取出程序补丁信息和数据流信息,便于对程序代码进行缺陷修复和分析合成操作,特别适用于程序缺陷的自动分析。
为了保证程序缺陷数据特征的提取精度,现有的程序缺陷数据特征提取方法为:获取表征程序代码特征的AST和DFG,对缺陷程序和补丁程序进行差异查找和区别分析。这种方式并不能根据不同的编程语言自身的特性对程序缺陷数据特征进行提取,而且由于没有对抽象语法树信息进行优化处理,无法在程序缺陷自动修复的场景中实现高效、精准的程序代码特征分析。
基于以上,本申请实施例提供一种程序缺陷数据特征提取方法、装置、电子设备及计算机可读存储介质,通过对抽象语法树信息进行规范化处理,得到规范化信息;并把规范化信息转化为序列信息;根据缺陷程序代码的序列信息和补丁程序代码的序列信息,得到程序补丁信息,最终从序列信息、程序补丁信息和数据流信息中提取缺陷程序代码的缺陷数据特征,以达到快速、精准地提取出程序补丁信息和数据流信息的目的,提高软件缺陷分析的效率和用户的使用体验。
请参见图1,图1示出了本申请实施例提供的一种程序缺陷数据特征提取方法的流程。如图1所示,本申请实施例的程序缺陷数据特征提取方法包括以下步骤:
S1000,获取程序代码的抽象语法树信息,其中,程序代码包括缺陷程序代码和补丁程序代码。
可以理解的是,在程序缺陷自动修复过程中,程序代码包括缺陷程序代码和补丁程序代码。而程序缺陷数据特征提取的过程,就是通过快速地对比分析缺陷程序代码和补丁程序代码之间的区别特征,进而对缺陷程序代码存在的异常和错误进行快速的修改。因此,需要对缺陷程序代码和补丁程序代码分别进行处理,获取各自的抽象语法树信息,以便进行分析处理。
可以理解的是,通过将代码文件转换为抽象语法树信息,能更方便地对代码文件进行分析、优化、变更等操作。示例性的,把程序代码输入现有的AST前端工具就获取程序代码的抽象语法树信息,例如eslint、tree-sitter等。通过这些前端工具,能把缺陷程序代码和补丁程序代码分别转化为抽象语法树信息。在实际应用中,通过前端工具或者内嵌模块对程序代码进行AST转换,属于公知的技术,此处不再赘述。
S2000,对抽象语法树信息进行规范化处理,得到规范化信息。
可以理解的是,从程序代码直接获得的抽象语法树信息存在信息量大、处理时间长的特点。为了更精简地表达程序代码的语法特征,并且提供了统一的形式,能够被不同的后端算法处理,需要对抽象语法树信息进行提炼和优化处理,尤其是在不同的语言环境下,精准地提取出程序代码的语法特征。
请参见图2,图2示出了上述步骤S2000的另一实施例的实现过程示意图。如图2所示,步骤S2000至少包括以下步骤:
S2100,先序遍历抽象语法树信息的每个抽象语法树节点。
可以理解的是,为了保证数据的完整性和前后连续性,需要把每个抽象语法树节点进行先序遍历,以避免发生数据丢失和前后关系有误的情况。
S2200,在抽象语法树节点存在语法信息的情况下,创建与抽象语法树节点相对应的规范 化节点,其中,规范化节点包括:标识号、父节点指针、子节点指针和节点名称,节点名称与语法信息一致。
可以理解的是,当确定抽象语法树节点中存在语法信息,即可为当前抽象语法树节点创建规范化节点。对于语法相关节点,创建一个规范化节点以存储标识号、父节点指针、子节点指针和节点名。示例性的,标识号是按照先序遍历顺序从0开始对规范化节点进行编号的整数。
此外,当抽象语法树节点为“comment”、“;”、“(”、“)”、“[”、“]”、“{”、“}”、“,”、“\n”、“’”、“””,则表明当前节点是语法无关节点,忽略这些节点,以便去掉程序代码中的无效的信息。
S2300,根据规范化节点,得到规范化信息。
可以理解的是,通过对规范化节点进行进一步的优化处理,以获得更加简练、精准的程序代码规范化节点。把优化处理后的规范化节点进行关联和聚合,得到规范化信息。
请参见图3,图3示出了上述步骤S2300的另一实施例的实现过程示意图。如图3所示,步骤S2300至少包括以下步骤:
S2310,在节点名称存在类型名的情况下,在规范化节点和规范化节点的父节点之间插入一个节点名称为类型名的规范化节点。
可以理解的是,类型名为系统或用户已定义的一种数据类型,是函数执行过程中要求返回的值的类型。因此,在节点名称存在类型名的情况下,需要在规范化节点和规范化节点的父节点之间插入规范化节点,以对类型名所对应的返回值进行记录。
S2320,在节点名称存在循环控制指令的情况下,为抽象语法树节点创建与循环控制指令配合的循环控制子节点和条件判断子节点。
可以理解的是,循环控制指令的作用是反复执行相同的任务,直到不满足循环条件为止。因此,循环控制指令规范化节点必须设有与之配合的循环控制子节点和条件判断子节点,以保证循环控制指令相关的数据完整性。
示例性的,对于节点名称为“for_statement”的循环控制规范化节点,创建节点名称为“for_condition”规范化节点,并且将当前节点的节点名称为“for”、“initializer”、“condition”或“update”的子节点放置到“for_condition”节点的子节点列表中。对节点名称为“if_statement”或“while_statement”的带条件判断的规范化节点,创建一个“if_condition”规范化节点,并且将当前节点的节点名称为“if”、“while”或“condition”的子节点放置到“if_condition”节点的子节点列表中。
S2330,在节点名称存在标识符的情况下,为抽象语法树节点创建节点名称与标识符一致的子节点。
可以理解的是,标识符是用来标识某个实体的一个符号,在不同的应用环境下有不同的含义。在计算机编程语言中,标识符是用户编程时使用的名字,用于给变量、常量、函数、语句块等命名,以建立起名称与使用之间的关系。因此,在节点名称存在标识符的情况下,需要为其创建对应的子节点,以记录与之相关的变量、常量或者函数。
示例性的,对于节点名称为“identifier”、“primitive_type”、“number_literal”、“type_identifier”或“field_identifier”的规范化节点,创建一个规范化子节点,其节点名称从当前规范化节点对应的程序代码中获取。
S2340,在节点名称存在函数指令的情况下,对规范化节点和函数指令进行记录处理。
可以理解的是,函数指令中往往包含各种操作对象和转换关系,通过记录规范化节点和对应的函数名,以便可以按照函数对程序代码进行切分。
示例性的,对节点名称为“function_declaration”的规范化节点,在其子树中找到函数名,并把该规范化节点和函数名记录到一个列表中。
示例性的,为更好地描述各个步骤的实现过程,本申请实施例以一组简单的缺陷程序代码和补丁程序代码为例进行描述。程序代码如下所示:
缺陷程序代码:
由上可知,缺陷程序代码实现了一个计算阶乘的功能,缺陷是变量production没有被正确的初始化。而补丁程序代码将变量production初始化为1,修复了该缺陷。
可以理解的是,获取规范化信息后,为了便于神经网络直接读取,能采用带回溯符的先序遍历序列和邻接矩阵的方式记录节点关系。
示例性的,通过构建带回溯符的先序遍历序列,对于遍历到的规范化节点,将其节点名存储于列表中,当进行回溯时,即返回到上一层节点时,将一个“^”作为回溯符添加到列表中。以上述缺陷程序代码的规范化信息为例,前6个节点形成序列为:[function_definition,type,primitive_type,int,^,^,^,declarator,function_declarator]。可以理解的是,采用先序遍历序列的方式记录节点关系为公知的技术,此处不再赘述。
示例性的,通过获取带节点关系的邻接矩阵,其中矩阵的行数和列数相同,都为规范化节点的数量。矩阵的第i行第j列元素按照如下规则赋值:若第i个节点是第j个节点的父节点,那么赋值为“父子关系”;若第i个节点是第j个节点的子节点,那么赋值为“子父 关系”;若第i个节点是第j个节点的左边紧邻的节点,那么赋值为“弟兄关系”;若第i个节点是第j个节点的右边紧邻的节点,那么赋值为“兄弟关系”;若第i个节点和第j个节点不存在上述任何一种关系,那么赋值为“无关系”。可以理解的是,通过邻接矩阵的方式记录节点关系为公知的技术,此处不再赘述。
S3000,根据规范化信息,得到数据流信息。
请参见图4,图4示出了上述步骤S3000的另一实施例的实现过程示意图。如图4所示,步骤S3000至少包括以下步骤:
S3100,建立数据节点数据集。
可以理解的是,数据节点数据集至少包括变量创建指令、数据转移指令和数据控制指令。其中,变量创建指令通常表示一个新的变量被首次引入到程序代码中。示例性的,比如C语言中的变量声明和参数声明节点,即“declaration”和“parameter_declaration”。这类节点创建无源数据流关系,即变量名创建但数据来源为空。
数据转移指令通常表示一个变量的数据被另一个或多个变量的某种计算更新。示例性的,比如C语言中的赋值节点,变量定义节点,自增节点和自减节点,即“assignment_expression”、“init_declarator”和“update_expression”。这类节点创建单一数据流关系,即创建的变量数据流来自于原有的一个或者多个变量。
数据控制指令通常表示在不同条件时,数据更新的路径可能会不同。示例性的,比如C语言中的条件语句节点,多分支语句节点,条件循环语句节点,即“if_statement”、“case_statement”“switch_statement”、“for_statement”和“while_statement”。这类节点会建立数据流的多分支流向关系,即该语句后的所有变量的数据,可以来自于当前语句之前的变量,也可以来自于当前语句中的变量。
S3200,先序遍历规范化信息,提取节点名称与数据节点数据集相匹配的规范化信息,得到数据节点信息。
可以理解的是,通过遍历规范化信息,把与上述数据节点相关的规范化信息进行提取,得到能充分体现程序代码中各个数据节点的数据节点信息,保证数据节点的处理和分析效率。
S3300,根据数据节点信息的节点名称,确定多个数据节点信息之间的相邻关系,形成数据流信息。
可以理解的是,根据数据节点信息的节点名称及其多个数据节点信息之间的相邻关系,得到程序代码中各个数据节点之间的转换和逻辑关系,便于根据数据流信息对缺陷程序中的非语法特征缺陷,如逻辑错误、前后顺序有误等缺陷,进行快速的对比和分析处理。
示例性的,对上述缺陷程序代码的规范化信息进行数据流信息提取,得到53:n->17:n,表示了规范化信息中的节点53对应的变量n的数据依赖于节点17对应的变量n;此外,75:production->26:production和75:production->66:production,表示了节点75对应的变量production的数据来自于节点26的变量production或节点66的变量production或者两者的组合。
可以理解的是,与上述规范化信息的存储方式类似,数据流信息同样能通过邻接矩阵的方式存储数据节点信息之间的相邻关系,此处不再赘述。
S4000,把规范化信息转化为序列信息。
请参见图5,图5示出了上述步骤S4000的另一实施例的实现过程示意图。如图5所示,步骤S4000至少包括以下步骤:
S4100,建立代码行节点数据集。
可以理解的是,由于规范化信息中存在完整的程序代码语法信息,其中很大部分对程序的正常运行不起关键性作用。为了进一步简化规范化信息,提高系统的处理速度,需要对特殊的规范化节点进行提取处理,得到代码行节点。其中,代码行节点的子树能够表示去掉了格式控制符且语法完整的一行代码。建立代码行节点数据集,即把程序代码中所有代码行节点类型进行收集统计。
示例性的,针对C编程语言,代码行节点包括但不仅限于以下节点名称的节点:“continue_statement”、“break_statement”、“return_statement”、“declaration”、“goto_statement”、“parameters”、“expression_statement”、“for_condition”和“if_condition”。
S4200,先序遍历规范化信息,提取节点名称与代码行节点数据集相匹配的规范化信息,得到代码行节点信息。
可以理解的是,通过提取节点名称与代码行节点数据集相匹配的规范化信息,获得的代码行节点信息表示了整个程序代码,而代码行节点信息中的每一个节点对应了抽象语法树信息的根节点,而代码行节点信息子树表示了程序代码中的一行。
示例性的,上述缺陷程序代码的代码行节点信息Linenodes1为:[9:parameters,20:declaration,28:for_condition,62:expression_statement,72:return_statement];上述补丁程序代码的代码行节点信息Linenodes2为:[9:parameters,20:declaration,34:for_condition,67:expression_statement,78:return_statement]。其中,代码行节点信息中各个数字表示该代码行节点在抽象语法树信息中的标识号。
S4300,根据代码行节点数据集,创建字典序列。
可以理解的是,根据代码行节点数据集,创建字典序列,以便于把代码行节点的类型转化为字典序列中对应的编号,达到进一步简化处理数据的效果。
S4400,根据字典序列,把代码行节点信息转化为序列信息。
可以理解的是,把代码行节点信息转化为序列信息,即把代码行节点信息的元素以字典序列中对应的编号表示出,便于神经网络对序列信息进行数据获取和分析。
示例性的,上述缺陷程序代码的序列信息Dictnodes1为[0,1,2,3,4],补丁程序代码的序列信息Dictnodes2为[0,5,2,3,4]。其中,序列信息中的“0”表示代码行节点“9:parameters”在字典序列中的编号为“0”,如此类推。
S5000,根据缺陷程序代码的序列信息和补丁程序代码的序列信息,得到程序补丁信息。
请参见图6,图6示出了上述步骤S5000的另一实施例的实现过程示意图。如图6所示,步骤S5000至少包括以下步骤:
S5100,将缺陷程序代码的序列信息和补丁程序代码的序列信息进行差异对比。
可以理解的是,经过上述步骤S4000的简化处理,使缺陷程序代码的序列信息和补丁程序代码的序列信息能进行快速、准确的差异对比。
S5200,计算缺陷程序代码的序列信息和补丁程序代码的序列信息之间的差异值,得到程序补丁信息;其中,程序补丁信息包括:缺陷程序代码的序列信息标识号、操作指令和补丁 程序代码的序列信息标识号。
示例性的,以上述Dictnodes1和Dictnodes2作为例子,通过最小编辑距离算法计算可得Dictnodes1和Dictnodes2最小编辑操作数为1,示例操作为{[1]:1modify 1},即将Dictnodes1中标识号为1的元素(值为1),修改为Dictnodes2中标识号为1的元素(值为5)。相当于把缺陷程序代码的序列信息中标识号为1所对应的代码行节点信息所代表的代码行(缺陷程序代码第三行),修改为补丁程序代码的序列信息中标识号为1所对应的代码行节点信息所代表的代码行(补丁程序代码第三行),这样就能把缺陷程序代码中变量“production”没有被正确初始化的缺陷去除,得到与补丁程序代码一致的结果。其中,通过最小编辑距离算法计算缺陷程序代码的序列信息和补丁程序代码的序列信息之间的差异值为公知的技术,此处不再赘述。
可以理解的是,通过对比缺陷程序代码的序列信息和补丁程序代码的序列信息之间的差异值,能快速、准确地得到缺陷程序代码转化为补丁程序代码的最简单快速的方式,进而高效地获取程序补丁信息。
S6000,根据数据流信息、序列信息和程序补丁信息,提取得到缺陷程序代码的缺陷数据特征。
请参见图7,图7示出了上述步骤S6000的另一实施例的实现过程示意图。如图7所示,步骤S6000至少包括以下步骤:
S6100,获取与程序补丁信息对应的数据流信息和序列信息。
可以理解的是,通过上述步骤S5200获取程序补丁信息后,通过获取与程序补丁信息对应的数据流信息和序列信息,能快速地查找出缺陷程序代码与补丁程序代码之间的区别特征,并通过数据流信息和序列信息进行表征。获取与程序补丁信息对应的数据流信息和序列信息,能提高缺陷程序代码与补丁程序代码的分析处理效率,避免无效信息的处理和干扰。
S6200,提取数据流信息的区别特征和序列信息的区别特征,得到缺陷数据特征。
可以理解的是,通过程序补丁信息,提取出缺陷程序代码与补丁程序代码之间,数据流信息和序列信息的区别特征,能高效、准确地获取缺陷程序代码的缺陷数据特征,便于后续对缺陷程序代码的进一步分析和修复。
可以理解的是,把上述步骤获取的序列信息、程序补丁信息和数据流信息输入神经网络中,大大地提高了系统的学习效率和准确率。示例性的,序列信息与数据流信息可以作为程序的特征被神经网络所学习;程序补丁信息还能用于程序缺陷的快速修复,示例性的,缺陷行及修复操作等信息可以作为特征。除此之外,缺陷定位,缺陷分类等任务也可以使用相关的缺陷数据特征。
参见图8,图8是本申请实施例提供的程序缺陷数据特征提取装置700的结构示意图,本申请实施例提供的程序缺陷数据特征提取方法的整个流程中涉及程序缺陷数据特征提取装置700中的以下模块:获取模块710、转化模块720、计算模块730和提取模块740。
其中,获取模块710,被设置为获取程序代码的抽象语法树信息,其中,程序代码包括缺陷程序代码和补丁程序代码;转化模块720,被设置为对抽象语法树信息进行规范化处理,得到规范化信息;把规范化信息转化为序列信息;根据规范化信息,得到数据流信息;计算模块730,被设置为根据缺陷程序代码的序列信息和补丁程序代码的序列信息,得到程序补丁信息;提取模块740,被设置为根据序列信息、程序补丁信息和数据流信息,提取缺陷程 序代码的缺陷数据特征。
需要说明的是,上述装置的模块之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。
图9示出了本申请实施例提供的电子设备800。该电子设备800包括但不限于:
存储器801,被设置为存储程序;
处理器802,被设置为执行存储器801存储的程序,当处理器802执行存储器801存储的程序时,处理器802被设置为执行上述的程序缺陷数据特征提取方法。
处理器802和存储器801可以通过总线或者其他方式连接。
存储器801作为一种非暂态计算机可读存储介质,可被设置为存储非暂态软件程序以及非暂态性计算机可执行程序,如本申请任意实施例描述的程序缺陷数据特征提取方法。处理器802通过运行存储在存储器801中的非暂态软件程序以及指令,从而实现上述的程序缺陷数据特征提取方法。
存储器801可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储执行上述的程序缺陷数据特征提取方法。此外,存储器801可以包括高速随机存取存储器,还可以包括非暂态存储器,比如至少一个磁盘存储器件、闪存器件、或其他非暂态固态存储器件。在一些实施方式中,存储器801可包括相对于处理器802远程设置的存储器,这些远程存储器可以通过网络连接至该处理器802。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。
实现上述的程序缺陷数据特征提取方法所需的非暂态软件程序以及指令存储在存储器801中,当被一个或者多个处理器802执行时,执行本申请任意实施例提供的程序缺陷数据特征提取方法。
本申请实施例还提供了一种存储介质,存储有计算机可执行指令,计算机可执行指令用于执行上述的程序缺陷数据特征提取方法。
在一实施例中,该存储介质存储有计算机可执行指令,该计算机可执行指令被一个或多个控制处理器802执行,比如,被上述电子设备800中的一个处理器802执行,可使得上述一个或多个处理器802执行本申请任意实施例提供的程序缺陷数据特征提取方法。
本申请实施例,通过获取程序代码的抽象语法树信息;对所述抽象语法树信息进行规范化处理,得到规范化信息;根据所述规范化信息,得到数据流信息;把所述规范化信息转化为序列信息;根据缺陷程序代码的所述序列信息和补丁程序代码的所述序列信息,得到程序补丁信息;根据所述数据流信息、所述序列信息和所述程序补丁信息,提取所述缺陷程序代码的缺陷数据特征。本申请实施例的方案能够快速、精准地提取出程序补丁信息和数据流信息,便于对程序代码进行缺陷修复和分析合成操作,提高用户的使用体验。
以上所描述的实施例仅仅是示意性的,其中作为分离部件说明的单元可以是或者也可以不是物理上分开的,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、系统可以被实施为软件、固件、硬件及其适当的组合。某些物理组件或所有物理组件可以被实施为由处理器,如中央处理器、数字信号处理器或微处理器执行的软件,或者被实施为硬件,或者被实 施为集成电路,如专用集成电路。这样的软件可以分布在计算机可读介质上,计算机可读介质可以包括计算机存储介质(或非暂时性介质)和通信介质(或暂时性介质)。如本领域普通技术人员公知的,术语计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质。计算机存储介质包括但不限于RAM、ROM、EEPROM、闪存或其他存储器技术、CD-ROM、数字多功能盘(DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质。此外,本领域普通技术人员公知的是,通信介质通常包括计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。
以上是对本申请的若干实施进行了具体说明,但本申请并不局限于上述实施方式,熟悉本领域的技术人员在不违背本申请本质的条件下还可作出种种等同的变形或替换,这些等同的变形或替换均包括在本申请权利要求所限定的范围内。

Claims (10)

  1. 一种程序缺陷数据特征提取方法,所述方法包括:
    获取程序代码的抽象语法树信息,其中,所述程序代码包括缺陷程序代码和补丁程序代码;
    对所述抽象语法树信息进行规范化处理,得到规范化信息;
    对所述规范化信息进行提取处理,得到数据流信息;
    把所述规范化信息转化为序列信息;
    根据所述缺陷程序代码的所述序列信息和所述补丁程序代码的所述序列信息,得到程序补丁信息;
    根据所述数据流信息、所述序列信息和所述程序补丁信息,提取得到所述缺陷程序代码的缺陷数据特征。
  2. 根据权利要求1所述的方法,其中,所述对所述抽象语法树信息进行规范化处理,得到规范化信息,包括:
    遍历所述抽象语法树信息的每个抽象语法树节点;
    在所述抽象语法树节点存在语法信息的情况下,创建与所述抽象语法树节点相对应的规范化节点,其中,所述规范化节点包括:标识号、父节点指针、子节点指针和节点名称,所述节点名称与所述语法信息一致;
    根据所述规范化节点,得到所述规范化信息。
  3. 根据权利要求2所述的方法,其中,所述根据所述规范化节点,得到所述规范化信息,包括:
    在所述节点名称存在类型名的情况下,在所述规范化节点和所述规范化节点的父节点之间插入一个所述节点名称为所述类型名的所述规范化节点;或,
    在所述节点名称存在循环控制指令的情况下,为所述抽象语法树节点创建与所述循环控制指令配合的循环控制子节点和条件判断子节点;或,
    在所述节点名称存在标识符的情况下,为所述抽象语法树节点创建所述节点名称与所述标识符一致的子节点;或,
    在所述节点名称存在函数指令的情况下,对所述规范化节点和所述函数指令进行记录处理。
  4. 根据权利要求2所述的方法,其中,所述对所述规范化信息进行提取处理,得到数据流信息,包括:
    建立数据节点数据集;
    遍历所述规范化信息,提取所述节点名称与所述数据节点数据集相匹配的所述规范化信息,得到数据节点信息;
    根据多个所述数据节点信息的所述节点名称,确定所述数据节点信息之间的相邻关系,形成所述数据流信息。
  5. 根据权利要求4所述的方法,其中,所述数据节点数据集至少包括:变量创建指令、数据转移指令和数据控制指令。
  6. 根据权利要求2所述的方法,其中,所述把所述规范化信息转化为序列信息,包括:
    建立代码行节点数据集;
    遍历所述规范化信息,提取所述节点名称与所述代码行节点数据集相匹配的所述规范化信息,得到代码行节点信息;
    根据所述代码行节点数据集,创建字典序列;
    根据字典序列,把所述代码行节点信息转化为所述序列信息。
  7. 根据权利要求2所述的方法,其中,所述根据所述缺陷程序代码的所述序列信息和所述补丁程序代码的所述序列信息,得到程序补丁信息,包括:
    将所述缺陷程序代码的所述序列信息和所述补丁程序代码的所述序列信息进行差异对比;
    计算所述缺陷程序代码的序列信息和所述补丁程序代码的序列信息之间的差异值,得到所述程序补丁信息;其中,所述程序补丁信息包括:所述缺陷程序代码的序列信息标识号、操作指令和所述补丁程序代码的序列信息标识号。
  8. 根据权利要求1所述的方法,其中,所述根据所述数据流信息、所述序列信息和所述程序补丁信息,提取得到所述缺陷程序代码的缺陷数据特征,包括:
    根据与所述程序补丁信息对应的所述数据流信息和所述序列信息,提取所述缺陷程序代码的所述数据流信息与所述缺陷程序代码的所述序列信息的区别特征,得到所述缺陷数据特征。
  9. 一种电子设备,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现如权利要求1至8任意一项所述的程序缺陷数据特征提取方法。
  10. 一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时,实现如权利要求1至8任意一项所述的程序缺陷数据特征提取方法。
PCT/CN2023/079878 2022-03-08 2023-03-06 一种程序缺陷数据特征提取方法、电子设备及存储介质 WO2023169368A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210239269.X 2022-03-08
CN202210239269.XA CN116775121A (zh) 2022-03-08 2022-03-08 一种程序缺陷数据特征提取方法、电子设备及存储介质

Publications (1)

Publication Number Publication Date
WO2023169368A1 true WO2023169368A1 (zh) 2023-09-14

Family

ID=87937262

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/079878 WO2023169368A1 (zh) 2022-03-08 2023-03-06 一种程序缺陷数据特征提取方法、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN116775121A (zh)
WO (1) WO2023169368A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117056940A (zh) * 2023-10-12 2023-11-14 中关村科学城城市大脑股份有限公司 服务器系统漏洞修复方法、装置、电子设备和介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100050151A1 (en) * 2008-08-20 2010-02-25 International Business Machines Corporation System, method and program product for correcting semantic errors in code using peer submitted code snippets
US20170212829A1 (en) * 2016-01-21 2017-07-27 American Software Safety Reliability Company Deep Learning Source Code Analyzer and Repairer
CN108932192A (zh) * 2017-05-22 2018-12-04 南京大学 一种基于抽象语法树的Python程序类型缺陷检测方法
CN110597735A (zh) * 2019-09-25 2019-12-20 北京航空航天大学 一种面向开源软件缺陷特征深度学习的软件缺陷预测方法
CN112181428A (zh) * 2020-09-28 2021-01-05 北京航空航天大学 一种基于抽象语法树的开源软件缺陷数据分类方法及系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100050151A1 (en) * 2008-08-20 2010-02-25 International Business Machines Corporation System, method and program product for correcting semantic errors in code using peer submitted code snippets
US20170212829A1 (en) * 2016-01-21 2017-07-27 American Software Safety Reliability Company Deep Learning Source Code Analyzer and Repairer
CN108932192A (zh) * 2017-05-22 2018-12-04 南京大学 一种基于抽象语法树的Python程序类型缺陷检测方法
CN110597735A (zh) * 2019-09-25 2019-12-20 北京航空航天大学 一种面向开源软件缺陷特征深度学习的软件缺陷预测方法
CN112181428A (zh) * 2020-09-28 2021-01-05 北京航空航天大学 一种基于抽象语法树的开源软件缺陷数据分类方法及系统

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117056940A (zh) * 2023-10-12 2023-11-14 中关村科学城城市大脑股份有限公司 服务器系统漏洞修复方法、装置、电子设备和介质
CN117056940B (zh) * 2023-10-12 2024-01-16 中关村科学城城市大脑股份有限公司 服务器系统漏洞修复方法、装置、电子设备和介质

Also Published As

Publication number Publication date
CN116775121A (zh) 2023-09-19

Similar Documents

Publication Publication Date Title
CN111522816B (zh) 基于数据库引擎的数据处理方法、装置、终端及介质
CN110502227B (zh) 代码补全的方法及装置、存储介质、电子设备
CN111382070B (zh) 兼容性测试方法、装置、存储介质和计算机设备
CN109491658A (zh) 计算机可执行代码数据的生成方法及装置
WO2023169368A1 (zh) 一种程序缺陷数据特征提取方法、电子设备及存储介质
CN112035588B (zh) 构建空间数据规则库引擎的方法及gis数据质量检查方法
CN113760891B (zh) 一种数据表的生成方法、装置、设备和存储介质
CN115309451A (zh) 代码克隆检测方法、装置、设备、存储介质及程序产品
CN113190220A (zh) Json文件差异化对比方法及装置
CN115454445A (zh) 代码检查方法及装置、计算机可读存储介质、终端
CN115238655A (zh) 一种json数据编辑方法和装置
CN112328246A (zh) 页面组件生成方法、装置、计算机设备及存储介质
CN115658030A (zh) 代码处理方法、装置和电子设备
CN115221047A (zh) 测试用例自动生成方法及电子设备
CN114780098A (zh) Gauss Db数据库程序语法的检测方法及相关设备
CN113971044A (zh) 组件文档生成方法、装置、设备及可读存储介质
CN112925874A (zh) 基于案例标记的相似代码搜索方法及系统
CN114647439A (zh) 一种代码扫描的方法、代码迁移的方法及相关装置
CN113220800B (zh) 基于antlr的数据字段血缘分析方法及装置
WO2024108986A1 (zh) 一种通信网络业务处理方法和装置
CN113408250B (zh) 一种项目文件的处理方法和装置
CN113626385B (zh) 一种基于文本数据读取的方法和系统
CN110825376B (zh) 一种解析带注释json文件的方法、存储介质及装置
CN117806647A (zh) 基于软件流程图的c程序合成方法及装置、设备、介质
CN115587085A (zh) 数据迁移方法、装置、电子设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23765946

Country of ref document: EP

Kind code of ref document: A1