CN110471667A - A kind of method, apparatus, medium and electronic equipment for auditing source program - Google Patents

A kind of method, apparatus, medium and electronic equipment for auditing source program Download PDF

Info

Publication number
CN110471667A
CN110471667A CN201910676258.6A CN201910676258A CN110471667A CN 110471667 A CN110471667 A CN 110471667A CN 201910676258 A CN201910676258 A CN 201910676258A CN 110471667 A CN110471667 A CN 110471667A
Authority
CN
China
Prior art keywords
difference
source program
syntax tree
program
program code
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN201910676258.6A
Other languages
Chinese (zh)
Inventor
赵岘
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN201910676258.6A priority Critical patent/CN110471667A/en
Publication of CN110471667A publication Critical patent/CN110471667A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management

Landscapes

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

Abstract

Present disclose provides a kind of method, apparatus, medium and electronic equipments for auditing source program.The described method includes: obtaining the corresponding first logical grammar tree of the first source program and the corresponding second logical grammar tree of the second source program;Wherein, first source program is the program code write on the basis of second source program;Differentiation processing is carried out to the first logical grammar tree and the second logical grammar tree, obtains difference results;Judge that every difference program code is annotated with the presence or absence of corresponding difference in the difference results;If so, audit passes through;Fail if it is not, then auditing.The disclosure ensure that the consistency of program code and annotation, ensure that the readability and maintainability of program code, improve developer's development efficiency.

Description

Method, device, medium and electronic equipment for auditing source program
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a medium, and an electronic device for auditing a source program.
Background
Software is a collection of computer data and instructions organized in a specific order. Typically implemented in a programming language.
Software development is the process of building a software system or software parts in a system according to user requirements. Software coding, software testing and software maintenance are two important stages in software development.
Software coding usually uses software development tools to perform coding work.
Software testing is the process of operating a program under specified conditions to find out program errors, measure software quality, and evaluate whether it can meet design requirements.
Software maintenance refers to software modification after a software product is released, such as correcting errors, improving performance, or other attributes.
In general, when software is coded, a developer annotates key program codes in the vicinity of the program codes so as to increase readability of software maintenance and improve work efficiency when software is tested or maintained.
However, it is often the case that program code is modified without synchronized modification annotations at the time of software maintenance. Therefore, the program code is inconsistent with the annotation, the readability of the program code is influenced, the difficulty of software maintenance is increased, and the development efficiency is reduced.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
An object of the present disclosure is to provide a method, an apparatus, a medium, and an electronic device for auditing a source program, which can solve at least one of the above-mentioned technical problems. The specific scheme is as follows:
according to a specific embodiment of the present disclosure, in a first aspect, the present disclosure provides a method for auditing a source program, including:
acquiring a first logic syntax tree corresponding to a first source program and a second logic syntax tree corresponding to a second source program; wherein the first source program is a program code written on the basis of the second source program;
performing differentiation processing on the first logic syntax tree and the second logic syntax tree to obtain a differentiation result;
judging whether each difference program code in the difference result has a corresponding difference note;
if yes, the audit is passed;
if not, the audit fails.
According to a second aspect, the present disclosure provides an apparatus for auditing a source program, including:
the device comprises an acquisition unit, a judgment unit and a processing unit, wherein the acquisition unit is used for acquiring a first logic syntax tree corresponding to a first source program and a second logic syntax tree corresponding to a second source program; wherein the first source program is a program code written on the basis of the second source program;
the difference processing unit is used for carrying out difference processing on the first logic syntax tree and the second logic syntax tree to obtain a difference result;
the judging unit is used for judging whether each difference program code in the difference result has a corresponding difference note;
the checking and passing unit is used for passing the checking and passing if the output result of the judging unit is 'yes';
and the auditing failure unit is used for auditing failure if the output result of the judging unit is 'no'.
According to a third aspect, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method of auditing source programs according to any of the first aspects.
According to a fourth aspect thereof, the present disclosure provides an electronic device, comprising: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement a method of auditing source programs according to any of the first aspects.
Compared with the prior art, the scheme of the embodiment of the disclosure at least has the following beneficial effects:
the disclosure provides a method, a device, a medium and an electronic device for auditing a source program. The method comprises the following steps: acquiring a first logic syntax tree corresponding to a first source program and a second logic syntax tree corresponding to a second source program; wherein the first source program is a program code written on the basis of the second source program; performing differentiation processing on the first logic syntax tree and the second logic syntax tree to obtain a differentiation result; judging whether each difference program code in the difference result has a corresponding difference note; if yes, the audit is passed; if not, the audit fails.
The method and the device ensure the consistency of the program codes and the annotations, ensure the readability and the maintainability of the program codes, and improve the development efficiency of developers.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale. In the drawings:
FIG. 1 shows a flow diagram of a method of auditing a source program according to an embodiment of the present disclosure;
FIG. 2 illustrates a block diagram of elements of an apparatus for auditing a source program, according to an embodiment of the present disclosure;
fig. 3 shows an electronic device connection structure schematic according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
Alternative embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
A first embodiment, an embodiment of a method for auditing a source program, is provided for the present disclosure.
An embodiment of the present disclosure is described in detail below with reference to fig. 1, where fig. 1 is a flowchart of a method for auditing a source program according to an embodiment of the present disclosure.
Step S101, a first logic syntax tree corresponding to a first source program and a second logic syntax tree corresponding to a second source program are obtained.
The source program refers to a text file which is not compiled, written according to a certain programming language specification and readable by human beings. Typically written in a high level language (e.g., C + +, JAVA) as well as a low level language (e.g., assembly language, e.g., 8086 assembly language). The source program may be in the form of a book or tape or other carrier, but the most common format is a text file written in a program code editor, which is typically intended to compile a computer executable program. The source program is composed of a plurality of pieces of program code.
Program code means computer language instructions readable by a human.
In an embodiment of the present disclosure, the first source program is a program code written on the basis of the second source program. For example, when software is tested or maintained, a software exception is often found, and a software developer needs to modify a source program to solve the problem of the software exception, where the source program including the software exception before modification is a second source program, and after modification is performed on the second source program, an obtained source program is a first source program.
A logical syntax tree, which is an abstract representation of the syntax structure of the source program; it represents the syntactic structure between program codes in the form of tree, and each node in the tree represents a structure in the source program. The grammar does not represent every detail that appears in the true grammar; for example, nesting brackets are implicit in the structure of the tree and are not present in the form of nodes; whereas a conditional jump statement like the if-condition-then may be represented using a node with two branches. For example, the first logical syntax tree and the second logical syntax tree are Abstract Syntax Trees (AST).
The obtaining of the first logical syntax tree corresponding to the first source program includes:
and carrying out syntactic analysis on the first source program through a preset syntactic analyzer to obtain the first logic syntactic tree.
In computer science and linguistics, parsing is a process of analyzing an input text composed of a sequence of words according to a preset-form grammar and determining a grammatical structure thereof.
The parser is used for syntax checking of the source program and building of data structures before compiling. For example, a data structure of an abstract syntax tree is constructed for the source program.
The obtaining of the second logical syntax tree corresponding to the second source program includes the following steps:
step S101-1, acquiring serialized data.
Since the logical syntax tree is not suitable for storage, a second logical syntax tree needs to be serialized to store the logical syntax tree.
Serialization processing is the process of converting the state information of an object into a storable form. In the disclosed embodiment, the process is to convert the second logical syntax tree into serialized data.
The serialized data is the data that the second logical syntax tree converts to storable form.
In the embodiment of the present disclosure, the first source program is a program code written based on the second source program, and the second source program is used as a reference to perform differentiation processing, and whether the difference program code in the first source program has a corresponding difference annotation is checked.
The differentiation process is to calculate and output different points of two states.
The difference program code is the program code in the second source program that is different from the first source program, i.e., the modified program code.
Comments are words in the source program that explain the purpose of the program code.
A difference annotation is an annotation in the second source program that is different from the first source program, i.e., a modified annotation.
Thus, optionally, the second source program is a source program that is passed through the audit, i.e., the difference program code in the second source program has a corresponding difference annotation relative to the first source program. Therefore, the validity of the difference program code and the difference annotation of the second source program can be guaranteed, and the consistency of the difference program code and the difference annotation can also be guaranteed.
And S101-2, performing deserialization processing on the serialized data to obtain the second logic syntax tree.
Deserialization is the process of reading serialized data from storage and recreating the state information for the object. In the disclosed embodiment, the process is to convert the serialized data into a second logical syntax tree.
Step S102, carrying out differentiation processing on the first logic syntax tree and the second logic syntax tree to obtain a difference result.
Optionally, the obtaining the difference result includes the following steps:
step S102-1, obtaining a difference result associated with the first logical syntax tree.
Only the content associated with the first logical syntax tree, i.e., only the content associated with the first source program, is present in the difference result. The content of the second logic syntax tree or the second source program is filtered, so that the difference result has higher pertinence and more clear audit, and the audit efficiency and the audit accuracy can be improved.
Step S103, determining whether each difference program code in the difference result has a corresponding difference annotation.
Optionally, the determining whether each difference program code in the difference result has a corresponding difference annotation includes the following steps:
and step S103-1, judging whether each difference program code in each difference node has a corresponding difference note in the difference result.
In the difference result, difference program code and/or difference annotations are recorded in units of nodes (e.g., function nodes) of a logical syntax tree. The nodes that have recorded the difference program code and/or difference annotations are difference nodes.
The step is to examine whether each difference program code in the difference node has a corresponding difference note by taking the difference node as a unit.
And step S104, if yes, the audit is passed.
The method of the disclosed embodiment further comprises the following steps:
and step S104-1, if the audit is passed, compiling the first source program to generate a first program.
Compilation is the process of translating program code of a human-readable source program into binary instructions that can be executed by a computer. Typically by various compilers.
Optionally, the method further comprises the following steps:
and step S104-2, if the examination is passed, carrying out serialization processing on the first logic syntax tree to generate serialized data.
The purpose of this step is to facilitate the conversion of the serialized data into the second logical syntax tree for the next audit to be used as an audit reference for the first logical syntax tree.
After the generating of the serialized data, further comprising the steps of:
and step S104-3, storing the serialized data in a preset memory.
And step S105, if not, the auditing is failed.
And after the audit fails, the first source program is not compiled.
Optionally, the method further comprises the following steps:
and if the audit fails, prompting failure information.
Further, the prompting of the failure information includes:
and prompting the difference program code that no corresponding difference annotation exists.
The embodiment of the disclosure ensures the consistency of the program code and the annotation, ensures the readability and maintainability of the program code, and improves the development efficiency of developers.
Corresponding to the first embodiment provided by the present disclosure, the present disclosure also provides a second embodiment, that is, an apparatus for auditing a source program. Since the second embodiment is basically similar to the first embodiment, the description is simple, and the relevant portions should be referred to the corresponding description of the first embodiment. The device embodiments described below are merely illustrative.
Fig. 2 illustrates an embodiment of an apparatus for auditing a source program according to the present disclosure. Fig. 2 is a block diagram of a unit of an apparatus for auditing a source program according to an embodiment of the present disclosure.
Referring to fig. 2, the present disclosure provides an apparatus for auditing a source program, including: the device comprises an acquisition unit 201, a differentiation processing unit 202, a judgment unit 203, an examination passing unit 204 and an examination failure unit 205.
An obtaining unit 201, configured to obtain a first logical syntax tree corresponding to a first source program and a second logical syntax tree corresponding to a second source program; wherein the first source program is a program code written on the basis of the second source program;
a difference processing unit 202, configured to perform difference processing on the first logical syntax tree and the second logical syntax tree to obtain a difference result;
a judging unit 203, configured to judge whether each difference program code in the difference result has a corresponding difference annotation;
an audit passing unit 204, configured to pass the audit if the output result of the determining unit is "yes";
an audit failure unit 205, configured to fail the audit if the output result of the determining unit is "no".
Optionally, the obtaining unit 201 includes:
and the obtaining first logic syntax tree subunit is used for carrying out syntax analysis on the first source program through a preset syntax analyzer to obtain the first logic syntax tree.
Optionally, the apparatus further comprises:
and the compiling unit is used for compiling the first source program to generate a first program if the audit is passed.
Optionally, the apparatus further comprises:
and the serialization processing unit is used for carrying out serialization processing on the first logic syntax tree if the audit is passed, and generating serialization data.
Optionally, the obtaining unit 201 further includes:
a obtain serialized data subunit for obtaining the serialized data;
and acquiring a second logic syntax tree subunit, configured to perform deserialization processing on the serialized data to acquire the second logic syntax tree.
Optionally, the differentiation processing unit 202 includes:
a difference processing subunit, configured to obtain a difference result associated with the first logical syntax tree.
Optionally, the determining unit 203 includes:
and the difference node judging subunit is used for judging whether each difference program code in each difference node has a corresponding difference note in the difference result.
The embodiment of the disclosure ensures the consistency of the program code and the annotation, ensures the readability and maintainability of the program code, and improves the development efficiency of developers.
The third embodiment of the present disclosure provides an electronic device, where the electronic device is used for a method for reviewing a source program, and the electronic device includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the one processor to cause the at least one processor to perform the method of auditing source programs according to the first embodiment.
A fourth embodiment of the present disclosure is a computer storage medium for auditing a source program, where the computer storage medium stores computer-executable instructions that can execute the method for auditing a source program as described in the first embodiment.
Referring now to FIG. 3, shown is a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 3, the electronic device may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 301 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)302 or a program loaded from a storage device 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data necessary for the operation of the electronic apparatus are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
Generally, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 308 including, for example, magnetic tape, hard disk, etc.; and a communication device 309. The communication means 309 may allow the electronic device to communicate wirelessly or by wire with other devices to exchange data. While fig. 3 illustrates an electronic device having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 309, or installed from the storage means 308, or installed from the ROM 302. The computer program, when executed by the processing device 301, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring at least two internet protocol addresses; sending a node evaluation request comprising the at least two internet protocol addresses to node evaluation equipment, wherein the node evaluation equipment selects the internet protocol addresses from the at least two internet protocol addresses and returns the internet protocol addresses; receiving an internet protocol address returned by the node evaluation equipment; wherein the obtained internet protocol address indicates an edge node in the content distribution network.
Alternatively, the computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving a node evaluation request comprising at least two internet protocol addresses; selecting an internet protocol address from the at least two internet protocol addresses; returning the selected internet protocol address; wherein the received internet protocol address indicates an edge node in the content distribution network.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation of the unit itself, for example, the first retrieving unit may also be described as a "unit for retrieving at least two internet protocol addresses".
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (10)

1. A method of auditing a source program, comprising:
acquiring a first logic syntax tree corresponding to a first source program and a second logic syntax tree corresponding to a second source program; wherein the first source program is a program code written on the basis of the second source program;
performing differentiation processing on the first logic syntax tree and the second logic syntax tree to obtain a differentiation result;
judging whether each difference program code in the difference result has a corresponding difference note;
if yes, the audit is passed;
if not, the audit fails.
2. The method of claim 1, wherein obtaining the first logical syntax tree corresponding to the first source program comprises:
and carrying out syntactic analysis on the first source program through a preset syntactic analyzer to obtain the first logic syntactic tree.
3. The method of claim 1, further comprising:
and if the audit is passed, compiling the first source program to generate a first program.
4. The method of claim 1, further comprising:
and if the examination is passed, carrying out serialization processing on the first logic syntax tree to generate serialized data.
5. The method of claim 4, wherein obtaining the second logical syntax tree corresponding to the second source program comprises:
acquiring the serialized data;
and performing deserialization processing on the serialized data to obtain the second logic syntax tree.
6. The method of claim 1, wherein obtaining the difference result comprises:
obtaining a difference result associated with the first logical syntax tree.
7. The method of claim 1, wherein the determining whether each difference program code in the difference result has a corresponding difference annotation comprises:
and judging whether each difference program code in each difference node has a corresponding difference note or not in the difference result.
8. An apparatus for auditing a source program, comprising:
the device comprises an acquisition unit, a judgment unit and a processing unit, wherein the acquisition unit is used for acquiring a first logic syntax tree corresponding to a first source program and a second logic syntax tree corresponding to a second source program; wherein the first source program is a program code written on the basis of the second source program;
the difference processing unit is used for carrying out difference processing on the first logic syntax tree and the second logic syntax tree to obtain a difference result;
the judging unit is used for judging whether each difference program code in the difference result has a corresponding difference note;
the checking and passing unit is used for passing the checking and passing if the output result of the judging unit is 'yes';
and the auditing failure unit is used for auditing failure if the output result of the judging unit is 'no'.
9. A computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
10. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to carry out the method of any one of claims 1 to 7.
CN201910676258.6A 2019-07-25 2019-07-25 A kind of method, apparatus, medium and electronic equipment for auditing source program Pending CN110471667A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910676258.6A CN110471667A (en) 2019-07-25 2019-07-25 A kind of method, apparatus, medium and electronic equipment for auditing source program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910676258.6A CN110471667A (en) 2019-07-25 2019-07-25 A kind of method, apparatus, medium and electronic equipment for auditing source program

