CN116483423B - Incremental code scanning method and system based on genetic algorithm - Google Patents
Incremental code scanning method and system based on genetic algorithm Download PDFInfo
- Publication number
- CN116483423B CN116483423B CN202310744349.5A CN202310744349A CN116483423B CN 116483423 B CN116483423 B CN 116483423B CN 202310744349 A CN202310744349 A CN 202310744349A CN 116483423 B CN116483423 B CN 116483423B
- Authority
- CN
- China
- Prior art keywords
- file information
- information tree
- code file
- current
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 46
- 230000002068 genetic effect Effects 0.000 title claims abstract description 31
- 230000035772 mutation Effects 0.000 claims description 13
- 238000012986 modification Methods 0.000 claims description 4
- 230000004048 modification Effects 0.000 claims description 4
- 238000010276 construction Methods 0.000 claims description 3
- 238000012163 sequencing technique Methods 0.000 claims description 3
- 238000004590 computer program Methods 0.000 description 6
- 230000006870 function Effects 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 230000008569 process Effects 0.000 description 4
- 238000013459 approach Methods 0.000 description 2
- 230000008901 benefit Effects 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 2
- 230000007547 defect Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000012827 research and development Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000015556 catabolic process Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000006731 degradation reaction Methods 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 108090000623 proteins and genes Proteins 0.000 description 1
- 238000003908 quality control method Methods 0.000 description 1
- 230000008439 repair process Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3604—Software analysis for verifying properties of programs
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/12—Computing arrangements based on biological models using genetic models
- G06N3/126—Evolutionary algorithms, e.g. genetic algorithms or genetic programming
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Biophysics (AREA)
- General Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- Life Sciences & Earth Sciences (AREA)
- Evolutionary Biology (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Bioinformatics & Computational Biology (AREA)
- Computer Hardware Design (AREA)
- Data Mining & Analysis (AREA)
- Physiology (AREA)
- Genetics & Genomics (AREA)
- Artificial Intelligence (AREA)
- Biomedical Technology (AREA)
- Computational Linguistics (AREA)
- Quality & Reliability (AREA)
- Evolutionary Computation (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses an incremental code scanning method based on a genetic algorithm, and belongs to the technical field of computers; the method comprises the following steps: acquiring updated file information; constructing a current code file information tree according to the updated file information; optimizing the current code file information tree through a genetic algorithm to obtain an optimized current code file information tree; replacing the unaffected nodes by the optimized current code file information tree to obtain a final information tree; and scanning the directory and the file list of the final information tree to obtain the increment code. The invention also provides an incremental code scanning system based on the genetic algorithm. The invention can realize incremental scanning in any scene, improve the code scanning efficiency and reduce the resource cost.
Description
Technical Field
The invention relates to the technical field of computers, in particular to an incremental code scanning method and system based on a genetic algorithm.
Background
Along with digital transformation, software research and development enters the lean management era. In the lean development process, code scanning is important to improve code quality, reliability and security. Code scanning can bring the following advantages to enterprises:
1) Finding potential defects of the code;
2) Discovering potential security problems of the code;
3) The manual code walking cost is reduced, automatic defect searching is realized, and the research and development efficiency is improved;
4) And the software complexity and the maintenance cost are reduced, and the quick access of new people is facilitated.
Based on the benefits of code scanning, enterprises have proposed the concept of continuous scanning, but have encountered certain challenges in the actual landing process.
1) And the time cost is high. The general code scanning tool can support full-scale scanning, but the full-scale scanning generally takes a long time in an enterprise project, and long-time code scanning influences the research and development iteration rate, so that an enterprise generally performs code scanning before online, and code quality control is realized in the last link;
2) And the resource cost is high. The full code scanning requires a large amount of computing resources, cpu, memory and disk because the whole code warehouse is required to be scanned;
3) And the repair cost is high. The ROI for repairing the problem with the steady running and tested historical code is not high, and the code is usually continuously scanned from the new code in the practice process.
In order to solve the above problems, the conventional scheme and the corresponding drawbacks are:
1) Incremental scanning functionality using an open source code scanning tool sonar. It is mainly aimed at setting a baseline and then allowing the user to pay attention to the problem after the baseline, i.e. to solve the third problem. But in terms of scanning efficiency it is essentially a full scan that is performed, with only the two scan results being subjected to a differential analysis, leaving the latest scan results. This solution is only applicable to a certain extent.
2) Version control git, and a sonar scan tool. This type of scheme uses Git diff to perform file difference analysis of two versions, and then uses file inclusion of the sonerscanner command to analyze only new files. This approach can solve the above three problems in most cases. However, the command inclusion file is transmitted with a certain number limit, and when the number limit is exceeded, the error is directly reported. In which case the degradation into full scan is required.
3) And a compiler integration mode. Some compiler-integrated code scanning tools may perform incremental scanning while compiling code. But this approach and compilers have a strong dependency and not all compilers in all languages can do this.
Disclosure of Invention
The invention aims to provide an efficient incremental code scanning method and system based on a genetic algorithm.
In order to solve the technical problems, the invention provides an incremental code scanning method based on a genetic algorithm, which comprises the following steps:
acquiring updated file information;
constructing a current code file information tree according to the updated file information;
expanding or merging nodes of the current code file information tree through a genetic algorithm to obtain an optimized current code file information tree;
expanding the unaffected nodes in the optimized current code file information tree to obtain a final information tree;
and scanning the final information tree to obtain an increment code.
Preferably, the method for acquiring the updated file information specifically comprises the following steps:
and acquiring the current commit data by a Git diff method to be used as updated file information.
Preferably, the method constructs the current code file information tree according to the updated file information, and specifically comprises the following steps:
judging whether the last commit data has a corresponding historical code file information tree or not;
if the last commit data has a corresponding historical code file information tree, reconstructing the historical code file information tree according to the current commit data and the last commit data to obtain a current code file information tree;
if the last commit data does not have the corresponding historical code file information tree, constructing a current code file information tree according to the current commit data.
Preferably, the method comprises the steps of reconstructing a historical code file information tree according to the current commit data and the last commit data to obtain a current code file information tree, and specifically comprises the following steps:
comparing the current commit data with the last commit data to obtain new modification code file information;
and adding the new modified code file information into the corresponding historical code file information tree to obtain a current code file information tree.
Preferably, the current code file information tree is constructed according to the present commit data, and the method specifically comprises the following steps:
respectively constructing a code file information tree according to the current commit data and the last commit data;
comparing the current commit data with the code file information tree of the last commit data to obtain a public directory;
and deleting the public directory from the code file information tree of the current commit data to obtain a current code file information tree.
Preferably, the nodes of the current code file information tree are unfolded or combined through a genetic algorithm to obtain an optimized current code file information tree, and the method specifically comprises the following steps:
coding the current code file information tree to obtain a coding result;
selecting a root node in a coding result to be unfolded, and combining other nodes to be used as an initial population;
and repeatedly executing selection, intersection and mutation on the initial population to generate a next generation population until the iteration times are reached or no expandable node exists, so as to obtain a current code file information tree after the conversion.
Preferably, the selection, crossover and mutation are repeatedly performed on the initial population to generate a next generation population, specifically comprising the following steps:
counting the number of nodes of the next layer;
judging whether the leaf nodes of the layer meet constraint conditions according to the number of the nodes of the next layer;
if the leaf nodes of the layer do not meet constraint conditions, calculating the adaptability of the leaf nodes and sequencing the leaf nodes to determine the nodes to be mutated;
and selecting nodes from the nodes to be mutated according to a dichotomy to be unfolded to serve as a next generation population.
Preferably, the final information tree is scanned to obtain the increment code, which specifically comprises the following steps:
decoding the final information tree to obtain a final catalog and a file;
and scanning the final catalogue and the file to obtain the increment code.
Preferably, the method comprises the steps of expanding non-affected nodes in the optimized current code file information tree to obtain a final information tree, and specifically comprises the following steps:
taking directory nodes with only one file node in the optimized current code file information tree as influence-free nodes;
and expanding the influence-free nodes to obtain a final information tree.
The invention also provides an incremental code scanning system based on the genetic algorithm, which comprises the following steps:
the acquisition module is used for acquiring updated file information;
the construction module is used for constructing a current code file information tree according to the updated file information;
the optimizing module is used for expanding or combining the nodes of the current code file information tree through a genetic algorithm to obtain an optimized current code file information tree;
the replacing module is used for expanding the unaffected nodes in the optimized current code file information tree to obtain a final information tree;
and the scanning module is used for scanning the final information tree to obtain an increment code.
Compared with the prior art, the invention has the beneficial effects that:
the invention provides a general incremental scanning method for balancing optimal scanning accuracy and scanning efficiency, which helps enterprises to realize incremental scanning in any scene, improves code scanning efficiency and reduces resource cost.
Drawings
The following describes the embodiments of the present invention in further detail with reference to the accompanying drawings.
FIG. 1 is a schematic flow chart of constructing a code file information tree;
FIG. 2 is a schematic diagram of the removal of public directories;
FIG. 3 is a schematic flow chart of genetic algorithm optimization of the current code file information tree;
FIG. 4 is a schematic flow chart of an incremental scan;
FIG. 5 is a flow chart of a method for scanning incremental codes based on a genetic algorithm according to the present invention.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. The present invention may be embodied in many other forms than those herein described, and those skilled in the art will readily appreciate that the present invention may be similarly embodied without departing from the spirit or essential characteristics thereof, and therefore the present invention is not limited to the specific embodiments disclosed below.
The terminology used in the one or more embodiments of the specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the specification. As used in this specification, one or more embodiments and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present specification refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that, although the terms first, second, etc. may be used in one or more embodiments of this specification to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first may also be referred to as a second, and similarly, a second may also be referred to as a first, without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
The invention is described in further detail below with reference to the attached drawing figures:
as shown in fig. 5, the invention provides an incremental code scanning method based on a genetic algorithm, which comprises the following steps:
acquiring updated file information;
constructing a current code file information tree according to the updated file information;
expanding or merging nodes of the current code file information tree through a genetic algorithm to obtain an optimized current code file information tree;
expanding the unaffected nodes in the optimized current code file information tree to obtain a final information tree;
and scanning the final information tree to obtain an increment code.
Preferably, the method for acquiring the updated file information specifically comprises the following steps:
and acquiring the current commit data by a Git diff method to be used as updated file information.
Preferably, the method constructs the current code file information tree according to the updated file information, and specifically comprises the following steps:
judging whether the last commit data has a corresponding historical code file information tree or not;
if the last commit data has a corresponding historical code file information tree, reconstructing the historical code file information tree according to the current commit data and the last commit data to obtain a current code file information tree;
if the last commit data does not have the corresponding historical code file information tree, constructing a current code file information tree according to the current commit data.
Preferably, the method comprises the steps of reconstructing a historical code file information tree according to the current commit data and the last commit data to obtain a current code file information tree, and specifically comprises the following steps:
comparing the current commit data with the last commit data to obtain new modification code file information;
and adding the new modified code file information into the corresponding historical code file information tree to obtain a current code file information tree.
Preferably, the current code file information tree is constructed according to the present commit data, and the method specifically comprises the following steps:
respectively constructing a code file information tree according to the current commit data and the last commit data;
comparing the current commit data with the code file information tree of the last commit data to obtain a public directory;
and deleting the public directory from the code file information tree of the current commit data to obtain a current code file information tree.
Preferably, the nodes of the current code file information tree are unfolded or combined through a genetic algorithm to obtain an optimized current code file information tree, and the method specifically comprises the following steps:
coding the current code file information tree to obtain a coding result;
selecting a root node in a coding result to be unfolded, and combining other nodes to be used as an initial population;
and repeatedly executing selection, intersection and mutation on the initial population to generate a next generation population until the iteration times are reached or no expandable node exists, so as to obtain a current code file information tree after the conversion.
Preferably, the selection, crossover and mutation are repeatedly performed on the initial population to generate a next generation population, specifically comprising the following steps:
counting the number of nodes of the next layer;
judging whether the leaf nodes of the layer meet constraint conditions according to the number of the nodes of the next layer;
if the leaf nodes of the layer do not meet constraint conditions, calculating the adaptability of the leaf nodes and sequencing the leaf nodes to determine the nodes to be mutated;
and selecting nodes from the nodes to be mutated according to a dichotomy to be unfolded to serve as a next generation population.
Preferably, the final information tree is scanned to obtain the increment code, which specifically comprises the following steps:
decoding the final information tree to obtain a final catalog and a file;
and scanning the final catalogue and the file to obtain the increment code.
Preferably, the method comprises the steps of expanding non-affected nodes in the optimized current code file information tree to obtain a final information tree, and specifically comprises the following steps:
taking directory nodes with only one file node in the optimized current code file information tree as influence-free nodes;
and expanding the influence-free nodes to obtain a final information tree.
The invention also provides an incremental code scanning system based on the genetic algorithm, which comprises the following steps:
the acquisition module is used for acquiring updated file information;
the construction module is used for constructing a current code file information tree according to the updated file information;
the optimizing module is used for expanding or combining the nodes of the current code file information tree through a genetic algorithm to obtain an optimized current code file information tree;
the replacing module is used for expanding the unaffected nodes in the optimized current code file information tree to obtain a final information tree;
and the scanning module is used for scanning the final information tree to obtain an increment code.
In order to better illustrate the technical effects of the present invention, the present invention provides the following specific embodiments to illustrate the above technical flow:
embodiment 1, a genetic algorithm-based incremental code scanning method, as shown in fig. 4;
based on the shortcomings of the prior art solutions, the present method and system aim to improve the second solution of the conventional practice in the background art, and seek a certain optimal solution in the case of certain restrictions on file parameters. The invention provides a general incremental scanning method for balancing optimal scanning accuracy and scanning efficiency, which helps enterprises to realize incremental scanning in any scene, improves code scanning efficiency and reduces resource cost.
The specific steps of the specific method are as follows:
1) The number of updated files is obtained according to the Git diff method, and then a code file information tree is constructed according to the information. The specific steps are shown in figure 1.
(1) Git diff obtains new modified code file information between scanning commit;
(2) judging whether there is previous history tree information
(3) If not, reconstructing the code file information tree. Firstly, according to the longest public subtree of the characteristic statistical information tree with the child node tree being 1, the longest public subtree is a public directory, the current commit data is traversed, the total file number of the file related directory is counted in each file traversal, and the storage tree structure comprises the total file number and the new file number. The tree structure deletes the public directory when stored, and reduces the memory occupation of the tree information, as shown in fig. 2.
(4) And if the history tree exists, acquiring the history tree, analyzing the catalog information according to the new modification code file information acquired in the step 1, inserting the catalog, and updating the total file number and the new file number of the tree node.
2) After the number of the code files is built, the files are required to be combined under the condition that the number limit is met, the files are transmitted into the catalogue, and the new files are required to be kept as most as possible under the condition that the files are transmitted into the catalogue, so that the increment scanning accuracy is higher. This step requires the search for an optimal solution, so a genetic algorithm can be used to select files, ensuring that the number of files does not exceed the command limit of the sonarscaner. The specific steps are shown in fig. 3:
(1) the final question is abstracted as to whether the new file-dependent directories merge or unfold. Merging is 0 and unrolling is 1. The first step is to encode the information tree of the constructed code file. And constructing a two-dimensional array by using the file depth L and the number C of leaf nodes, and judging whether the directory on the first updated file of the first line of codes of the data is unfolded or not, wherein 1 is obtained and 0 is obtained as a combination. Because the tree depths are different, if there is a directory-level miss, a-1 representation is used; 2 denotes leaf nodes, each iteration is not updated. The tree according to the above can be constructed as follows:
Treecodes[C][L]=
(2) and obtaining an initial population. Because of the number limitation problem, if the number of the catalogues is limited, and the catalogues exceed the limitation, intermediate combination is not needed, and all population evolution evolves from top to bottom. The initial population assumes that the root node is expanded and the other directories are merged, so the encoded gene results are as follows:
(3) and selecting an algorithm. And counting the number of leaf nodes (catalogues or files) according to the second column of information, judging whether constraint conditions are met, and ending if constraint limits are not met. Satisfying constraint conditions, sorting according to fitness, performing mutation operation on the next row of maximum N-count (leaf node tree), expanding by 0-1, selecting a node with small fitness for mutation, and performing mutation on a leaf node with a value of 2. According to the dichotomy, selecting nodes to try mutation, determining a mutation boundary, wherein the left side of the mutation boundary exceeds the limit, and the right side of the mutation boundary does not exceed the limit. And selecting the node with small adaptability on the right side to perform batch variation.
Total number of files: ftotal
New number of files: fnew
And finally selecting a node tree: count (Count)
Limiting number: n (N)
Function fitness: fitness=fnew/Ftotal 100;
constraint Count < = N
(4) And mutating the node on the right side of the boundary, and setting the node value as expansion.
(5) And obtaining next generation stage information, and repeating the steps 3-5 to obtain the optimal solution.
3) And expanding the catalog of only one updated file according to the result obtained by the genetic algorithm again, wherein the mutation does not influence the final result and the second settlement can be ended at the fastest speed.
4) And (3) transmitting the file and the catalogue in the final information tree obtained in the step (3) into command parameters to realize scanning.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and the division of modules, or units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units, modules, or components may be combined or integrated into another apparatus, or some features may be omitted, or not performed.
The units may or may not be physically separate, and the components shown as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such embodiments, the computer program may be downloaded and installed from a network via a communication portion, and/or installed from a removable medium. The above-described functions defined in the method of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU). The computer readable medium of the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above.
The flowcharts 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 invention. 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 foregoing is merely illustrative of specific embodiments of the present invention, and the scope of the present invention is not limited thereto, but any changes or substitutions within the technical scope of the present invention should be covered by the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (8)
1. The incremental code scanning method based on the genetic algorithm is characterized by comprising the following steps of:
acquiring updated file information;
constructing a current code file information tree according to the updated file information;
coding the current code file information tree to obtain a coding result;
selecting a root node in a coding result to be unfolded, and combining other nodes to be used as an initial population;
repeatedly executing selection, intersection and mutation on the initial population to generate a next generation population until the iteration times are reached or no expandable node exists, so as to obtain an optimized current code file information tree;
taking directory nodes with only one file node in the optimized current code file information tree as influence-free nodes;
expanding the influence-free nodes to obtain a final information tree;
and scanning the final information tree to obtain an increment code.
2. The incremental code scanning method based on a genetic algorithm according to claim 1, wherein the step of acquiring the updated file information comprises the steps of:
and acquiring the current commit data by a Git diff method to be used as updated file information.
3. The incremental code scanning method based on genetic algorithm according to claim 2, wherein the current code file information tree is constructed based on the updated file information, specifically comprising the steps of:
judging whether the last commit data has a corresponding historical code file information tree or not;
if the last commit data has a corresponding historical code file information tree, reconstructing the historical code file information tree according to the current commit data and the last commit data to obtain a current code file information tree;
if the last commit data does not have the corresponding historical code file information tree, constructing a current code file information tree according to the current commit data.
4. The incremental code scanning method according to claim 3, wherein the step of reconstructing the historical code file information tree based on the present commit data and the last commit data to obtain the current code file information tree comprises the steps of:
comparing the current commit data with the last commit data to obtain new modification code file information;
and adding the new modified code file information into the corresponding historical code file information tree to obtain a current code file information tree.
5. The incremental code scanning method based on genetic algorithm of claim 4 wherein constructing the current code file information tree based on the current commit data comprises the steps of:
respectively constructing a code file information tree according to the current commit data and the last commit data;
comparing the current commit data with the code file information tree of the last commit data to obtain a public directory;
and deleting the public directory from the code file information tree of the current commit data to obtain a current code file information tree.
6. The genetic algorithm-based incremental code scan method of claim 1 wherein the selecting, crossing and mutating are repeatedly performed on the initial population to generate a next generation population, comprising the steps of:
counting the number of nodes of the next layer;
judging whether the leaf nodes of the layer meet constraint conditions according to the number of the nodes of the next layer;
if the leaf nodes of the layer do not meet constraint conditions, calculating the adaptability of the leaf nodes and sequencing the leaf nodes to determine the nodes to be mutated;
and selecting nodes from the nodes to be mutated according to a dichotomy to be unfolded to serve as a next generation population.
7. The method for scanning incremental codes based on genetic algorithm according to claim 1, wherein the final information tree is scanned to obtain the incremental codes, and specifically comprising the steps of:
decoding the final information tree to obtain a final catalog and a file;
and scanning the final catalogue and the file to obtain the increment code.
8. A genetic algorithm-based incremental code scanning system for implementing the genetic algorithm-based incremental code scanning method according to any one of claims 1 to 7, comprising:
the acquisition module is used for acquiring updated file information;
the construction module is used for constructing a current code file information tree according to the updated file information;
the optimizing module is used for expanding or combining the nodes of the current code file information tree through a genetic algorithm to obtain an optimized current code file information tree;
the replacing module is used for expanding the unaffected nodes in the optimized current code file information tree to obtain a final information tree;
and the scanning module is used for scanning the final information tree to obtain an increment code.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310744349.5A CN116483423B (en) | 2023-06-25 | 2023-06-25 | Incremental code scanning method and system based on genetic algorithm |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310744349.5A CN116483423B (en) | 2023-06-25 | 2023-06-25 | Incremental code scanning method and system based on genetic algorithm |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116483423A CN116483423A (en) | 2023-07-25 |
CN116483423B true CN116483423B (en) | 2023-09-05 |
Family
ID=87212325
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310744349.5A Active CN116483423B (en) | 2023-06-25 | 2023-06-25 | Incremental code scanning method and system based on genetic algorithm |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116483423B (en) |
Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104461578A (en) * | 2014-12-26 | 2015-03-25 | 广州唯品会信息科技有限公司 | Automatic code merging method and system |
CN110609693A (en) * | 2019-08-15 | 2019-12-24 | 平安国际智慧城市科技股份有限公司 | Code updating method and device based on data standardization and terminal equipment |
CN113705813A (en) * | 2021-09-01 | 2021-11-26 | 中国工商银行股份有限公司 | Mutation rule supplementing method and device based on genetic algorithm |
CN115168085A (en) * | 2022-06-23 | 2022-10-11 | 南京邮电大学 | Repetitive conflict scheme detection method based on diff code block matching |
CN115373735A (en) * | 2022-09-24 | 2022-11-22 | 南京大学 | Method and system for improving software module quality by using genetic algorithm |
WO2023053101A1 (en) * | 2021-10-03 | 2023-04-06 | Seraphic Algorithms Ltd. | Systems and methods for malicious code neutralization in execution environments |
CN115994124A (en) * | 2022-12-01 | 2023-04-21 | 奇安信网神信息技术(北京)股份有限公司 | File scanning method, device, electronic equipment and computer readable storage medium |
CN116166547A (en) * | 2023-02-13 | 2023-05-26 | 建信金融科技有限责任公司 | Code change range analysis method, device, equipment and storage medium |
CN116257279A (en) * | 2022-10-18 | 2023-06-13 | 浙江利尔达物联网技术有限公司 | Incremental development method and system of module software |
CN116305118A (en) * | 2023-02-23 | 2023-06-23 | 浙江极氪智能科技有限公司 | Method, device, electronic equipment and medium for static detection of increment codes |
CN116301985A (en) * | 2023-03-03 | 2023-06-23 | 丰巢网络技术有限公司 | Code scanning method, device, computer equipment and storage medium |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10459695B2 (en) * | 2017-10-05 | 2019-10-29 | Sap Se | Correction of code errors using machine learning |
-
2023
- 2023-06-25 CN CN202310744349.5A patent/CN116483423B/en active Active
Patent Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104461578A (en) * | 2014-12-26 | 2015-03-25 | 广州唯品会信息科技有限公司 | Automatic code merging method and system |
CN110609693A (en) * | 2019-08-15 | 2019-12-24 | 平安国际智慧城市科技股份有限公司 | Code updating method and device based on data standardization and terminal equipment |
CN113705813A (en) * | 2021-09-01 | 2021-11-26 | 中国工商银行股份有限公司 | Mutation rule supplementing method and device based on genetic algorithm |
WO2023053101A1 (en) * | 2021-10-03 | 2023-04-06 | Seraphic Algorithms Ltd. | Systems and methods for malicious code neutralization in execution environments |
CN115168085A (en) * | 2022-06-23 | 2022-10-11 | 南京邮电大学 | Repetitive conflict scheme detection method based on diff code block matching |
CN115373735A (en) * | 2022-09-24 | 2022-11-22 | 南京大学 | Method and system for improving software module quality by using genetic algorithm |
CN116257279A (en) * | 2022-10-18 | 2023-06-13 | 浙江利尔达物联网技术有限公司 | Incremental development method and system of module software |
CN115994124A (en) * | 2022-12-01 | 2023-04-21 | 奇安信网神信息技术(北京)股份有限公司 | File scanning method, device, electronic equipment and computer readable storage medium |
CN116166547A (en) * | 2023-02-13 | 2023-05-26 | 建信金融科技有限责任公司 | Code change range analysis method, device, equipment and storage medium |
CN116305118A (en) * | 2023-02-23 | 2023-06-23 | 浙江极氪智能科技有限公司 | Method, device, electronic equipment and medium for static detection of increment codes |
CN116301985A (en) * | 2023-03-03 | 2023-06-23 | 丰巢网络技术有限公司 | Code scanning method, device, computer equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
AIMED: Evolving Malware with Genetic Programming to Evade Detection;Raphael Labaca Castro.etc;IEEE;全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN116483423A (en) | 2023-07-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102945240B (en) | Method and device for realizing association rule mining algorithm supporting distributed computation | |
US6055539A (en) | Method to reduce I/O for hierarchical data partitioning methods | |
CN112328578B (en) | Database query optimization method based on reinforcement learning and graph attention network | |
CN102163203B (en) | Method and device for downloading web pages | |
CN109542783B (en) | Extended finite-state machine test data generation method based on variable segmentation | |
CN113283613A (en) | Deep learning model generation method, optimization method, device, equipment and medium | |
CN105718509A (en) | Directed graph association rule-based music cloud recommendation algorithm | |
CN116502648A (en) | Machine reading understanding semantic reasoning method based on multi-hop reasoning | |
Wolters et al. | Simulated annealing model search for subset selection in screening experiments | |
CN103577414A (en) | Data processing method and device | |
CN116483423B (en) | Incremental code scanning method and system based on genetic algorithm | |
CN112509644B (en) | Molecular optimization method, system, terminal equipment and readable storage medium | |
US6282694B1 (en) | IC design floorplan generation using ceiling and floor contours on an O-tree structure | |
CN113743453A (en) | Population quantity prediction method based on random forest | |
CN116955335B (en) | Address data management method and system based on big data model algorithm | |
CN113076089A (en) | API completion method based on object type | |
Lu et al. | On the auto-tuning of elastic-search based on machine learning | |
CN111612156A (en) | Interpretation method for XGboost model | |
CN115185728A (en) | Software system architecture recovery method based on graph node embedding | |
KR20220099745A (en) | A spatial decomposition-based tree indexing and query processing methods and apparatus for geospatial blockchain data retrieval | |
You et al. | Reduced O3 subsequence labelling: a stepping stone towards optimisation sequence prediction | |
Yang et al. | IMBT--A Binary Tree for Efficient Support Counting of Incremental Data Mining | |
Mirto et al. | A grid-enabled protein secondary structure predictor | |
CN117689011B (en) | Model adjustment method, device, equipment and storage medium | |
CN112433756B (en) | Rapid code clone detection method and device based on weighted recursive self-encoder |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |