Code analysis method, system, device, equipment and computer readable storage medium
By performing code analysis on the code repository server or a third server on the same network segment, the problem of wasted time due to code transmission is solved, and the efficiency of code analysis is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2026-03-17
AI Technical Summary
In existing technologies, the transfer of code between the Git repository and the local server results in wasted time and affects code analysis efficiency.
The analysis script can be installed on the code repository server for local analysis, or the analysis script can be transferred to a third server on the same network segment for code analysis, provided that certain memory and network transmission speed requirements are met.
By reducing the time it takes for code to travel from the code repository server to the primary server, the efficiency of code analysis is improved.
Smart Images

Figure CN114297072B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and in particular relates to a code analysis method, system, device, equipment and computer-readable storage medium. Background Technology
[0002] To simplify the code calling process, most users set up corresponding code repositories and then store the code in the code repository.
[0003] The most commonly used code repository is the Git repository, where code is typically stored in an encrypted manner. Because the code is stored in an encrypted manner in a Git repository, when users want to analyze and troubleshoot the code, they can only pull the code stored in the Git repository to their local server and then analyze the code.
[0004] However, because the amount of code stored in the Git repository is large, and the local server and the code repository are usually on different network segments, a lot of time is wasted in the process of pulling the code stored in the Git repository to the local server. Summary of the Invention
[0005] This application provides a code analysis method, system, apparatus, device, and computer-readable storage medium that can reduce wasted time and improve the efficiency of code analysis during the code analysis process.
[0006] In a first aspect, embodiments of this application provide a code analysis method applied to a code repository server. The code analysis method includes:
[0007] Obtain the analysis script sent by the first server; the analysis script includes an analysis script used to analyze the code stored on the code repository server;
[0008] The installation environment of the code repository server was verified based on the analysis script, and the verification results were obtained.
[0009] If the verification results indicate that the code repository server's installation environment can install the analysis script, the code is analyzed according to the analysis script to obtain the first analysis result;
[0010] The first analysis result is sent to the first server.
[0011] In some implementations, the method further includes:
[0012] If the verification results indicate that the installation environment of the code repository server cannot install the analysis script, the second server located in the same network segment as the code repository server is filtered according to preset conditions to obtain the third server that meets the preset conditions.
[0013] The analysis script is sent to a third server, which then analyzes the code pulled from the code repository server based on the analysis script and sends the second analysis result back to the first server.
[0014] In some implementations, the preset conditions include at least one of the following:
[0015] The memory capacity should be no less than 8GB*2 in dual channels;
[0016] The memory frequency should be no less than 3000MHz;
[0017] Disk arrays whose storage hard drives meet the independent disk redundancy array or distributed parity check independent disk structure;
[0018] The network transmission rate with the code repository server should be no less than 1000Mbps.
[0019] In some implementations, the code pulled includes the current version of the code stored on the code repository server.
[0020] Secondly, embodiments of this application provide a code analysis method applied to a third server. The code analysis method includes:
[0021] If the code repository server verifies the environment of the code repository server and the verification result indicates that the installation environment of the code repository server cannot install the analysis script, the analysis script sent by the code repository server is received; the analysis script is sent from the first server to the code repository server.
[0022] The second analysis result is obtained by analyzing the code pulled from the code repository server by the third server based on the analysis script;
[0023] The second analysis result is sent to the first server.
[0024] Thirdly, embodiments of this application provide a code analysis system, the system comprising: a code repository server, configured to acquire an analysis script sent by a first server; analyze the code stored in the code repository server according to the analysis script to obtain a first analysis result; and send the first analysis result to the first server;
[0025] The first server is used to send analysis scripts to the code repository server and receive the first analysis results sent by the code repository server.
[0026] In some implementations, the system further includes:
[0027] The third server is used to receive the analysis script sent by the code repository server; analyze the code pulled from the code repository server according to the script, obtain the second analysis result, and send the second analysis result to the first server;
[0028] The code repository server is also used to send analysis scripts to third-party servers; and to send code to third-party servers.
[0029] The first server is also used to receive the second analysis results sent by the third server.
[0030] In some implementations, the third server satisfies at least one of the following:
[0031] It is located on the same network segment as the code repository server;
[0032] The memory capacity should be no less than 8GB*2 in dual channels;
[0033] The memory frequency should be no less than 3000MHz;
[0034] A server with a network transmission rate of not less than 1000Mbps between a disk array whose storage hard drives meet the requirements of independent disk redundancy array or distributed parity check independent disk structure and the code repository server.
[0035] Fourthly, embodiments of this application provide a code analysis apparatus applied to a code repository server, the apparatus comprising:
[0036] The acquisition module is used to acquire the analysis script sent by the first server; the analysis script includes an analysis script for analyzing the code stored on the code repository server;
[0037] The verification module is used to verify the installation environment of the code repository server based on the analysis script and obtain the verification results;
[0038] The first analysis module is used to analyze the code according to the analysis script and obtain the first analysis result when the verification result indicates that the installation environment of the code repository server can install the analysis script.
[0039] The first sending module is used to send the first analysis result to the first server.
[0040] In some implementations, the code analysis apparatus further includes:
[0041] The filtering module is used to filter second servers located on the same network segment as the code repository server according to preset conditions when the verification result indicates that the installation environment of the code repository server cannot install the analysis script, so as to obtain a third server that meets the preset conditions.
[0042] The third sending module is used to send the analysis script to the third server, so that the third server can analyze the code pulled from the code repository server according to the analysis script, and send the second analysis result obtained from the analysis to the first server.
[0043] In some implementations, the preset conditions include a dual-channel memory capacity of no less than 8G*2, a memory frequency of no less than 3000MHz, a disk array with an independent disk redundancy array or a distributed parity check independent disk structure for storage hard drives, and a network transmission rate of no less than 1000Mbps with the code repository server.
[0044] Fifthly, embodiments of this application also provide a code analysis apparatus applied to a third server, the apparatus comprising:
[0045] The receiving module is used to receive the analysis script sent by the code repository server when the code repository server verifies the environment of the code repository server and the verification result indicates that the installation environment of the code repository server cannot install the analysis script; the analysis script is sent from the first server to the code repository server.
[0046] The second analysis module is used to analyze the code pulled from the code repository server by the third server according to the analysis script, and obtain the second analysis result;
[0047] The second sending module is used to send the second analysis result to the first server.
[0048] Thirdly, embodiments of this application provide an electronic device, which includes: a processor and a memory storing computer program instructions;
[0049] When the processor executes computer program instructions, it implements the steps of the code analysis method as described in any embodiment of the first aspect.
[0050] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer program instructions, which, when executed by a processor, implement the steps of the code analysis method as described in any embodiment of the first aspect.
[0051] Fifthly, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electronic device, enable the electronic device to perform the code analysis method as described in any embodiment of the first aspect.
[0052] The code analysis method, apparatus, device, and computer-readable storage medium of this application embodiment, after the code repository server receives the analysis script sent by the first server, verifies whether the installation environment of the code repository server can install the analysis script based on the analysis script. If the verification result indicates that the code repository can install the analysis script, the code repository server installs the analysis script and uses the installed analysis script to analyze the code in the code repository server. Since the analysis script is transferred from the first server to the code repository server, and then the code is analyzed on the code repository server, the time wasted due to the large amount of code being transferred from the code repository server to the first server and then analyzed by the first server can be avoided. This improves the efficiency of code analysis. Attached Figure Description
[0053] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0054] Figure 1 This is a schematic diagram of the structure of a code analysis system provided in one embodiment of this application;
[0055] Figure 2 This is a schematic diagram of the structure of another code analysis system provided in one embodiment of this application;
[0056] Figure 3 This is a flowchart illustrating a code analysis method provided in one embodiment of this application;
[0057] Figure 4 This is a flowchart illustrating another code analysis method provided in one embodiment of this application;
[0058] Figure 5 This is a schematic diagram of the structure of a code analysis device provided in one embodiment of this application;
[0059] Figure 6 This is a schematic diagram of the structure of another code analysis device provided in one embodiment of this application;
[0060] Figure 7 This is a schematic diagram of the hardware structure of an electronic device provided in one embodiment of this application. Detailed Implementation
[0061] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.
[0062] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0063] To address the problems of the prior art, embodiments of this application provide a code analysis method, system, apparatus, device, and computer-readable storage medium.
[0064] The code analysis system provided in the embodiments of this application will be introduced first below.
[0065] Figure 1 A schematic diagram of the structure of a code analysis system 10 provided in one embodiment of this application is shown. Figure 1 As shown, the system may include:
[0066] Code repository server 101 is used to obtain the analysis script sent by the first server; analyze the code stored in the code repository server according to the analysis script to obtain the first analysis result; and send the first analysis result to the first server.
[0067] The first server 102 is used to send analysis scripts to the code repository server and receive the first analysis results sent by the code repository server.
[0068] In some implementations, the code repository server 101 may include a server corresponding to the repository storing the code. The first server 102 may include a server located in a different network segment or even a different region than the code repository server 101. For example, the code repository server 101 may be a cloud server, while the first server 102 may be a local server.
[0069] In some implementations, the analysis script may include a user-defined, compiled script for analyzing the code. In the aforementioned code repository, the code is stored in encrypted form. Before the analysis script can analyze the code, it must first be decrypted to obtain the plaintext code, which is then analyzed.
[0070] In some implementations, the code analyzed by the code repository server 101 according to the analysis script may include the latest version of the code stored in the code repository server 101.
[0071] Code repository server 101 stores various versions of code. Analyzing all versions would be time-consuming. However, analyzing only the latest version would significantly reduce the workload.
[0072] In some embodiments, the installation environment of the code repository server 101 cannot install the analysis script. In this case, after receiving the analysis script, the code repository server 101 also needs to verify the installation environment of the code repository server 101 according to the analysis script.
[0073] In some implementations, verifying the installation environment of the code repository server 101 according to the analysis script specifically includes: obtaining the installation parameters of the analysis script and the installation parameters of the code repository server 101, determining whether the installation parameters of the analysis script and the installation parameters of the code repository server 101 match, and if they match, the verification is successful.
[0074] In some embodiments, one embodiment of this application also provides another code analysis system 20, which can be applied when the code repository server's installation environment cannot install analysis scripts.
[0075] Figure 2 A schematic diagram of the structure of another code analysis system 20 provided in one embodiment of this application is shown.
[0076] like Figure 2 The code analysis system 20 described above may also include:
[0077] The third server 103 can be used to receive analysis scripts sent by the code repository server; analyze the code pulled from the code repository server according to the scripts, obtain a second analysis result, and send the second analysis result to the first server 102;
[0078] The code repository server can also be used to send analysis scripts to the third server 103; and to send code to the third server 103.
[0079] The first server can also be used to receive the second analysis results sent by the third server 103.
[0080] In some implementations, the third server 103 satisfies at least one of the following:
[0081] It is on the same network segment as code repository server 101;
[0082] The memory capacity should be no less than 8GB*2 in dual channels;
[0083] The memory frequency should be no less than 3000MHz;
[0084] A server with a network transmission rate of not less than 1000Mbps between a disk array whose storage hard drives meet the requirements of independent disk redundancy array or distributed parity check independent disk structure and the code repository server.
[0085] Therefore, the code repository server sends the analysis scripts and code to a third server located on the same network segment as the code repository server. This third server has a dual-channel memory capacity of at least 8GB*2, a memory frequency of at least 3000MHz, and an independent disk array with a redundant RAID or distributed parity check structure. The network transmission rate between the third server and the code repository server is at least 1000Mbps. By configuring the network segment, memory parameters, disk parameters, and transmission parameters of the third server, the problem of excessively long code transmission times due to these parameter limitations during code transmission from the code repository server to the third server can be avoided. Compared to transmitting code to the first server, transmitting code to a third server on the same network segment avoids the problems of cross-network segment transmission and long transmission distances required during code transmission from the code repository server to the first server. Overall, this improves the efficiency of code analysis.
[0086] Based on the same inventive concept, this application also provides a code analysis method applied to a code repository server.
[0087] Figure 3 The diagram illustrates a flowchart of a code analysis method according to an embodiment of this application. Figure 3 As shown, the method may include:
[0088] S310. Obtain the analysis script sent by the first server; the analysis script includes an analysis script used to analyze the code stored on the code repository server;
[0089] S320. Verify the installation environment of the code repository server according to the analysis script and obtain the verification results;
[0090] S330. If the verification result indicates that the installation environment of the code repository server can install the analysis script, analyze the code according to the analysis script and obtain the first analysis result.
[0091] S340. Send the first analysis result to the first server.
[0092] Therefore, after the code repository server receives the analysis script sent by the first server, it verifies whether the code repository server's installation environment can install the analysis script. If the verification result indicates that the code repository can install the analysis script, the code repository server installs the analysis script and uses the installed analysis script to analyze the code on the code repository server. Because the analysis script is transferred from the first server to the code repository server, and then the code is analyzed on the code repository server, the time wasted due to the large amount of code being transferred from the code repository server to the first server and then analyzed by the first server is avoided. This improves the efficiency of code analysis.
[0093] In some implementations, the code pulled includes the current version of the code stored on the code repository server.
[0094] In some implementations, the above methods have been described in detail in the above embodiments, and will not be repeated here.
[0095] In some embodiments, when the verification result indicates that the code repository server's installation environment cannot install the analysis script, the code analysis method may further include:
[0096] Based on preset conditions, the second server located in the same network segment as the code repository server is filtered to obtain the third server that meets the preset conditions;
[0097] The analysis script is sent to a third server, which then analyzes the code pulled from the code repository server based on the analysis script and sends the second analysis result back to the first server.
[0098] In some implementations, there are often multiple second servers located on the same network segment as the code repository server, and the second servers need to be selected according to preset conditions.
[0099] In some implementations, the preset conditions include at least one of the following: the memory capacity is not less than 8G*2 dual-channel; the memory frequency is not less than 3000MHZ; the storage hard disk meets the independent disk redundancy array or distributed parity check independent disk structure disk array; and the network transmission rate with the code repository server is not less than 1000Mbps.
[0100] Therefore, the code repository server sends the analysis scripts and code to a third server located on the same network segment as the code repository server. This third server has a dual-channel memory capacity of at least 8GB*2, a memory frequency of at least 3000MHz, and an independent disk array with a redundant RAID or distributed parity check structure. The network transmission rate between the third server and the code repository server is at least 1000Mbps. By configuring the network segment, memory parameters, disk parameters, and transmission parameters of the third server, the problem of excessively long code transmission times due to these parameter limitations during code transmission from the code repository server to the third server can be avoided. Compared to transmitting code to the first server, transmitting code to a third server on the same network segment avoids the problems of cross-network segment transmission and long transmission distances required during code transmission from the code repository server to the first server. Overall, this improves the efficiency of code analysis.
[0101] Based on the same inventive concept, one embodiment of this application also provides another code analysis method, which is applied to a third server.
[0102] like Figure 4 The diagram shown is a flowchart illustrating another code analysis method provided in one embodiment of this application.
[0103] like Figure 4 As shown, the above code analysis methods may include:
[0104] S410. If the code repository server verifies the environment of the code repository server and the verification result indicates that the installation environment of the code repository server cannot install the analysis script, the analysis script sent by the code repository server is received; the analysis script is sent from the first server to the code repository server.
[0105] S420. Analyze the code pulled from the code repository server by the third server according to the analysis script to obtain the second analysis result;
[0106] S430. Send the second analysis result to the first server.
[0107] In some implementations, the amount of data in the analysis script and the first analysis result is much smaller than the amount of data in the code.
[0108] Therefore, since the first server sends the analysis script to the code repository server, and the code repository server analyzes the code stored in the code repository server according to the analysis script, and after obtaining the first analysis result, it sends the first analysis result back to the first server, which can avoid the problem of long transmission time caused by the large amount of data when the code repository server sends a large amount of code to the first server, thus improving the efficiency of code analysis.
[0109] Based on the same inventive concept, this application also provides a code analysis device 500, which is applied to a code repository server.
[0110] Figure 5 This illustration shows a structural schematic diagram of a code analysis device 500 provided in one embodiment of this application, as shown below. Figure 5 The device shown may include:
[0111] The acquisition module 501 is used to acquire the analysis script sent by the first server; the analysis script includes an analysis script for analyzing the code stored on the code repository server;
[0112] Verification module 502 is used to verify the installation environment of the code repository server according to the analysis script and obtain the verification results;
[0113] The first analysis module 503 is used to analyze the code according to the analysis script and obtain the first analysis result when the verification result indicates that the installation environment of the code repository server can install the analysis script.
[0114] The first sending module 504 is used to send the first analysis result to the first server.
[0115] Therefore, after the code repository server receives the analysis script sent by the first server, it verifies whether the code repository server's installation environment can install the analysis script. If the verification result indicates that the code repository can install the analysis script, the code repository server installs the analysis script and uses the installed analysis script to analyze the code on the code repository server. Because the analysis script is transferred from the first server to the code repository server, and then the code is analyzed on the code repository server, the time wasted due to the large amount of code being transferred from the code repository server to the first server and then analyzed by the first server is avoided. This improves the efficiency of code analysis.
[0116] In some implementations, the code analysis apparatus may further include:
[0117] The filtering module can be used to filter second servers located on the same network segment as the code repository server according to preset conditions when the verification result indicates that the installation environment of the code repository server cannot install the analysis script, so as to obtain a third server that meets the preset conditions.
[0118] The third sending module can be used to send the analysis script to the third server, so that the third server can analyze the code pulled from the code repository server according to the analysis script, and send the second analysis result obtained from the analysis to the first server.
[0119] In some implementations, the preset condition satisfies at least one of the following:
[0120] The memory capacity is no less than 8GB*2 in dual channels; the memory frequency is no less than 3000MHz; the storage hard disk meets the requirements of independent disk redundancy array or independent disk array with distributed parity check; and the network transmission rate with the code repository server is no less than 1000Mbps.
[0121] Therefore, the code repository server sends the analysis scripts and code to a third server located on the same network segment as the code repository server. This third server has a dual-channel memory capacity of at least 8GB*2, a memory frequency of at least 3000MHz, and an independent disk array with a redundant RAID or distributed parity check structure. The network transmission rate between the third server and the code repository server is at least 1000Mbps. By configuring the network segment, memory parameters, disk parameters, and transmission parameters of the third server, the problem of excessively long code transmission times due to these parameter limitations during code transmission from the code repository server to the third server can be avoided. Compared to transmitting code to the first server, transmitting code to a third server on the same network segment avoids the problems of cross-network segment transmission and long transmission distances required during code transmission from the code repository server to the first server. Overall, this improves the efficiency of code analysis.
[0122] Based on the same inventive concept, this application also provides a code analysis device, which is applied to a third server.
[0123] Figure 6 This application provides a schematic diagram of the structure of another code analysis apparatus according to one embodiment, as shown below. Figure 6 As shown, the device may include:
[0124] The receiving module 601 is used to receive the analysis script sent by the code repository server when the code repository server verifies the environment of the code repository server and the verification result indicates that the installation environment of the code repository server cannot install the analysis script; the analysis script is sent from the first server to the code repository server.
[0125] The second analysis module 602 is used to analyze the code pulled by the third server from the code repository server according to the analysis script, and obtain the second analysis result;
[0126] The second sending module 603 is used to send the second analysis result to the first server.
[0127] Therefore, since the first server sends the analysis script to the code repository server, and the code repository server analyzes the code stored in the code repository server according to the analysis script, and after obtaining the first analysis result, it sends the first analysis result back to the first server, which can avoid the problem of long transmission time caused by the large amount of data when the code repository server sends a large amount of code to the first server, thus improving the efficiency of code analysis.
[0128] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in one embodiment of this application is shown.
[0129] The electronic device 700 may include a processor 701 and a memory 702 storing computer program instructions.
[0130] Specifically, the processor 701 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0131] Memory 702 may include a large-capacity memory that can be used for data or instructions. For example, and not limitingly, memory 702 may include a hard disk drive (HDD), a floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 702 may include removable or non-removable (or fixed) media. Where appropriate, memory 702 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 702 is a non-volatile solid-state memory.
[0132] Memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this application.
[0133] The processor 701 implements any of the code analysis methods described in the above embodiments by reading and executing computer program instructions stored in the memory 702.
[0134] In some examples, the electronic device 700 may also include a communication interface 703 and a bus 710. For example, Figure 7 As shown, the processor 701, memory 702, and communication interface 703 are connected through bus 710 and complete communication with each other.
[0135] The communication interface 703 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0136] Bus 710 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not as a limitation, bus 710 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 710 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.
[0137] For example, as a payment terminal, electronic device 700 can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. As a scanning terminal, electronic device 700 can be a POS machine (Point of Sales, POS), barcode scanner, etc.
[0138] The electronic device can execute the code analysis method in the embodiments of this application, thereby achieving a combination Figures 3 to 6 The described code analysis methods and apparatus.
[0139] Furthermore, in conjunction with the code analysis methods in the above embodiments, this application embodiment can provide a computer-readable storage medium for implementation. This computer-readable storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the code analysis methods in the above embodiments. Examples of computer-readable storage media include non-transitory computer-readable storage media, such as portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, etc.
[0140] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0141] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments that can be used to perform desired tasks. Programs or code segments can be stored on machine-readable media or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable media" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0142] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0143] The aspects of this application have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by dedicated hardware performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0144] The above are merely specific embodiments of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A code analysis method characterized by, Applied to a code repository server, the method comprises: Obtaining an analysis script sent by a first server; the analysis script comprises an analysis script for analyzing code stored by the code repository server; Verifying an installation environment of the code repository server according to the analysis script to obtain a verification result; In a case where the verification result indicates that the installation environment of the code repository server can install the analysis script, analyzing the code according to the analysis script to obtain a first analysis result; Sending the first analysis result to the first server; In a case where the verification result indicates that the installation environment of the code repository server cannot install the analysis script, screening a second server in a same network segment as the code repository server according to a preset condition to obtain a third server satisfying the preset condition; Sending the analysis script to the third server to enable the third server to analyze code pulled from the code repository server according to the analysis script and send a second analysis result obtained by the analysis to the first server.
2. The method of claim 1, wherein, The preset condition comprises at least one of the following: A capacity of a memory is not less than 8G*2 dual channels; A frequency of the memory is not less than 3000MHZ; A storage hard disk satisfies a disk array of an independent disk structure of a redundant array of independent disks or a distributed parity check; A network transmission rate with the code repository server is not less than 1000Mbps.
3. The method of claim 1, wherein, The pulled code comprises a current version of code stored in the code repository server.
4. A code analysis method characterized by, Applied to a third server, the method comprises: In a case where a code repository server verifies an environment of the code repository server and a verification result indicates that an installation environment of the code repository server cannot install an analysis script, receiving the analysis script sent by the code repository server; the analysis script is sent to the code repository server by a first server; Analyzing code pulled by the third server in the code repository server according to the analysis script to obtain a second analysis result; Sending the second analysis result to the first server; The third server is a server satisfying a script installation condition and in a same network segment as the code repository server.
5. A code analysis system characterized by comprising: The system comprises: A code repository server configured to obtain an analysis script sent by a first server, analyze code stored by the code repository server according to the analysis script to obtain a first analysis result, and send the first analysis result to the first server; The first server configured to send the analysis script to the code repository server and receive the first analysis result sent by the code repository server; A third server configured to receive the analysis script sent by the code repository server, analyze code pulled in the code repository server according to the analysis script to obtain a second analysis result, and send the second analysis result to the first server. The code repository server is further configured to send the analysis script to the third server, and send the pulled code to the third server. The first server is further configured to receive the second analysis result sent by the third server.
6. The system of claim 5, wherein, The third server satisfies at least one of the following conditions: The third server is in the same network segment as the code repository server. The memory has a capacity of no less than 8G*2 dual channels. The memory has a frequency of no less than 3000MHZ. The storage hard disk satisfies a disk array structure of a redundant array of independent disks or a distributed parity check. The network transmission rate between the third server and the code repository server is no less than 1000Mbps.
7. A code analysis apparatus characterized by comprising: The device applied to a code repository server comprises: An acquisition module configured to acquire an analysis script sent by a first server, wherein the analysis script comprises an analysis script used for analyzing code stored in a code repository server; A verification module configured to verify an installation environment of the code repository server according to the analysis script, and obtain a verification result; A first analysis module configured to, in a case where the verification result indicates that the installation environment of the code repository server can install the analysis script, analyze the code according to the analysis script, and obtain a first analysis result; A first sending module configured to send the first analysis result to the first server; A screening module configured to, in a case where the verification result indicates that the installation environment of the code repository server cannot install the analysis script, screen a second server in the same network segment as the code repository server according to a preset condition, and obtain a third server satisfying the preset condition; A third sending module configured to send the analysis script to the third server, so that the third server analyzes code pulled from the code repository server according to the analysis script, and sends a second analysis result obtained by the analysis to the first server.
8. A code analysis apparatus characterized by comprising: The device applied to a third server comprises: A receiving module configured to, in a case where a code repository server verifies an environment of the code repository server, and a verification result indicates that an installation environment of the code repository server cannot install an analysis script, receive the analysis script sent by the code repository server, wherein the analysis script is sent to the code repository server by a first server; A second analysis module configured to analyze code pulled by the third server from the code repository server according to the analysis script, and obtain a second analysis result; A second sending module configured to send the second analysis result to the first server; The third server is a server satisfying a script installation condition and in the same network segment as the code repository server.
9. An electronic device, comprising: The device comprises a processor and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the code analysis method according to any one of claims 1-4.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer program instructions, and the computer program instructions are executed by a processor to implement the code analysis method in any one of claims 1-4.
11. A computer program product, characterised in that, The instructions in the computer program product are executed by a processor of an electronic device, so that the electronic device performs the code analysis method in any one of claims 1-4.
Citation Information
Patent Citations
Source code statistical analysis method and source code statistical analysis system
CN104750469A
Maintenance method and device for server
CN106325871A