Publications (1)

Publication Number Publication Date
CN110471667A true CN110471667A (en) 2019-11-19

Family

ID=68508943

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910676258.6A Pending CN110471667A (en) 2019-07-25 2019-07-25 A kind of method, apparatus, medium and electronic equipment for auditing source program

Country Status (1)

Country Link
CN (1) CN110471667A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112162755A (en) * 2020-09-28 2021-01-01 北京字节跳动网络技术有限公司 Data processing method, device, medium and electronic equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107463375A (en) * 2017-07-18 2017-12-12 上海斐讯数据通信技术有限公司 A kind of method and system for detecting source code
CN109445834A (en) * 2018-10-30 2019-03-08 北京计算机技术及应用研究所 The quick comparative approach of program code similitude based on abstract syntax tree

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107463375A (en) * 2017-07-18 2017-12-12 上海斐讯数据通信技术有限公司 A kind of method and system for detecting source code
CN109445834A (en) * 2018-10-30 2019-03-08 北京计算机技术及应用研究所 The quick comparative approach of program code similitude based on abstract syntax tree

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
孟薇: "C/C++代码审查辅助工具的设计与实现", 《中国优秀硕士学位论文全文数据库信息科技辑》 *
左翔宇: "跨项目细粒度代码变更的缺陷预测方法研究", 《中国优秀硕士学位论文全文数据库信息科技辑》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112162755A (en) * 2020-09-28 2021-01-01 北京字节跳动网络技术有限公司 Data processing method, device, medium and electronic equipment
CN112162755B (en) * 2020-09-28 2023-03-31 抖音视界有限公司 Data processing method, device, medium and electronic equipment

