WO2020146205A1 - Source code similarity detection using digital fingerprints - Google Patents
Source code similarity detection using digital fingerprints Download PDFInfo
- Publication number
- WO2020146205A1 WO2020146205A1 PCT/US2020/012197 US2020012197W WO2020146205A1 WO 2020146205 A1 WO2020146205 A1 WO 2020146205A1 US 2020012197 W US2020012197 W US 2020012197W WO 2020146205 A1 WO2020146205 A1 WO 2020146205A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- source code
- processor
- blocks
- control flow
- tokens
- 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.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/75—Structural analysis for program understanding
- G06F8/751—Code clone detection
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/901—Indexing; Data structures therefor; Storage structures
- G06F16/9027—Trees
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
- G06F8/425—Lexical analysis
Definitions
- the present disclosure is related, generally, to management of program source code and, more particularly, to locating and identifying duplicate or similar program source code across an enterprise.
- source code fragments are portions of existing programming code
- minor changes are often made to the pasted source code fragments.
- source code fragments often introduces defects in existing source code, including when developers overlook making updates to source code fragments that have been copied and pasted many times.
- copied source code often does not comply with copyright and/or licensing restrictions, which creates compliance issues. Maintenance of source code, such as with extensions and patches, often need to be applied to each respective copied source code fragment which can be difficult or impossible to locate, particularly after years of copying and pasting.
- source code tools have been developed that identify exact and/or similar code fragments. These tools often work by scanning source code or a representation thereof to identify pieces of code (e.g., source code fragments) that are the same or similar. Often these tools are limited to“brute-force” methods that are unable to handle a program codebase that is large or complex.
- Traditional source code tools are often unable to present results of detection and analyses in a usable and useful manner to a software developer.
- conventional tools are unable to locate source code fragments that are textually different, such as due to variable renaming, statement insertions, deletions, and replacements, but that still share enough similarity to be considered duplicative. This makes precise searching techniques infeasible and, as a result, traditional source code tools tend to over-compensate and over-approximate. Over-approximating results in a considerable number of false positives, which often requires manual inspection.
- the present application provides systems and methods for identifying similarity in source code in accordance with searching digital fingerprints representing at least blocks of programming statements.
- At least one processor that is configured by executing program instructions stored on non-transitory processor- readable media accesses programming source code.
- At least some of the source code is converted into a plurality of respective tokens, wherein each of the tokens is associated with a plurality of blocks of programming statements.
- the tokens are modified by normalizing at least one value in at least one of the plurality of blocks of programming statements, and/or by defining at least one abstraction associated with at least one operation associated with at least one of the blocks of programming statements.
- a representation is created which is associated with control flow of a plurality of blocks associated with a respective token.
- the control flow includes a plurality of possible operational paths associated with the blocks in each of the modified tokens.
- a digital fingerprint representing a respective operational path associated with the control flow for a given token is generated.
- source code within at least one block of a given token is determined and identifiable as being a duplicate of source code stored in a repository by comparing at least one of the generated digital fingerprints and at least one previously generated digital fingerprint.
- an abstract syntax tree is generated by at least one processor from the tokens, wherein the abstract syntax tree comprises a plurality of nodes corresponding to the source code.
- the abstract syntax tree is derived by: defining a root element; assigning statements to each of at least one child node of the root element; and assigning a value and/or a variable to each of the at least one child node.
- the generated representation associated with the control flow is a control flow graph.
- the control flow graph is generated using an abstract syntax tree which is generated from the tokens.
- the generated digital fingerprint further represents control flow associated with a plurality of the blocks.
- a digital fingerprint is generated which represents a source code program associated with at least one of the tokens.
- At least one processor identifies, as a function of searching and detecting a match between the generated digital fingerprint representing the source code program and at least one previously generated digital fingerprint representing a different source code program, a duplicate of at least part of a source code program associated with at least one of the respective tokens and the different source code program.
- At least one processor determines that the at least one of the generated digital fingerprint representing a source code program and at least one previously generated digital fingerprint representing a different source code program meet a predetermined threshold of similarity. Further, at least one processor identifies the at least one statement that is a duplicate. Further, at least one processor identifies at least one source code program that contains the at least one statement that is a duplicate.
- the digital fingerprint is generated as a function of hashing.
- Fig. 1 is a flow diagram showing a routine that illustrates a broad aspect of the present application, in accordance with one or more embodiments.
- Fig. 2 is a flow diagram illustrating details associated with certain steps illustrated in Fig. 1, in accordance with one or more embodiments of the present application.
- Fig. 3A illustrates an example transformation of program source code in plaintext, which includes assignments, conditional statements, and commands.
- Fig. 3B shows example output that is generated by a tokenizer, in accordance with an example implementation of the present application.
- Fig. 4A illustrates an example abstract syntax tree that is generated from tokens that were normalized and augmented with metadata.
- Fig. 4B illustrates example output representing an abstract syntax tree, in accordance with the present application.
- Fig. 5 illustrates an example collection of blocks that were generated from the abstract syntax tree shown in Fig. 4A.
- FIGs. 5 A and 5B illustrate two similar, but not identical, control flow graphs that are identifiable as representing duplicative source code fragments in accordance with one or more implementations of the present application.
- FIGs. 6A and 6B illustrate an example implementation of the present application in connection with improved searching techniques by grouping fingerprints
- Fig. 7 is a block diagram that shows an example hardware arrangement that operates for providing the systems and methods disclosed herein.
- Fig. 8 shows an example of an information processor that can be used to implement the techniques described herein the present application.
- program source code that is termed“duplicate” or“duplicative” refers, generally, to at least a portion of program source code that is identical or similar to other program source code within prescribed criteria, including within prescribed tolerances.
- the digital fingerprints which are used as a basis for searching for duplicative source code, can be generated within a processor using code executing therein to process a digital representation of source code, including the execution behavior of the source code, and by hashing processes to enable improved matching of similar source code.
- implementations of the present application use control dependency graphs to capture interrelations between different components of source code, and control flow graphs are used to represent the execution behavior of the source code.
- techniques can be implemented to determine whether two source code fragments are similar, rather than identical.
- so-called“fuzzy” hashing techniques can be used to reduce large files into relatively small number of data values, which are then hashed and used for searching. This improves searching processes for duplicative source code, particularly against large source code bases such as those in enterprise resource planning (“ERP”) systems.
- ERP enterprise resource planning
- source code is processed and represented by generic control flow programming blocks.
- the blocks are transformed, for example, by using one or more hashing functions to generate unique digital fingerprints.
- the digital fingerprints represent code semantics as well as code execution behavior.
- the fingerprints can be stored and later used for searching for duplicate source code.
- the technical features presented herein include analysis of the digital representation of a source code control flow graph in which specific blocks in the control flow graph are transformed into digital fingerprints.
- a control flow graph is used colloquially with the understanding that that the machine processing and analyzing the source code in question is actually operating on digital representations of the control flow graph, rather than on an actual“graph.”
- the digital fingerprints can be derived from representations of generic code constructs in the source code, as well as the way such constructs are used. Practical complexities associated with scalability and flexibility are addressed by incrementally storing and reusing digital fingerprints for searching and locating duplicate source code.
- control-flow graphs in the present application is advantageous to identify all possible paths that can be traversed by a program during execution, which can be represented using graph notations. Minor and relatively insignificant differences between different source code fragments need not be represented in different respective graphs, which improves the likelihood of identifying duplicative source code that may not be strictly identical.
- the present application supports grouping and clustering which can also speed up searching in ERP systems. This approach improves upon known techniques that rely on searching source code fragments (i.e., hash blocks table) by comparing code against every piece of code in a source code repository (e.g.,“pairwise comparison”). Such pairwise comparison techniques in large source code repositories are overly intensive and require significant computing and storage resources.
- a flow diagram is described showing a routine 100 that illustrates a broad aspect of a method for converting and searching for duplicate source code in accordance with one or more embodiments of the present application.
- a routine 100 that illustrates a broad aspect of a method for converting and searching for duplicate source code in accordance with one or more embodiments of the present application.
- the logical operations described herein are implemented as a sequence of computer-implemented acts or program modules running on one or more computing devices. Accordingly, the logical operations described herein are referred to variously as operations, steps, structural devices, acts and modules can be implemented in software, in firmware, in special purpose digital logic, and any combination thereof. It should also be appreciated that more or fewer operations can be performed than shown in the figures and described herein. These operations can also be performed in a different order than those described herein.
- the process begins at step 102.
- program source code is accessed, which is a basis for a search for duplicate source code.
- the source code is accessed by a computing system configured by executing instructions that are stored on non-transitory processor-readable media.
- the program source code can be accessed from a source code repository that stores existing source code.
- the program source code can be accessed substantially in real time, including as it is being developed.
- the accessed source code is transformed, at least in part by extracting discrete portions of the source code (e.g., source code fragments) and augmenting the source code fragments with metadata. Details regarding transforming source code pursuant to step 106 in accordance with one or more implementations of the present application are provided below.
- digital fingerprints are generated.
- a digital fingerprint that was generated at step 108 is compared with stored digital fingerprints that were previously generated from other transformed source code fragments.
- the digital fingerprint generated from the transformed source code is “matched” with one or more other stored digital fingerprints, by means of the processor being configured by code to determine instances in which source code within at least one block of a given token which is identifiable as being a duplicate of source code stored in a repository. Such a determination can be made by identifying matches within one or more prescribed tolerances, such above 0.993.
- B df represents one or more blocks which are not equal and stored in different locations.
- B ma represents one or more blocks that are equal but misaligned, and a is a sensitivity factor.
- step 114 the program source code associated with the matched stored fingerprint is located and obtained, and the source code is identified is being a“duplicate.” Thereafter, at step 116 the process ends.
- steps are provided for identifying similarity in source code in accordance with searching digital fingerprints representing at least blocks of programming statements, in lieu of a comparison of the source code itself.
- fingerprints generated in accordance with the teachings herein can be grouped or clustered based at least on the same or similar X number of blocks.
- the groups are used during searching for duplicative source code by identifying a first X number of blocks of a particular fingerprint to search for one or more other fingerprints within one or more respective groups in accordance with the initial X number bocks. Thereafter, additional searching for duplicative source code, such as by pairwise comparisons, can occur for just the source code associated with the fingerprint(s) within the respective group(s).
- This technique improves the efficacy and efficiency of a search of source code, such as within a large codebase, by reducing detailed searching (e.g., pairwise comparisons) to one or more subsets of the codebase.
- FIG. 2 is a flow diagram illustrating additional details associated with certain steps illustrated in Fig. 1, in accordance with one or more embodiments of the present application.
- Fig. 2 illustrates steps associated with transforming and augmenting program source code (step 106) and with generating digital fingerprints from the transformed/augmented program source code (step 108).
- the source code is extracted, such as by being converted from a compressed format to plaintext (step 202).
- tokens are identified in the program source code (step 204).
- a tokenizer as known by one of ordinary skill in the art, is employed to parse the program source code into tokens. Tokens can be identified in the program source code by finding whitespace (e.g., tabs, spaces, new lines) or other recognizable aspects in the program source code.
- whitespace e.g., tabs, spaces, new lines
- a suitable lexical extractor as known by one of ordinary skill in the art is employed to normalize the tokens identified in the program source code, including by adding extra context to the tokens.
- metadata can be appended to tokens that identify tokens as numbers, string literals, equality operators, or the like.
- user-defined identifiers in the tokens can be replaced with specific fixed tokens, for example, to ensure that changes in variable names and other modifiers can be detected during searches for duplicate source code.
- normalized values such as a respective identifier name and a corresponding literal value, can be fixed with a specific token.
- a local variable named “variableName” can be replaced by “l_variableName.”
- abstractions of syntactic structure such as IF statements, CASE statements and LOOPs, can be normalized to ensure that minor changes made to copies of such code, including changes which do not impact the functionality the code during operation, are accounted for. Table 1, below, illustrates example normalization structures.
- an abstract syntax tree is generated from the normalized tokens (step 208).
- Each node in the abstract syntax tree can correspond to an abstract component in the program source code that was normalized in step 206, (e.g., a function declaration, an operator, or other component).
- a tree node in the abstract syntax tree is a tuple.
- the first component in the tree represents the type or name of the node followed by zero or more components, each representing a child of a current node. More particularly, the abstract syntax tree is derived by defining the root element, assigning statements as child node(s), and adding variables and values to the child node(s).
- control flow graph (step 210).
- the control flow is derived by a) identifying basic blocks which include no branches or conditions, and by b) identifying every node except the first node, which has only one path in and one path out.
- control flow represents an order in which statements in source code execute.
- control flow can represent different possible paths that a certain software program will take during execution.
- a set of statements are structured as a block, in which all statements in the block are executed in the same scope of control.
- the present application improves upon searching for duplicative source code, including by using specific representations of source code execution behavior, and by hashing techniques and refined searching of subsets of source code within a codebase.
- a control flow graph is generated using the abstract syntax tree by exploring different execution paths in the code.
- intermediate code of each node is divided into basic blocks (Bn). More particularly, an example basic block is a fragment of straight line code, in which no jumps (i.e., loops or conditional statements) occur in or out of the middle of the respective block.
- blocks are identified as a function of one or more determinations, including by determining a set of block leaders (L) (i.e., first line of basic block B). In one or more implementations, the first line in a block is always determined to be a leader.
- any line is a leader if the block contains a tuple IF ...goto Bn, goto Bn, i.e., are loops. Furthermore, a line that immediately follows IF ...GOTO Bn or if GOTO Bn is a leader. Moreover, in one or more implementations, a basic block Bn includes a leader and all the following statements until the next leader.
- the basic blocks within one software program are organized as a control flow graph.
- the control flow graph has basic blocks B1 ⁇ ⁇ ⁇ Bn as nodes, and has a directed edge, B1->B2, for example if control can flow from B1 to B2.
- the following conditions are usable for organizing blocks within programming source code in accordance with one or more implementations of the present application.
- Directed edges are constructed from jump instructions, while conditional jumps specify two directed edges.
- Conditional jumps can include one jump from a current node to its direct successor node, and another jump from a current node to a respective node resulting from program control flow.
- Unconditional jumps can define one direct edge from a current node to its direct successor node.
- nodes“ENTER” and“EXIT” can be treated as a source and sink of the control flow graph.
- These nodes represented in a control flow graph and respective hashing and grouping functionality shown and described herein improve upon searching for duplicative source code, particularly in large ERP systems.
- Figs. 3A, 3B, 4A, and 4B illustrate a transformation process of program source code from plaintext to a control flow graph, in accordance with an example implementation of the present application.
- Fig. 3A illustrates an example transformation of program source code 302 in plaintext, which includes assignments, conditional statements, and commands.
- the source code 302 is expressed in respective table tokens 304.
- Fig. 3B shows example output 302 that is generated by a tokenizer.
- Fig. 4 A illustrates an example abstract syntax tree 402 that is generated from the tokens that were normalized and augmented with metadata.
- Fig. 4B illustrates example output representing an abstract syntax tree, in accordance with the present application.
- Fig. 5 illustrates an example collection of blocks 502 that were generated from the abstract syntax tree 402.
- example control flow graph 504 is illustrated in Fig. 5 that is generated from the blocks 502.
- Figs. 5A and 5B illustrate two similar, but not identical, control flow graphs that are identifiable as representing duplicative source code, in accordance with one or more implementations of the present application.
- differences include: block“a” of Fig. 5A is not included in the control flow graph shown in Fig. 5B, thus there is no flow from block a -> block d in Fig. 5B.
- FIG. 5A does not include flow from (start)-> block d, which is shown in the control flow graph of Fig. 5B. Notwithstanding these subtle differences, the control flow graphs shown in Figs. 5A and 5B are identifiable to represent duplicative source code fragments.
- execution paths in the control flow can be enumerated. For example, and as set forth in the example shown in Fig. 5, three execution paths (B1: B2: B4, B1: B4, B1: B2: B4) are supported.
- a digital fingerprint is generated.
- a fixed size fingerprint for each block B is generated based on a fixed size similarity hashing.
- a fixed size fingerprint is generated by: Hash statement i 0 ->/ with collision resistance h(Si).
- Table 2 illustrates an example of digital fingerprints of blocks in accordance with respective control flow graphs for two programs (P, P’).
- program P and P’ include duplicate source code.
- the present application provides for searching fingerprints to identify similar code in a source code repository and to identify source code fragments that are identical or near identical in linear time.
- a fixed size similarity hash such as Jaccard distance or other distance metric can be generated from the software program.
- Jaccard distance is useful to compare dissimilarity of respective samples, including as a function of a measure of overlap between a fingerprint representing a respective block and one or more stored fingerprints. If the dissimilarity is within a predefine tolerance, then the fingerprints can be considered matched and source code within a respective block to be a duplicate of the source code.
- two distinct hash tables can be generated: one for fixed program size fingerprints, and one for the blocks. For example, while searching for a program source code duplicate and where a similarity threshold is met, the programming blocks are compared using the blocks in the hash table associated with the blocks (i.e., blocks hash table).
- Use of two respective hash tables is particularly useful for identifying the program and also the specific fragments of code that are being or have been copied.
- the fingerprinting techniques disclosed herein improve speed and efficiency of searches for similar code in large-scale program code repositories.
- comparisons which yield smaller distances between different fingerprints, identify a relatively high probability of source code fragments having“close” hash codes, which can be recognized as being identical or similar (i.e., duplicative).
- Fingerprint b1 is hashed and grouped in group2, while fingerprints b2 and b3 are hashed and grouped in group3, on the basis of the first 3 hash blocks of those fingerprints.
- the first hash blocks of the new fingerprint are determined and be used for searching for relevant clusters or groups.
- the size of the groups is smaller than a full database of fingerprints, which results in considerable speed improvement and reduction in search time. Hashing blocks into buckets results in similar fingerprints being grouped and searched for in the same bucket.
- a hash lookup is performed by determining whether other blocks in a respective group or cluster are matched with those of a given fingerprint.
- a fingerprint “dictionary” is referenced to identify similar fingerprints within one or more groups. If the lookup fails, meaning that no blocks in a group or cluster are identified to be within a predefined threshold of similarity with blocks in a respective fingerprint, then a determination is made that there is no duplicative source code. Alternatively, if the lookup succeeds, source code which is associated with the located fingerprint(s) is identified.
- the source code associated with the respective (target) fingerprint is compared more precisely, such as via a pairwise comparison, with the source code associated with the group(s) of fingerprints to determine whether a predetermined threshold of similarity is met. If the threshold is met, then the source code is determined to be duplicative.
- a search for fingerprints within one or more groups or clusters may initially generate a set of search results having a relatively high false positive rate. However, the results are refined, thereafter, such as via a pairwise search of the associated source code file in the subset of the code, based on the retrieved fingerprints. It is to be appreciated that the present application is not limited to the example source code transformation and representation techniques shown and described herein, and that alternative techniques are available that may be better suited in a particular implementation.
- a cfg fuzzy hash can use basic blocks, edge and statements, and assign a different prime value to each different feature. Thereafter, a hash is generated by just prime value multiplication and modulo all the values.
- the following algorithm can be executed that includes the following features:
- the final generated‘hash’ is a large number result of the multiplication. This hash is usable to perform another search based on the control flow graph. The results from this search can finally be combined with text search to estimate with high confidence the syntax and semantic similarity of particular source code.
- a respective digital fingerprint that represents a program file preferably is generated using a similarity measure to account for misalignments, as well as for content differences. It is recognized by the inventors that use of a fixed fingerprint allows for faster, more space efficient searching of the code.
- System 700 can include one or more information processors 702 that are at least communicatively coupled to one or more user computing devices 704 across communication network 706.
- Information processors 702 and user computing devices 704 can include, for example, mobile computing devices such as tablet computing devices, smartphones, personal digital assistants or the like, as well as laptop computers and/or desktop computers, server computers and mainframe computers. Further, one computing device may be configured as an information processor 702 and a user computing device 704, depending upon operations being executed at a particular time.
- information processor 702 can be configured to access one or more databases 703 for the present application, including source code repositories and other information. However, it is contemplated that information processor 702 can access any required databases via communication network 706 or any other communication network to which information processor 702 has access. Information processor 702 can communicate with devices comprising databases using any known communication method, including a direct serial, parallel, universal serial bus (“USB”) interface, or via a local or wide area network.
- USB universal serial bus
- User computing devices 704 can communicate with information processors 702 using data connections 708, which are respectively coupled to communication network 706.
- Communication network 706 can be any communication network, but typically is or includes the Internet or other computer network.
- Data connections 708 can be any known arrangement for accessing communication network 706, such as the public internet, private Internet (e.g. VPN), dedicated Internet connection, or dial-up serial line interface protocol/point-to-point protocol (SLIPP/PPP), integrated services digital network (ISDN), dedicated leased-line service, broadband (cable) access, frame relay, digital subscriber line (DSL), asynchronous transfer mode (ATM) or other access techniques.
- VPN public internet
- private Internet e.g. VPN
- SLIPP/PPP dial-up serial line interface protocol/point-to-point protocol
- ISDN integrated services digital network
- DSL digital subscriber line
- ATM asynchronous transfer mode
- User computing devices 704 preferably have the ability to send and receive data across communication network 706, and are equipped with web browsers, software applications, or other means, to provide received data on display devices incorporated therewith.
- user computing device 704 may be personal computers such as Intel Pentium-class and Intel Core-class computers or Apple Macintosh computers, tablets, smartphones, but are not limited to such computers.
- Other computing devices which can communicate over a global computer network such as palmtop computers, personal digital assistants (PDAs) and mass-marketed Internet access devices such as WebTV can be used.
- PDAs personal digital assistants
- the hardware arrangement of the present invention is not limited to devices that are physically wired to communication network 706, and that wireless communication can be provided between wireless devices and information processors 702.
- System 700 preferably includes software that provides functionality described in greater detail herein, and preferably resides on one or more information processors 702 and/or user computing devices 704.
- information processor 702 One of the functions performed by information processor 702 is that of operating as a web server and/or a web site host.
- Information processors 702 typically communicate with communication network 706 across a permanent i.e., un-switched data connection 708. Permanent connectivity ensures that access to information processors 702 is always available.
- Fig. 8 shows an example information processor 702 that can be used to implement the techniques described herein.
- the information processor 702 is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers.
- the components shown in Fig. 8, including connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed in this document.
- the information processor 702 includes a processor 802, a memory 804, a storage device 806, a high-speed interface 808 connecting to the memory 804 and multiple high-speed expansion ports 810, and a low-speed interface 812 connecting to a low-speed expansion port 814 and the storage device 806.
- Each of the processor 802, the memory 804, the storage device 806, the high-speed interface 808, the high-speed expansion ports 810, and the low-speed interface 812 are interconnected using various busses, and can be mounted on a common motherboard or in other manners as appropriate.
- the processor 802 can process instructions for execution within the information processor 702, including instructions stored in the memory 804 or on the storage device 806 to display graphical information for a GUI on an external input/output device, such as a display 816 coupled to the high-speed interface 808.
- an external input/output device such as a display 816 coupled to the high-speed interface 808.
- multiple processors and/or multiple buses can be used, as appropriate, along with multiple memories and types of memory.
- multiple computing devices can be connected, with each device providing portions of the necessary operations (e.g., as a server bank, a group of blade servers, or a multi-processor system).
- the memory 804 stores information within the information processor 702.
- the memory 804 is a volatile memory unit or units.
- the memory 804 is a non-volatile memory unit or units.
- the memory 804 can also be another form of computer-readable medium, such as a magnetic or optical disk.
- the storage device 806 is capable of providing mass storage for the information processor 702.
- the storage device 806 can be or contain a computer- readable medium, e.g., a computer-readable storage medium such as a floppy disk device, a hard disk device, an optical disk device, or a tape device, a flash memory or other similar solid- state memory device, or an array of devices, including devices in a storage area network or other configurations.
- a computer program product can also be tangibly embodied in an information carrier.
- the computer program product can also contain instructions that, when executed, perform one or more methods, such as those described above.
- the computer program product can also be tangibly embodied in a computer- or machine-readable medium, such as the memory 804, the storage device 806, or memory on the processor 802.
- the high-speed interface 808 can be configured to manage bandwidth-intensive operations, while the low-speed interface 812 can be configured to manage lower bandwidth intensive operations.
- the high-speed interface 808 is coupled to the memory 804, the display 816 (e.g., through a graphics processor or accelerator), and to the high-speed expansion ports 810, which can accept various expansion cards (not shown).
- the low-speed interface 812 is coupled to the storage device 806 and the low-speed expansion port 814.
- the low-speed expansion port 814 which can include various communication ports (e.g., USB, Bluetooth, Ethernet, wireless Ethernet) can be coupled to one or more input/output devices, such as a keyboard, a pointing device, a scanner, or a networking device such as a switch or router, e.g., through a network adapter.
- input/output devices such as a keyboard, a pointing device, a scanner, or a networking device such as a switch or router, e.g., through a network adapter.
- the information processor 702 can be implemented in a number of different forms, as shown in the figure. For example, it can be implemented as a standard server, or multiple times in a group of such servers. In addition, it can be implemented in a personal computer such as a laptop computer. It can also be implemented as part of a rack server system. Alternatively, components from the computing device 200 can be combined with other components in a mobile device (not shown), such as a mobile computing device.
- the term“communicating device,” as used in this disclosure, means any hardware, firmware, or software that can transmit or receive data packets, instruction signals or data signals over a communication link.
- the hardware, firmware, or software can include, for example, a telephone, a smart phone, a personal data assistant (PDA), a smart watch, a tablet, a computer, a software defined radio (SDR), or the like, without limitation.
- PDA personal data assistant
- SDR software defined radio
- the term“communication link,” as used in this disclosure, means a wired and/or wireless medium that conveys data or information between at least two points.
- the wired or wireless medium can include, for example, a metallic conductor link, a radio frequency (RF) communication link, an Infrared (IR) communication link, an optical communication link, or the like, without limitation.
- the RF communication link can include, for example, Wi-Fi, WiMAX, IEEE 802.11 , DECT, 0G, 1 G, 2G, 3G or 4G cellular standards, Bluetooth, or the like, without limitation.
- the terms“computer” or“computing device,” as used in this disclosure, means any machine, device, circuit, component, or module, or any system of machines, devices, circuits, components, modules, or the like, which are capable of manipulating data according to one or more instructions, such as, for example, without limitation, a processor, a microprocessor, a central processing unit, a general purpose computer, a super computer, a personal computer, a laptop computer, a palmtop computer, a notebook computer, a desktop computer, a workstation computer, a server, a server farm, a computer cloud, or the like, or an array of processors, microprocessors, central processing units, general purpose computers, super computers, personal computers, laptop computers, palmtop computers, notebook computers, desktop computers, workstation computers, servers, or the like, without limitation.
- Non-volatile media can include, for example, optical or magnetic disks and other persistent memory.
- Volatile media can include dynamic random access memory (DRAM).
- Computer-readable media include, for example, a floppy disk, a flexible disk, hard disk, magnetic tape, any other magnetic medium, a CD-ROM, DVD, any other optical medium, punch cards, paper tape, any other physical medium with patterns of holes, a RAM, a PROM, an EPROM, a FLASH-EEPROM, any other memory chip or cartridge, a carrier wave as described hereinafter, or any other medium from which a computer can read.
- the computer-readable medium can include a“Cloud,” which includes a distribution of files across multiple (e.g., thousands of) memory caches on multiple (e.g., thousands of) computers.
- sequences of instruction can be delivered from a RAM to a processor, (ii) can be carried over a wireless transmission medium, and/or (iii) can be formatted according to numerous formats, standards or protocols, including, for example, Wi-Fi, WiMAX, IEEE 802.11, DECT, 0G, 1G, 2G, 3G, 4G, or 5G cellular standards, Bluetooth, or the like.
- transmission and“transmit,” as used in this disclosure, refer to the conveyance of signals via electricity, acoustic waves, light waves and other electromagnetic emissions, such as those generated in connection with communications in the radio frequency (RF) or infrared (IR) spectra.
- Transmission media for such transmissions can include coaxial cables, copper wire and fiber optics, including the wires that comprise a system bus coupled to the processor.
- the term“database,” as used in this disclosure, means any combination of software and/or hardware, including at least one application and/or at least one computer.
- the database can include a structured collection of records or data organized according to a database model, such as, for example, but not limited to at least one of a relational model, a hierarchical model, a network model or the like.
- the database can include a database management system application (DBMS) as is known in the art.
- the at least one application may include, but is not limited to, for example, an application program that can accept connections to service requests from clients by sending back responses to the clients.
- the database can be configured to run the at least one application, often under heavy workloads, unattended, for extended periods of time with minimal human direction.
- the term“network,” as used in this disclosure means, but is not limited to, for example, at least one of a local area network (LAN), a wide area network (WAN), a metropolitan area network (MAN), a personal area network (PAN), a campus area network, a corporate area network, a global area network (GAN), a broadband area network (BAN), a cellular network, the Internet, or the like, or any combination of the foregoing, any of which can be configured to communicate data via a wireless and/or a wired communication medium.
- LAN local area network
- WAN wide area network
- MAN metropolitan area network
- PAN personal area network
- GAN global area network
- BAN broadband area network
- cellular network the Internet, or the like, or any combination of the foregoing, any of which can be configured to communicate data via a wireless and/or a wired communication medium.
- These networks can run a variety of protocols not limited to TCP/IP, IRC or HTTP.
- the term“server,” as used in this disclosure, means any combination of software and/or hardware, including at least one application and/or at least one computer to perform services for connected clients as part of a client-server architecture.
- the at least one server application can include, but is not limited to, for example, an application program that can accept connections to service requests from clients by sending back responses to the clients.
- the server can be configured to run the at least one application, often under heavy workloads, unattended, for extended periods of time with minimal human direction.
- the server can include a plurality of computers configured, with the at least one application being divided among the computers depending upon the workload. For example, under light loading, the at least one application can run on a single computer. However, under heavy loading, multiple computers can be required to run the at least one application.
- the server, or any if its computers, can also be used as a workstation.
- Devices that are in communication with each other need not be in continuous communication with each other, unless expressly specified otherwise.
- devices that are in communication with each other may communicate directly or indirectly through one or more intermediaries.
- the technical methods here capture the execution behavior of the program not just the textual or syntax elements of a programming language. This can be done by modeling the program as blocks and capturing the execution behaviors in the fingerprints.
- the techniques presented herein improve upon the ability to find and identify duplicate code and to replace code with better code.
- the solutions shown and described herein address problems with searching and identify areas duplicate code in at least two principal ways.
- First, a unique representation of the source code and control flows in the code are provided using a combination of fingerprints and hashes to enable improved speed and efficiency.
- the teachings herein capture the program execution behavior by accounting for the probabilities of control blocks branching. [0098]
- the teachings herein improve upon known systems in various ways.
- control flow blocks are used as a basis for the comparison, which can be a small context sensitive part of any program.
- use of control flow as a basis of searching for duplicate code allows for capturing relative behavior of the program as opposed to merely syntax information.
- use of multilevel fingerprints e.g., representing blocks and programs) allow for a very efficient storage and search for duplicates.
- the present application is highly targeted to quality assurance in larger code bases and homogenous environments, such as in ERP systems.
- a centralized source code representation is generated, and initial processing of the code base can be used immediately for a specific targeted search.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Stored Programmes (AREA)
- Storage Device Security (AREA)
Abstract
Description
Claims
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| US16/242,414 | 2019-01-08 | ||
| US16/242,414 US11099842B2 (en) | 2019-01-08 | 2019-01-08 | Source code similarity detection using digital fingerprints |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020146205A1 true WO2020146205A1 (en) | 2020-07-16 |
Family
ID=69400652
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/US2020/012197 Ceased WO2020146205A1 (en) | 2019-01-08 | 2020-01-03 | Source code similarity detection using digital fingerprints |
Country Status (3)
| Country | Link |
|---|---|
| US (1) | US11099842B2 (en) |
| SA (1) | SA521422424B1 (en) |
| WO (1) | WO2020146205A1 (en) |
Families Citing this family (21)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US11137986B2 (en) * | 2019-12-13 | 2021-10-05 | Sap Se | Similar code analysis and template induction |
| US11169786B2 (en) * | 2020-02-04 | 2021-11-09 | X Development Llc | Generating and using joint representations of source code |
| US12423373B2 (en) | 2020-02-18 | 2025-09-23 | HashiCorp | Identifying and monitoring relevant enterprise data stored in software development repositories |
| US11599659B2 (en) | 2020-02-18 | 2023-03-07 | BluBracket, Inc. | Documenting and annotating code activities |
| CN112148359B (en) * | 2020-10-10 | 2022-07-05 | 中国人民解放军国防科技大学 | A distributed code clone detection and search method, system and medium based on sub-block filtering |
| US11662998B2 (en) * | 2020-11-05 | 2023-05-30 | Outsystems—Software Em Rede, S.A. | Detecting duplicated code patterns in visual programming language code instances |
| US11657161B2 (en) * | 2020-12-22 | 2023-05-23 | Microsoft Technology Licensing, Llc. | Correlation between source code repositories and web endpoints |
| US20220300277A1 (en) * | 2021-03-19 | 2022-09-22 | Fossid AB | Software composition analysis on target source code |
| US20240211383A9 (en) * | 2021-04-17 | 2024-06-27 | Aidin NASIRISHARGH | Machine learning based methods and systems for generating customized feedback for program codes |
| US12475119B2 (en) * | 2021-08-11 | 2025-11-18 | Sap Se | Operator movement optimization technique for procedures |
| CN114328525B (en) * | 2021-12-27 | 2025-01-14 | 深圳前海微众银行股份有限公司 | Data processing method and device |
| US11886849B2 (en) * | 2022-01-20 | 2024-01-30 | Dell Products L.P. | System and method to compare modules for the common code, remove the redundancy and run the unique workflows |
| US11972256B2 (en) | 2022-02-16 | 2024-04-30 | International Business Machines Corporation | Software code analysis using fuzzy fingerprinting |
| CN116561299B (en) * | 2023-07-10 | 2023-10-20 | 合肥综合性国家科学中心人工智能研究院(安徽省人工智能实验室) | Code abstract generation method, device, equipment and storage medium |
| US20250110854A1 (en) * | 2023-09-28 | 2025-04-03 | Oracle International Corporation | Binary detection in software |
| US20250110715A1 (en) * | 2023-10-03 | 2025-04-03 | Shanghai Jiao Tong University | Binary Code Similarity Detection System Based on Hard Sample-aware Momentum Contrastive Learning |
| US20250245000A1 (en) * | 2024-01-31 | 2025-07-31 | Endor Labs Inc | Detection of phantom dependencies within a constructed software application |
| CN118331637A (en) * | 2024-06-14 | 2024-07-12 | 北京迪力科技有限责任公司 | Code similarity evaluation method, device, equipment and storage medium |
| US20260030322A1 (en) * | 2024-07-23 | 2026-01-29 | Amazon Technologies, Inc. | Tracing sources of generative artificial intelligence machine learning model output |
| CN118779726B (en) * | 2024-09-09 | 2025-01-03 | 广州市高奈特网络科技有限公司 | Homologous application program identification method, device, computer equipment and storage medium |
| CN119377086A (en) * | 2024-12-30 | 2025-01-28 | 北京安普诺信息技术有限公司 | Code homology detection method, device, computer equipment and medium based on SCA |
Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20160124966A1 (en) * | 2014-10-30 | 2016-05-05 | The Johns Hopkins University | Apparatus and Method for Efficient Identification of Code Similarity |
Family Cites Families (25)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6282698B1 (en) | 1998-02-09 | 2001-08-28 | Lucent Technologies Inc. | Detecting similarities in Java sources from bytecodes |
| US8249885B2 (en) | 2001-08-08 | 2012-08-21 | Gary Charles Berkowitz | Knowledge-based e-catalog procurement system and method |
| US7823127B2 (en) | 2003-11-25 | 2010-10-26 | Software Analysis And Forensic Engineering Corp. | Detecting plagiarism in computer source code |
| US20060122822A1 (en) | 2004-12-03 | 2006-06-08 | Alexander Simon | Language grammar driven recognizer of similar code fragments and methods |
| JP4560608B2 (en) | 2006-08-11 | 2010-10-13 | 国立大学法人神戸大学 | Similarity evaluation program, similarity evaluation device, and similarity evaluation method |
| US8312427B2 (en) | 2007-05-15 | 2012-11-13 | International Business Machines Corporation | Selecting a set of candidate code expressions from a section of program code for copying |
| US8209665B2 (en) | 2008-04-08 | 2012-06-26 | Infosys Limited | Identification of topics in source code |
| JP4839424B2 (en) | 2008-12-15 | 2011-12-21 | インターナショナル・ビジネス・マシーンズ・コーポレーション | Method for supporting program analysis, and computer program and computer system thereof |
| CN101697121A (en) | 2009-10-26 | 2010-04-21 | 哈尔滨工业大学 | Method for detecting code similarity based on semantic analysis of program source code |
| US9110769B2 (en) | 2010-04-01 | 2015-08-18 | Microsoft Technology Licensing, Llc | Code-clone detection and analysis |
| JP5564448B2 (en) | 2011-02-08 | 2014-07-30 | 株式会社日立製作所 | Software similarity evaluation method |
| US8752035B2 (en) | 2011-05-31 | 2014-06-10 | Microsoft Corporation | Transforming dynamic source code based on semantic analysis |
| JP5789537B2 (en) | 2012-02-13 | 2015-10-07 | 株式会社日立製作所 | Source code similarity visualization device |
| KR20140035608A (en) | 2012-09-14 | 2014-03-24 | 단국대학교 산학협력단 | Appratus for detectiing similarity of software and method thereof |
| JP5875961B2 (en) | 2012-09-18 | 2016-03-02 | 株式会社日立製作所 | Source code similarity evaluation program, source code similarity evaluation apparatus, and computer-readable storage medium |
| US8924941B2 (en) | 2013-02-12 | 2014-12-30 | Concurix Corporation | Optimization analysis using similar frequencies |
| JP6090850B2 (en) | 2013-03-29 | 2017-03-08 | Necソリューションイノベータ株式会社 | Source program analysis system, source program analysis method and program |
| EP2801906B1 (en) | 2013-05-08 | 2017-01-11 | Accenture Global Services Limited | Source code flow analysis using information retrieval |
| US9459861B1 (en) * | 2014-03-31 | 2016-10-04 | Terbium Labs, Inc. | Systems and methods for detecting copied computer code using fingerprints |
| US8997256B1 (en) * | 2014-03-31 | 2015-03-31 | Terbium Labs LLC | Systems and methods for detecting copied computer code using fingerprints |
| CN105426711B (en) | 2015-11-18 | 2018-05-15 | 北京理工大学 | A kind of computer software source code similarity detection method |
| US9965633B2 (en) | 2015-12-29 | 2018-05-08 | Sap Se | Using code similarities for improving auditing and fixing of SAST-discovered code vulnerabilities |
| US20170242671A1 (en) * | 2016-02-18 | 2017-08-24 | Qualcomm Innovation Center, Inc. | Semantically sensitive code region hash calculation for programming languages |
| US10805316B2 (en) * | 2016-05-31 | 2020-10-13 | University Of South Florida | Systems and methods for detecting attacks in big data systems |
| EP3502896B1 (en) * | 2017-12-20 | 2024-09-04 | Sap Se | Generation of an adapters configuration user interface using a data structure |
-
2019
- 2019-01-08 US US16/242,414 patent/US11099842B2/en active Active
-
2020
- 2020-01-03 WO PCT/US2020/012197 patent/WO2020146205A1/en not_active Ceased
-
2021
- 2021-06-29 SA SA521422424A patent/SA521422424B1/en unknown
Patent Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20160124966A1 (en) * | 2014-10-30 | 2016-05-05 | The Johns Hopkins University | Apparatus and Method for Efficient Identification of Code Similarity |
Non-Patent Citations (2)
| Title |
|---|
| CHANCHAL K. ROY ET AL: "Comparison and evaluation of code clone detection techniques and tools: A qualitative approach", SCIENCE OF COMPUTER PROGRAMMING, vol. 74, no. 7, 10 March 2009 (2009-03-10), NL, pages 470 - 495, XP055637619, ISSN: 0167-6423, DOI: 10.1016/j.scico.2009.02.007 * |
| RATTAN DHAVLEESH ET AL: "Software clone detection: A systematic review", INFORMATION AND SOFTWARE TECHNOLOGY, ELSEVIER, AMSTERDAM, NL, vol. 55, no. 7, 14 February 2013 (2013-02-14), pages 1165 - 1199, XP028564116, ISSN: 0950-5849, DOI: 10.1016/J.INFSOF.2013.01.008 * |
Also Published As
| Publication number | Publication date |
|---|---|
| SA521422424B1 (en) | 2024-06-09 |
| US20200218535A1 (en) | 2020-07-09 |
| US11099842B2 (en) | 2021-08-24 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11099842B2 (en) | Source code similarity detection using digital fingerprints | |
| US11500871B1 (en) | Systems and methods for decoupling search processing language and machine learning analytics from storage of accessed data | |
| US20200057864A1 (en) | System and method for data classification centric sensitive data discovery | |
| US12118334B1 (en) | Determination of schema compatibility between neighboring operators within a search query statement | |
| US11748634B1 (en) | Systems and methods for integration of machine learning components within a pipelined search query to generate a graphic visualization | |
| JP2023545765A (en) | Learning-based workload resource optimization for database management systems | |
| CN113312377A (en) | Automatic-association SQL query statement processing method and device and electronic equipment | |
| CN113128213B (en) | Log template extraction method and device | |
| US11727007B1 (en) | Systems and methods for a unified analytics platform | |
| US11681606B2 (en) | Automatic configuration of logging infrastructure for software deployments using source code | |
| Yuan et al. | Subgraph Matching over Graph Federation. | |
| CN115270136B (en) | A vulnerability clone detection system and method based on binary group | |
| US20250053497A1 (en) | Block anchors for online log parsing | |
| Tang et al. | An attention-based automatic vulnerability detection approach with GGNN | |
| CN113934701A (en) | Log processing method, device, server and storage medium | |
| Durán et al. | Identifying architectural design decisions for achieving green ml serving | |
| US12131233B1 (en) | Systems and methods for auto-deployment of a machine learning component within a pipelined search query | |
| CN114492366A (en) | Binary file classification method, computing device and storage medium | |
| CN116739605A (en) | Transaction data detection method, device, equipment and storage medium | |
| CN120492310B (en) | Method, device, equipment, storage medium and product for determining code adoption rate | |
| JP2022536019A (en) | Automatic Resolution of Overspecified and Underspecified in Knowledge Graph | |
| Nguyen et al. | An efficient similar image search framework for large-scale data on cloud | |
| US11223641B2 (en) | Apparatus and method for reconfiguring signature | |
| US9853946B2 (en) | Security compliance for cloud-based machine data acquisition and search system | |
| CN118363603A (en) | Code file analysis method, device, electronic equipment and readable storage medium |
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: 20702948 Country of ref document: EP Kind code of ref document: A1 |
|
| DPE2 | Request for preliminary examination filed before expiration of 19th month from priority date (pct application filed from 20040101) | ||
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 20702948 Country of ref document: EP Kind code of ref document: A1 |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 28.10.2021) |
|
| WWE | Wipo information: entry into national phase |
Ref document number: 521422424 Country of ref document: SA |
|
| WWG | Wipo information: grant in national office |
Ref document number: 521422424 Country of ref document: SA |