Similar Documents

Publication Publication Date Title
CN112104709B (en) Intelligent contract processing method, device, medium and electronic equipment
CN111324342B (en) Method, device, medium and electronic equipment for generating interface layer code
CN110543297B (en) Method and apparatus for generating source code
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN109947431B (en) Code generation method, device, equipment and storage medium
CN114035805B (en) Transcoding method, device, medium and equipment for precompiled device
CN110377289A (en) A kind of data analysis method, device, medium and electronic equipment
CN111381817A (en) Method, device, medium and electronic equipment for realizing cross-platform multi-language development
CN112395253B (en) Index file generation method, terminal device, electronic device and medium
CN111124541B (en) Configuration file generation method, device, equipment and medium
CN113778897B (en) Automatic test method, device and equipment for interface and storage medium
CN110471667A (en) A kind of method, apparatus, medium and electronic equipment for auditing source program
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN111367791B (en) Method, device, medium and electronic equipment for generating test case
CN111414161B (en) Method, device, medium and electronic equipment for generating IDL file
CN113138767B (en) Code language conversion method, device, electronic equipment and storage medium
CN111539200B (en) Method, device, medium and electronic equipment for generating rich text
CN114968260A (en) Hybrid pre-compiling method and device, electronic equipment and storage medium
CN112394920B (en) Application software development method, platform and electronic equipment
CN114047923A (en) Error code positioning method, device, storage medium and electronic equipment
CN114035804A (en) Code conversion method, device, medium and electronic equipment
CN113419716A (en) Code generation method and device, terminal equipment and storage medium
CN111399902A (en) Client source file processing method and device, readable medium and electronic equipment
CN117555542A (en) Transcoding method, transcoding device, electronic device and computer readable medium
CN115878091A (en) Data processing method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20191119