A method and system for managing code files
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING NAT DIGITAL FINANCIAL TECH TESTING CENT CO LTD
- Filing Date
- 2025-12-26
- Publication Date
- 2026-05-26
Smart Images

Figure CN122087798A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method and system for managing code files. Background Technology
[0002] As the core files of a software system, the security of code files directly affects the continuity and stability of the data system's operation. However, natural disasters such as earthquakes and floods, as well as catastrophic scenarios such as large-scale DDoS attacks, may cause code files to be lost, damaged, or tampered with, thereby seriously threatening the security of code files and even potentially paralyzing the data system in extreme cases.
[0003] Currently, relevant technologies commonly employ local backups or periodic backups. While these methods offer some protection for code files, they also have significant limitations. For instance, locally backed-up code files are susceptible to synchronization failure due to natural disasters or physical damage to data centers, making effective recovery impossible. Periodic backups, on the other hand, have time interval issues; if a disaster occurs between backups, the latest code version will be lost. Therefore, a more reliable method is urgently needed to effectively ensure the security of code files. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a code file management method and system that strongly links code merging operations with code backup processes. This ensures that when a code merging operation is triggered, a backup is immediately initiated through the code backup process, guaranteeing that every code update or modification is backed up instantly. This prevents code file loss in disaster scenarios such as natural disasters like earthquakes and floods, or large-scale DDoS attacks. Furthermore, redundant code storage is achieved through multiple remotely deployed burning servers. During code file recovery, the verification server can read and verify the code file from any burning storage medium at any deployment location. Upon successful verification, the recovery server restores the code file, thereby preventing code file loss due to backup server failure in extreme disaster scenarios.
[0005] To achieve the above objectives, according to one aspect of the present invention, a method for managing code files is provided. The method for managing code files according to the present invention includes: a code management server, in response to a code merge operation being triggered in the development process, initiating a code backup process, and performing integrity verification on the code file corresponding to the code merge operation through the code backup process; wherein the development process and the code backup process are integrated within the code management server;
[0006] The code management server transfers code files to multiple burning servers; the multiple burning servers are deployed in different locations, and each deployment location corresponds to different geographical features, with the geographical distance between any two deployment locations being greater than a preset distance threshold;
[0007] Each burning server verifies the code file. Once the verification is successful, the data is burned to obtain one or more burning storage media containing the code file.
[0008] When a missing or corrupted code file is detected in the production environment, the verification server reads the code file from a burning storage medium at any deployment location and performs integrity verification, file structure verification, and dependency verification on the read code file.
[0009] If the verification fails, the verification server reads the code file from the burning storage medium at another deployment location and verifies the read code file until the verification passes.
[0010] If the verification passes, the verification server will transfer the code file to the recovery server;
[0011] The server performs functional verification on the code files and restores the code after successful verification.
[0012] Optionally, each burning server reads the code files in the burning storage medium according to a preset recovery cycle, and sends the read code files to the test server;
[0013] The test server simulates the test recovery process under the target scenario in the test environment, and verifies the integrity, file structure and dependencies of the code files in the test recovery process.
[0014] Optionally, after the code management server determines that the code file integrity verification has passed, the following steps are also included:
[0015] The code management server encrypts code files using a symmetric key and then encrypts the symmetric key using an asymmetric private key.
[0016] The code management server transfers code files to multiple burning servers, including: the code management server transferring encrypted code files to burning servers according to an end-to-end encrypted transmission protocol.
[0017] Optionally, each burning server verifies the code file, including: the code management server also sends the digest value of the code file to the burning server; after receiving the code file, the burning server generates a digest value and compares the generated digest value with the digest value sent by the code management server to verify the integrity of the code file.
[0018] Optionally, the data burning steps of the burning server further include: the burning server dividing the code file into multiple file blocks, generating a first hash value corresponding to each file block, and storing the first hash value and the code file into the burning storage medium.
[0019] Optionally, the step of the verification server performing integrity verification on the read code file includes: the verification server dividing the read code file into multiple file blocks and generating a second hash value corresponding to each file block;
[0020] The verification server compares the first hash value and the second hash value corresponding to the same file block to see if they are the same.
[0021] For abnormal file blocks with different hash values, the corresponding target file blocks are read from other burning storage media in the same deployment location, and the target file blocks are used to complete the code file. The integrity of the completed code file is then verified.
[0022] Optionally, the steps for the recovery server to perform functional verification on the code files include: performing compilation verification and unit test verification on the code files, and determining that the functional verification is successful if the compilation verification and unit test verification are successful.
[0023] Optionally, the recovery server performs a compilation operation on the code files in the test environment and checks for syntax errors and compilation failures during the compilation operation. If no errors are found, the compilation verification is confirmed to be successful.
[0024] Optionally, the server is restored to execute unit test cases, and the execution results of the unit test cases are compared with the benchmark results to determine the pass rate; if the pass rate is greater than the preset pass rate threshold, the unit test verification is determined to be successful; the unit test cases and benchmark results are stored in the burning storage medium by the burning server.
[0025] Optionally, the method further includes: monitoring the operating status of the code management server, burning server, verification server, and recovery server, and triggering an alarm process in case of abnormal status.
[0026] To achieve the above objectives, according to another aspect of the present invention, a code file management system is provided. One such code file management system includes: a code management server, a burning server, a verification server, and a recovery server; wherein,
[0027] The code management server is configured to: respond to the code merging operation in the development process by initiating a code backup process and verifying the integrity of the code files corresponding to the code merging operation through the code backup process; and transfer the code files to multiple burning servers; wherein the development process and the code backup process are integrated into the code management server; the multiple burning servers are deployed in different locations, and each deployment location corresponds to different geographical features, and the geographical distance between any two deployment locations is greater than a preset distance threshold;
[0028] Each burning server is configured to: verify the code file, and burn the data after the verification is passed, to obtain a copy of the code file or a burning storage medium.
[0029] The verification server is configured to: when a missing or corrupted code file is detected in the production environment, read the code file from a burning storage medium at any deployment location and perform integrity verification, file structure verification, and dependency verification on the read code file; if the verification fails, the verification server reads the code file from a burning storage medium at another deployment location and verifies the read code file until the verification passes; if the verification passes, the verification server transfers the code file to the recovery server.
[0030] Restore the server with the following configuration: perform functional verification on the code files, and restore the code after successful verification.
[0031] To achieve the above objectives, according to another aspect of the present invention, an electronic device for processing data is provided. An electronic device for processing data according to an embodiment of the present invention includes: one or more processors; and a storage device communicatively connected to the one or more processors for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement a code file management method according to an embodiment of the present invention.
[0032] To achieve the above objectives, according to another aspect of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium of the present invention stores a computer program thereon, which, when executed by a processor, implements a code file management method of the present invention.
[0033] To achieve the above objectives, according to another aspect of the present invention, a computer program product is provided, including a computer program that, when executed by a processor, implements a code file management method according to an embodiment of the present invention.
[0034] One embodiment of the above invention has the following advantages or beneficial effects: It strongly links the code merging operation with the code backup process, ensuring that a backup is immediately performed when the code merging operation is triggered. This guarantees that every code update or modification can be backed up instantly, thus avoiding code file loss in disaster scenarios such as natural disasters like earthquakes and floods, or large-scale DDoS attacks. Furthermore, redundant code storage is achieved through multiple remotely deployed burning servers. During code file recovery, the verification server can read and verify the code file from any burning storage medium at any deployment location. Upon successful verification, the recovery server restores the code file. This establishes a full lifecycle management mechanism for code files, from burning and storing to detection, replacement, and recovery. Regular data detection addresses the problems of easily corrupted traditional offline backup data and easily leaked obsolete data, thereby improving the reliability of offline storage and preventing code file loss due to backup server failure in extreme disaster scenarios.
[0035] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description
[0036] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:
[0037] Figure 1 This is a schematic diagram illustrating the main steps of a code file management method according to an embodiment of the present invention;
[0038] Figure 2 This is a schematic diagram of the architecture of a code management system according to an embodiment of the present invention;
[0039] Figure 3 This is a flowchart illustrating another code management method according to an embodiment of the present invention;
[0040] Figure 4 This is a schematic diagram of a code management system according to an embodiment of the present invention;
[0041] Figure 5 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;
[0042] Figure 6 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation
[0043] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0044] It should be noted that, unless otherwise specified, the embodiments of the present invention and the technical features thereof can be combined with each other.
[0045] like Figure 1 As shown, this embodiment of the invention provides a method for managing code files, which mainly includes the following steps S101-S106:
[0046] Step S101: In response to the code merge operation being triggered in the development process, the code management server starts the code backup process and performs integrity verification on the code file corresponding to the code merge operation through the code backup process; wherein, the development process and the code backup process are integrated in the code management server.
[0047] The code management server is a server capable of performing operations such as code review and merging. For example, after developers implement a feature, fix code errors, or update the code, they trigger a code merging operation in the development process to integrate the corresponding code into the main codebase. The code management server reviews the merged code (code files), completes the code merge, and immediately initiates a code backup process after the merge is complete to verify the integrity of the code files.
[0048] Specifically, the code management server can export the merged code files and then perform integrity verification. For example, before exporting the code files, the code management server calculates a first checksum M1 corresponding to the code files. After exporting the code files, it calculates a second checksum M2 using the same method. The server confirms whether the code files have been tampered with or corrupted by comparing the first checksum M1 and the second checksum M2. For instance, before exporting the code files, the code management server calculates the digest value of the code files, their associated dependent files, and version information using the SHA-256 hash algorithm as the first checksum M1. After exporting the code files, it calculates the digest value of the code files, their associated dependent files, and version information using the SHA-256 hash algorithm as the second checksum M2. If the first checksum M1 and the second checksum M2 are the same, it confirms that the code files have not been tampered with or corrupted; that is, the code files have passed the integrity verification and can continue with subsequent processes.
[0049] After the code file passes integrity verification, the code management server can further encrypt it. During encryption, the server can encrypt the code file using a symmetric key and then encrypt the symmetric key using an asymmetric private key, thus achieving encryption. The symmetric encryption algorithm is used to encrypt the code file to improve efficiency, while the asymmetric algorithm is used to encrypt the symmetric key to prevent key leakage and improve security. Therefore, by employing a hybrid encryption method combining symmetric and asymmetric encryption, both encryption efficiency and security are balanced.
[0050] Step S102: The code management server transfers the code files to multiple burning servers; the multiple burning servers are deployed in different locations, and each deployment location corresponds to different geographical features, with the geographical distance between any two deployment locations being greater than a preset distance threshold.
[0051] To further enhance the security of code files, the code management server can transmit encrypted code files to burning servers in multiple deployment locations via an end-to-end transmission protocol. For example, the code management server can use Transport Layer Security Version 3 (TLS 1.3) for end-to-end encrypted transmission of code files. TLS 1.3 is a widely used security protocol primarily used to provide encryption and authentication in network communications.
[0052] To prevent code files from becoming unrecoverable due to physical damage to the data center, this embodiment of the invention deploys multiple burning servers in different locations. Each deployment location is also equipped with an independent storage device with a stable environment to redundantly and stably store the burning servers containing the code files. For example, at least three storage sites with geographical locations exceeding 500 kilometers and corresponding to different geographical characteristics (such as not being in the same earthquake zone or flood-prone area) are selected within a defined area to deploy burning servers. Each deployment site is also equipped with anti-magnetic, fireproof, and waterproof storage cabinets for burning storage media containing code files (such as optical discs for backing up code). In addition, each deployment site is also independently equipped with backup power generation equipment and an environmental monitoring system to ensure a stable storage environment.
[0053] Step S103: Each burning server verifies the code file. After the verification is passed, the data is burned to obtain one or more burning storage media containing the code file.
[0054] In this embodiment of the invention, to enhance the security of the code files, the code management server and the burning server can verify each other's identities through certificates, ensuring that code file transmission and burning only occur after confirming the other party's legitimacy. For example, the code management server and the burning server can pre-obtain SSL certificates issued by a trusted third-party authority. These SSL certificates include their respective public keys; for instance, the code management server's SSL certificate includes its public key, and the burning server's SSL certificate includes its public key. Before sending the encrypted code files to the burning server, the code management server can first send its SSL certificate to the burning server. Upon receiving the SSL certificate from the code management server, the burning server generates a random number, encrypts it using the code management server's public key from the SSL certificate, and sends the encrypted random number to the code management server. If the code management server can decrypt the random number using its private key, it can establish a secure transmission channel with the burning server for subsequent code file transmission. During file transfer, the burning server can use this random number as a symmetric key to encrypt the code file, obtaining an encrypted code file. Then, using its public key, the burning server encrypts the random number (symmetric key) again, sending both the encrypted random number and the code file to the burning server. The burning server can then decrypt the encrypted random number using its private key. After confirming that the decrypted random number matches the previously generated one, the burning server verifies its legitimacy and can further decrypt the encrypted code file using the random number to continue the subsequent process. This SSL certificate verification ensures the legitimacy of both parties' identities and data security. Furthermore, both parties can verify the validity period of the SSL certificate, domain name binding relationships, and revocation status to prevent certificate forgery or hijacking, further enhancing security.
[0055] Furthermore, the burning server also performs integrity verification on the received code file to prevent it from being tampered with or damaged during transmission. In one embodiment of the invention, the code management server sends the code file's digest value to the burning server along with the code file. After receiving the code file, the burning server generates a digest value and compares it with the digest value sent by the proxy management server to verify the integrity of the code file.
[0056] The code management server and the burning server use the same basis and method to generate digest values. For example, the code management server generates a checksum based on the unencrypted code file. Alternatively, after verifying the integrity of the exported code file, it can send a second checksum M2 as the checksum to be transmitted along with the encrypted code file to the burning server. Upon receiving the encrypted code file, the burning server decrypts it and generates a checksum M3 using the same method. It then verifies the integrity of the code file by comparing M2 and M3. If M2 and M3 are the same, the integrity verification is considered successful. Another example is that the code management server can generate a checksum based on the encrypted code file, such as using the SHA-256 hash algorithm. It calculates a checksum M4 based on the encrypted code file and sends it along with the encrypted code file to the burning server. After receiving the encrypted code file and verifying the code management server's SSL certificate, the burning server calculates a checksum M5 using the SHA-256 hash algorithm and verifies the integrity of the code file by comparing M4 and M5. If M4 and M5 are the same, the integrity verification is considered successful.
[0057] After the certificate and integrity verification are confirmed to be successful, the burning server burns the code files. For example, the burning server can automatically and completely burn the code files through offline backup nodes, and monitor the burning progress and data integrity in real time during the burning process. If a burning error occurs (such as data writing failure or storage media damage), it will issue a prompt to replace the storage media and re-burn. Industrial-grade Blu-ray discs can be used for burning, which have a large burning capacity (≥100GB) and a long storage life (≥50 years), which is beneficial for the long-term stable storage of code files.
[0058] When burning code files, the burning server can either burn the decrypted code files to an optical disc or burn the encrypted code files to an optical disc. In one embodiment of the present invention, to improve the security of the code files, the burning server burns the code files encrypted with a symmetric key to an optical disc. Therefore, even if the optical disc is lost or stolen, the party obtaining the disc will not be able to decrypt the code files because they do not have the key, thus significantly improving the security of the code files.
[0059] In addition, to facilitate code file verification during subsequent code recovery, the burning server divides the code file into multiple file blocks during the burning process and generates a first hash value corresponding to each file block. The first hash values and corresponding code files are stored in the burning storage medium. This allows the subsequent verification server to perform integrity verification on the code file based on the first hash values and file blocks, improving verification accuracy. Specific verification methods will be further described in subsequent embodiments.
[0060] Furthermore, each burning server at each deployment location can burn code files using a redundant storage mode. This means each burning server burns multiple copies of the code files, resulting in multiple burning storage media (such as optical discs) containing the complete code files. Therefore, by combining multiple deployment locations and a redundant storage mode with multiple burning storage media at each location, the problem of data corruption easily caused by traditional backup methods is solved, improving the reliability of offline code file storage.
[0061] After multiple copies of the recording storage media (taking optical discs as an example) are obtained, the recording server can generate a unique identifier for each disc based on factors such as recording time, code version, checksum, and deployment location. Furthermore, the identifier can be laser-etched onto the disc surface, and then a designated person stores the discs in a dedicated storage cabinet, establishing a disc storage ledger for periodic inspection.
[0062] Furthermore, behind a dedicated storage cabinet at the optical disc storage deployment site, the burning server can send a backup success notification to the development and operations systems. This notification can include the backup time, optical disc identification code, deployment location information, and checksum, allowing development and operations personnel to be aware of the code file backup status and facilitating restoration later if needed. If burning fails, transportation fails, or site storage fails, the burning server can automatically trigger multi-level alarms (such as SMS, email, or system pop-ups) and initiate a backup burning and transportation process to complete the burning and storage of the code files.
[0063] Step S104: When a code file is detected to be missing or corrupted in the production environment, the verification server reads the code file from the burning storage medium at any deployment location and performs integrity verification, file structure verification, and dependency verification on the read code file; if the verification passes, proceed to step S106; if the verification fails, proceed to step S105.
[0064] Step S105: The verification server reads the code file from the burning storage medium at another deployment location and verifies the read code file until the verification passes.
[0065] Step S106: The verification server transfers the code file to the recovery server;
[0066] Step S107: The server performs functional verification on the code files and restores the code after the verification is successful.
[0067] In this embodiment of the invention, proactive preventative measures can be implemented to periodically restore and verify the recordable storage medium, thereby ensuring its security and stability. Furthermore, disaster recovery verification can be used to recover code files, ensuring the availability and functional integrity of the recovered code.
[0068] For example, in one embodiment of the present invention, each burning server reads the code files in the burning storage medium according to a preset recovery cycle, and sends the read code files to the test server; the test server simulates the test recovery process under the target scenario in the test environment, and verifies the integrity, file structure and dependencies of the code files in the test recovery process, thereby realizing the periodic recovery verification of the burning storage medium and ensuring the integrity of the code files stored in the burning storage medium.
[0069] The preset recovery cycle can be set according to the importance of the code, thus obtaining a differentiated verification cycle based on the importance of the code files. Code importance is inversely proportional to the verification cycle; that is, the more important the code file, the shorter its corresponding verification cycle. For example, level A represents core business code, with a verification cycle of one quarter; level B represents auxiliary function code, with a verification cycle of six months; and level C represents test and maintenance code, with a verification cycle of one year. Therefore, for core business code, a full recovery verification is conducted quarterly; for auxiliary function code, a full recovery verification is conducted every six months; and for test and maintenance code, a full recovery verification is conducted annually. To reduce the verification workload, a proportional random sample of storage media can be selected for verification during each verification process. For example, 10% of the optical discs in each deployment location can be randomly sampled during each verification, covering optical discs burned at different times to ensure that the sampled samples cover the backup code files throughout their entire lifecycle.
[0070] During the verification process, the physical condition and identification consistency of the extracted optical discs are checked first to eliminate basic faults through pre-verification. After successful pre-verification, the code files on the optical discs can be read and sent to the test server. If the code files stored on the optical discs are encrypted, the burning server can first decrypt them using the recorded symmetric key before transmitting the decrypted code files to the test server. The test server is deployed in an isolated test environment that simulates target scenarios such as natural disasters like earthquakes and floods, and large-scale DDoS attacks, to simulate the code file recovery process under extreme disaster scenarios. The integrity, file structure, and dependency integrity of the code files are verified during the recovery process. For example, the code files are divided into blocks using the same file sharding method as during the burning process, and then hash verification is performed on each block based on the sharding results to verify the integrity of the code files. Furthermore, by checking whether the directory structure, filename, and extension of the code files received by the test server are consistent with the original structure during backup, the file structure of the code files is verified to prevent file loss or structural errors due to reading errors. In addition, the version number and size of the dependent files associated with the code (such as library files and configuration files) are verified to ensure that they match the backup records, thus ensuring that the dependent files are not lost and that the versions match, thereby verifying the dependencies of the code files.
[0071] After performing integrity checks, file structure checks, and dependency checks on the code files during the test recovery process, the test server can record the pass rate and the repair status of abnormal file blocks. For example, the test server reads the first hash value H1 of each file block corresponding to the code file in the burned storage medium, and divides the read code file into multiple file blocks using the same block-splitting method, generating a second hash value H2 for each file block. Abnormal file blocks are detected by comparing whether the first hash value H1 and the second hash value H2 corresponding to the same file block are the same. Specifically, file blocks with different first hash values H1 and second hash values H2 are identified as abnormal file blocks. For abnormal file blocks, other burned storage media at the same deployment location can be used, and the corresponding target file block can be read again. The target file block is then used to replace the abnormal file block to complete the code file. The integrity of the completed code file is then re-checked, and the pass rate and the repair status of the abnormal file blocks are recorded. Therefore, by using multiple burned storage media at the same deployment location to complete abnormal code file blocks, the risk of unrecoverable data due to corrupted burned code files is reduced. After the test server verifies the recovery of the burned storage media, if it is determined that the code files on the burned storage media are corrupted, the corresponding burned storage media can be physically destroyed to reduce storage costs and avoid the problem of leaked obsolete data. If the proportion of corrupted multiple burned storage media at a certain deployment location exceeds a preset threshold, the code files can be re-burned to maintain redundant code storage at that deployment location.
[0072] After the test server performs periodic recovery verification on the burning storage media and its stored code files according to a preset recovery cycle, it can also generate a data recovery verification report corresponding to this recovery cycle. The data recovery verification report clearly states the verification results, the problems found (such as the excessive read error rate of a certain batch of optical discs), and the corresponding rectification suggestions (such as reburning the code files). After the development or operation and maintenance personnel make rectifications based on the rectification suggestions, they can also update the recovery verification report to record the rectification status.
[0073] In another embodiment of the present invention, when the deployment location suffers extreme disasters such as earthquakes, floods, or large-scale cyberattacks, resulting in the loss or corruption of code in the production environment, code files can be burned onto storage media for recovery. Compared to the aforementioned proactive periodic recovery verification method based on a preset recovery cycle, the recovery verification process in this disaster scenario is a passive response method. For example, when earthquakes, floods, or large-scale cyberattacks occur, if code files in the production environment are detected to be lost or corrupted (e.g., unavailable), the verification server can attempt to perform recovery verification based on the code files stored on the burning storage media at any deployment location. Specifically, the production environment server can automatically detect whether the code files in the production environment are available. If the server automatically issues an alert when the code files are unavailable, relevant maintenance personnel can initiate the verification server to perform the code recovery process based on the alert information. Alternatively, relevant testing personnel can also detect whether the code files in the production environment are available. If the testing personnel determine that the data center or server in the production environment has suffered irreparable physical damage due to disasters such as earthquakes or floods, then the corresponding code files in the production environment are determined to be unavailable, and the code recovery process can also be initiated.
[0074] Before executing the recovery verification process, the physical condition and basic information of the burning storage media can be pre-verified. For example, for physical condition pre-verification, a dedicated optical inspection device can be used to check the surface of the disc for scratches, stains, deformation, or other physical damage. If the damage may affect the reading of code files, other spare discs from the same batch should be immediately replaced. For basic information pre-verification, the unique identification code laser-etched on the disc surface can be read and compared with the basic information recorded in the backup table, such as backup time, code version, checksum, and deployment site, to confirm that the identification code has not been tampered with or mistakenly taken.
[0075] After pre-verification is successful, the verification server can read the code file from the pre-verified storage medium and perform multi-dimensional verification on the code file, such as integrity verification, file structure verification, and dependency verification. For example, for integrity verification, the verification server divides the read code file into multiple file blocks and generates a second hash value for each file block. The verification server then compares the first hash value and the second hash value corresponding to the same file block. For abnormal file blocks with different hash values, the server reads the corresponding target file block from other storage media at the same deployment location, uses the target file block to complete the code file, and performs integrity verification on the completed code file. Specifically, the verification server divides the code file into blocks using the same file block division method as in the burning process, such as dividing the burning process into 64MB blocks, and then performing hash verification block by block based on the block division results to verify the integrity of the code file. Specifically, during the burning process, the SHA-256 hash value of each file block is stored as the first hash value in the burning storage medium. During the verification process on the verification server, the SHA-256 hash value of each file block is generated in real time as the second hash value. By comparing it block by block with the first hash value during disc burning, if the first and second hash values of a file are different, the file can be automatically retried three times. If the retry fails, the file block is marked as an abnormal file block, and data is completed using other discs (discs from the same batch) at the same deployment location. That is, after replacing the discs with discs from the same batch at the same deployment location, the target file block corresponding to the abnormal file block is read from it, and the target file block is used to replace the abnormal file block to complete the code file. Then, the integrity of the completed code file is re-verified, and the verification pass rate and the repair status of the abnormal file block are recorded. In addition, the file structure of the code file can be verified by checking whether the directory structure, file name, and extension of the code file are consistent with the original structure during backup, to prevent file loss or structural disorder due to reading errors. In addition, the version number and size of the dependent files associated with the code (such as library files and configuration files) are verified to match the backup records, ensuring that the dependent files are not lost and that the versions match, thereby realizing the verification of the code file dependencies.
[0076] After the verification server confirms that integrity verification, file structure verification, and dependency verification have all passed, the code file can be transferred to the recovery server. The recovery server further verifies the functionality of the code file, and restores the code after successful verification. For example, the recovery server performs compilation verification and unit test verification on the code file. If both compilation verification and unit test verification pass, the functional verification is considered successful. During compilation verification, the recovery server performs compilation operations on the code file in an isolated test environment and checks for syntax errors and compilation failures. If none are found, the compilation verification is considered successful. If compilation errors occur, the abnormal file block is located and repaired using redundant data. The repaired code file is then recompiled and verified until the number of successful or failed verifications reaches a preset threshold, at which point the compilation verification is considered a failure. During unit test verification, the recovery server executes unit test cases and compares the execution results of the unit test cases with the benchmark results to determine the pass rate. If the pass rate is greater than a preset pass rate threshold, the unit test verification is considered successful. The unit test cases and benchmark results are stored on the burning server's burning storage medium. For example, unit test cases and benchmark results are burned to a CD by a burning server along with the code files. During the unit test verification process, after the recovery server executes the unit test cases, it compares the test results with the benchmark results stored in the CD. Based on the comparison results of each function, the pass rate is determined. When the pass rate is greater than the preset pass rate threshold, the unit test is considered to have passed, so as to ensure that the core functional logic is not damaged during the recovery process.
[0077] After verification is completed, the recovery server can also generate a data recovery verification report, which includes information such as pre-verification results, verification records, functional test results, and exception handling, serving as proof of the validity of code recovery.
[0078] Furthermore, if an unrecoverable anomaly occurs in any of the above verification / validation stages, such as in integrity verification, file structure verification, dependency verification, compilation verification, or unit test verification, or if multiple data blocks are corrupted and cannot be restored through redundant backups, or if compilation fails and cannot be repaired, the recovery server can immediately trigger a cross-location recovery plan. That is, it reads the code file from the burning storage medium at another deployment location and verifies the read code file according to the above verification process, including integrity verification, file structure verification, dependency verification, compilation verification, and unit test verification, until the verification passes and the code file can be recovered, or it can be confirmed that the code files in all deployment locations are invalid or corrupted.
[0079] The following is combined with Figure 2The system architecture diagram shown here, applied to the code file management method of this embodiment of the invention, illustrates the code file management method provided by this embodiment of the invention using a specific example. For example... Figure 3 As shown, the method may include the following steps:
[0080] Step S301: The code management server responds to the code merge operation in the development process by obtaining the code merge request, merging the code according to the code merge request, and initiating the code backup process. The integrity of the code file corresponding to the code merge operation is verified through the code backup process. After the verification is passed, step S302 is executed.
[0081] Understandably, if the verification fails, it means that the code file has been corrupted or tampered with. In this case, the code management server can re-export the code file and re-verify its integrity until the verification passes or the preset number of times is reached, after which a verification failure message will be issued.
[0082] Step S302: The code management server encrypts the code file using a symmetric key and then encrypts the symmetric key using an asymmetric private key.
[0083] The code management server integrates development and code backup processes. For example, the code management server is configured with a DevOps platform. Developers can use the DevOps platform to develop features, fix code errors, or update code. Then, they can submit a code merge request (A1) by triggering the code merge operation in the development process. After the DevOps platform reviews the code merge (A2), it merges the code (A3). Immediately after the code merge is completed, it initiates a code backup process to export the merged code (A4). The exported code file is then verified for integrity (A5). After successful verification, it is encrypted to obtain an encrypted code file.
[0084] Step S303: The code management server transmits the encrypted code file, the encrypted symmetric key, and the digest value of the code file to multiple burning servers deployed in different locations through an end-to-end transmission protocol. Each deployment location corresponds to different geographical features, and the geographical distance between any two deployment locations is greater than a preset distance threshold.
[0085] For example, select at least three data centers within a designated area that are geographically more than 500 kilometers apart and correspond to different geographical characteristics (such as not being in the same earthquake zone or flood-prone area). Figure 2 Taking data centers 1-3 as an example, we can deploy burning servers. Each deployment location can also be equipped with anti-magnetic, fireproof, and waterproof storage cabinets for burning storage media containing code files (such as CDs for backing up code).
[0086] Step S304: Each burning server generates a digest value based on the received code file and compares the generated digest value with the digest value sent by the code management server to perform integrity verification on the received code file. If the verification passes, proceed to step S305.
[0087] If the verification fails, the burning server can return the verification failure result to the code management server. The code management server can then resend the encrypted code file based on the verification failure result. The burning server will then re-perform the integrity verification until the verification passes or the preset number of times is reached, at which point a verification failure message will be issued.
[0088] Step S305: The burning server burns the encrypted code file to multiple burning storage media.
[0089] In this embodiment of the invention, industrial-grade Blu-ray discs can be used as the recording storage medium to facilitate the long-term stable storage of code files. Furthermore, each recording server records multiple copies of the code files, resulting in multiple recording storage media (such as optical discs) storing the code files. This redundant storage mode, combining multiple deployment locations and storing multiple copies of the recording storage media at each location, solves the problem of data corruption that is easily caused by traditional backup methods, improving the reliability of offline code file storage. In addition, after obtaining multiple recording storage media (taking optical discs as an example) through recording, a designated person can store the optical discs in a dedicated storage cabinet and establish an optical disc storage ledger to periodically check the optical discs.
[0090] Step S306: Each burning server reads the code file in the burning storage medium according to the preset recovery cycle, and sends the read code file to the test server.
[0091] Step S307: The test server simulates the test recovery process under the target scenario in the test environment, and verifies the integrity, file structure and dependencies of the code files in the test recovery process, and records the verification information.
[0092] The burning server and the test server at the same deployment location can be the same physical server or different physical servers; this embodiment of the invention does not limit this.
[0093] Step S308: When a code file is detected to be missing or corrupted in the production environment, the verification server reads the code file from the burning storage medium at any deployment location and performs integrity verification, file structure verification, and dependency verification on the read code file. If the verification fails, proceed to step S309; if the verification passes, proceed to step S310.
[0094] Steps S306 and S308 can be executed in parallel.
[0095] Step S309: The verification server reads the code file from the burning storage medium at another deployment location and performs the verification step of step S308 based on the read code file.
[0096] Step S310: The verification server transfers the code file to the recovery server;
[0097] Step S311: The server performs functional verification on the code files and restores the code after the verification is successful.
[0098] The verification server and the recovery server can be the same physical server or different physical servers; this embodiment of the invention does not limit this.
[0099] In the management of the aforementioned code files, a comprehensive intelligent monitoring and rapid response mechanism is also established. For example, the operational status of the code management server, burning server, verification server, and recovery server is monitored, and an alarm process is triggered in case of abnormal status. This establishes a comprehensive intelligent monitoring system covering the verification, burning, transmission, periodic proactive verification and recovery, and passive verification and recovery of code files, enabling real-time monitoring of status indicators at each stage, effective management of code files, and improved code file security.
[0100] According to the above embodiments, the code merging operation is strongly linked to the code backup process. This ensures that when the code merging operation is triggered, a backup is immediately initiated through the code backup process, guaranteeing that every code update or modification is backed up instantly. This prevents code file loss in disaster scenarios such as natural disasters like earthquakes and floods, or large-scale DDoS attacks. Furthermore, redundant code storage is achieved through multiple remotely deployed burning servers. During code file recovery, the verification server can read and verify the code file from any burning storage medium at any deployment location. Upon successful verification, the recovery server restores the code file. This establishes a full lifecycle management mechanism for code files, from burning and storage to detection, replacement, and recovery. Regular data monitoring addresses the issues of data corruption and leakage of obsolete data in traditional offline backups, thereby improving the reliability of offline storage and preventing code file loss due to backup server failure in extreme disaster scenarios.
[0101] Based on the same inventive concept as the above embodiments, this embodiment of the invention also provides a code file management system, such as... Figure 4 As shown, the code file management system 400 includes: a code management server 401, a burning server 402, a verification server 403, and a recovery server 404; wherein,
[0102] The code management server 401 is configured to: initiate a code backup process in response to a code merge operation in the development process, and perform integrity verification on the code file corresponding to the code merge operation through the code backup process; transfer the code file to multiple burning servers 402; wherein the development process and the code backup process are integrated in the code management server 401; the multiple burning servers 402 are deployed in different locations, and each deployment location corresponds to different geographical features, and the physical distance between any two deployment locations is greater than a preset distance threshold;
[0103] Each burning server 402 is configured to: verify the code file, and burn the data after the verification is passed, to obtain one or more burning storage media containing the code file;
[0104] Verification server 403 is configured to: when a code file is detected to be missing or corrupted in the production environment, read the code file from a burning storage medium at any deployment location and perform integrity verification, file structure verification, and dependency verification on the read code file; if the verification fails, verification server 403 reads the code file from a burning storage medium at another deployment location and verifies the read code file until the verification passes; if the verification passes, verification server 403 transfers the code file to the recovery server;
[0105] To resolve a 404 error on the server, configure the system to perform functional verification on the code files and restore the code once the verification is successful.
[0106] In one embodiment of the present invention, each burning server 402 is configured to: read code files in the burning storage medium according to a preset recovery cycle, and send the read code files to the test server; so that the test server simulates the test recovery process under the target scenario in the test environment, and verifies the integrity, file structure and dependencies of the code files in the test recovery process.
[0107] In one embodiment of the present invention, the code management server 401 is further configured to: perform integrity verification on the code file, encrypt the code file with a symmetric key after the verification is passed, and encrypt the symmetric key with an asymmetric private key.
[0108] In one embodiment of the present invention, the code management server 401 is configured to transmit the encrypted code file to the burning server 402 according to the end-to-end encrypted transmission protocol.
[0109] In one embodiment of the present invention, the code management server 401 is further configured to send the digest value of the code file to the burning server 402; the burning server 402 is configured to generate a digest value after receiving the code file, and compare the generated digest value with the digest value sent by the code management server to verify the integrity of the code file.
[0110] In one embodiment of the present invention, the burning server 402 is configured to: divide the code file into multiple file blocks, generate a first hash value corresponding to each file block, and store the first hash value and the code file in the burning storage medium.
[0111] In one embodiment of the present invention, the verification server 403 is further configured to: divide the read code file into multiple file blocks and generate a second hash value corresponding to each file block; compare whether the first hash value and the second hash value corresponding to the same file block are the same; for abnormal file blocks with different hash values, read the corresponding target file block from other burning storage media at the same deployment location, use the target file block to complete the code file, and perform integrity verification on the completed code file.
[0112] In one embodiment of the present invention, the recovery server 404 is configured to: perform compilation verification and unit test verification on the code file, and determine that the functional verification is passed if the compilation verification and unit test verification are passed.
[0113] In one embodiment of the present invention, the recovery server 404 is configured to: perform a compilation operation on the code file in the test environment, and check whether there are any syntax errors and compilation failures during the compilation operation; if no errors are found, the compilation verification is confirmed to be successful.
[0114] In one embodiment of the present invention, the recovery server 404 is configured to: execute unit test cases, compare the execution results of the unit test cases with the benchmark results to determine the pass rate; determine that the unit test verification is passed if the pass rate is greater than a preset pass rate threshold; and store the unit test cases and benchmark results in the burning storage medium on the burning server.
[0115] In one embodiment of the present invention, the code file management system further includes a monitoring server, which is configured to monitor the operating status of the code management server, burning server, verification server and recovery server, and trigger an alarm process in case of abnormal status.
[0116] As can be seen from the code file management method and system provided in the above embodiments, the code merging operation is strongly linked to the code backup process. This ensures that when the code merging operation is triggered, a backup is immediately performed through the code backup process, guaranteeing that every code update or modification is backed up in real time. This avoids the loss of code files in disaster scenarios such as natural disasters like earthquakes and floods, or large-scale DDoS attacks. Furthermore, redundant code storage is achieved through multiple remotely deployed burning servers. During the code file recovery process, the verification server can read and verify the code file from the burning storage medium at any deployment location. Upon successful verification, the recovery server restores the code file, thereby preventing the loss of code files due to backup server failure in extreme disaster scenarios.
[0117] Figure 5 An exemplary system architecture 500 is shown, which can be applied to the code file management method or system of embodiments of the present invention.
[0118] like Figure 5 As shown, the system architecture 500 may include terminal device 501, network 502, and servers 503, 504, 505, and 506. Network 502 serves as the medium for providing communication links between terminal device 501 and servers 503, 504, 505, and 506. Network 502 may include various connection types, such as wired, wireless communication links, or fiber optic cables. Users can use terminal device 501 to access various applications, such as instant messaging tools and social media platforms, and can initiate code merging requests to server 503 through network 502. Terminal device 501 can be various electronic devices with a display screen and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers. Server 503 is a server capable of responding to code merging requests, merging code files, and sending encrypted code files to a remotely deployed server 504 for code backup. For example, it may be a backend server configured with a DevOps platform, capable of feature development, code bug fixing, or code updates. Server 504 is a server capable of burning code files to storage media for code file backup. Server 505 is a server capable of performing integrity checks, file structure checks, and dependency checks on the code to be restored during the recovery verification process to ensure the validity of the restored code files. Server 506 is a server capable of performing functional verification on the code files and restoring the code. It should be understood that... Figure 5 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0119] The following is for reference. Figure 6It shows a schematic diagram of the structure of a computer system 600 suitable for implementing a terminal device of the present invention. Figure 6 The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0120] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 602 or programs loaded from storage section 606 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the system 600. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0121] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.
[0122] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by central processing unit (CPU) 601, it performs the functions defined above in the system of this invention.
[0123] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0124] The flowcharts and block diagrams in the accompanying drawings 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 a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0125] The modules described in the embodiments of the present invention can be implemented in software or hardware. As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, which, when executed by the device, enable the device to perform the code management method provided in the embodiments of the present invention.
[0126] According to the technical solution of this invention, the code merging operation is strongly correlated with the code backup process. This ensures that when the code merging operation is triggered, a backup is immediately performed through the code backup process, guaranteeing that every code update or modification is backed up instantly. This prevents code file loss in disaster scenarios such as natural disasters like earthquakes and floods, or large-scale DDoS attacks. Furthermore, redundant code storage is achieved through multiple remotely deployed burning servers. During code file recovery, the verification server can read and verify the code file from any burning storage medium at any deployment location. Upon successful verification, the recovery server restores the code file, thereby preventing code file loss due to backup server failure in extreme disaster scenarios.
[0127] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for managing code files, characterized in that, include: In response to a code merge operation being triggered in the development process, the code management server initiates a code backup process and performs integrity verification on the code file corresponding to the code merge operation through the code backup process; wherein, the development process and the code backup process are integrated into the code management server. The code management server transmits the code files to multiple burning servers; the multiple burning servers are deployed in different locations, and each deployment location corresponds to different geographical features, with the geographical distance between any two deployment locations being greater than a preset distance threshold; Each of the burning servers verifies the code file. After the verification is passed, the data is burned to obtain one or more burning storage media containing the code file. When a missing or corrupted code file is detected in the production environment, the verification server reads the code file from the burning storage medium at any of the deployment locations and performs integrity verification, file structure verification, and dependency verification on the read code file. If the verification fails, the verification server reads the code file from the burning storage medium at another deployment location and verifies the read code file until the verification passes. If the verification passes, the verification server will transfer the code file to the recovery server; The recovery server performs functional verification on the code file and restores the code after the verification is successful.
2. The method according to claim 1, characterized in that, Also includes: Each of the burning servers reads the code files in the burning storage medium according to a preset recovery cycle, and sends the read code files to the test server. The test server simulates the test recovery process under the target scenario in the test environment, and verifies the integrity, file structure and dependencies of the code files in the test recovery process.
3. The method according to claim 1, characterized in that, After the code management server determines that the code file integrity verification has passed, the process further includes: The code management server encrypts the code file using a symmetric key and encrypts the symmetric key using an asymmetric private key; The code management server transmits the code file to multiple burning servers, including: the code management server transmitting the encrypted code file to the burning server according to an end-to-end encrypted transmission protocol.
4. The method according to claim 1, characterized in that, Each of the burning servers verifies the code file, including: The code management server also sends the digest value of the code file to the burning server; After receiving the code file, the burning server generates a digest value and compares the generated digest value with the digest value sent by the code management server to verify the integrity of the code file.
5. The method according to claim 4, characterized in that, The data burning steps performed by the burning server also include: The burning server divides the code file into multiple file blocks and generates a first hash value corresponding to each file block. The first hash value and the code file are then stored in the burning storage medium.
6. The method according to claim 5, characterized in that, The steps of the verification server performing integrity verification on the read code file include: The verification server divides the read code file into multiple file blocks and generates a second hash value corresponding to each file block. The verification server compares whether the first hash value and the second hash value corresponding to the same file block are the same; For abnormal file blocks with different hash values, the corresponding target file blocks are read from other burning storage media at the same deployment location, and the target file blocks are used to complete the code file. The integrity of the completed code file is then verified.
7. The method according to claim 1, characterized in that, The steps for the recovery server to perform functional verification on the code file include: The recovery server performs compilation verification and unit test verification on the code file, and determines that the function verification is successful if the compilation verification and unit test verification are successful.
8. The method according to claim 7, characterized in that, The recovery server performs a compilation operation on the code file in the test environment and checks for syntax errors and compilation failures during the compilation operation. If no errors are found, the compilation verification is confirmed to be successful. And / or, The recovery server executes unit test cases, compares the execution results of the unit test cases with the benchmark results to determine the pass rate; if the pass rate is greater than a preset pass rate threshold, the unit test verification is determined to be successful. The unit test cases and the benchmark results are stored in the burning storage medium by the burning server.
9. The method according to claim 1, characterized in that, Also includes: Monitor the operating status of the code management server, the burning server, the verification server, and the recovery server, and trigger an alarm process if the status is abnormal.
10. A code file management system, characterized in that, include: Code management server, burning server, verification server, and recovery server; among them, The code management server is configured to: initiate a code backup process in response to a code merge operation being triggered in the development process, and perform integrity verification on the code file corresponding to the code merge operation through the code backup process; and transfer the code file to multiple burning servers; wherein the development process and the code backup process are integrated into the code management server; the multiple burning servers are deployed in different locations, and each deployment location corresponds to different geographical features, with the geographical distance between any two deployment locations being greater than a preset distance threshold; Each of the burning servers is configured to: verify the code file, and after the verification is passed, burn the data to obtain one or more burning storage media containing the code file; The verification server is configured to: when a code file is detected to be lost or corrupted in the production environment, read the code file from the burning storage medium at any deployment location, and perform integrity verification, file structure verification, and dependency verification on the read code file; if the verification fails, the verification server reads the code file from the burning storage medium at another deployment location and verifies the read code file until the verification passes; if the verification passes, the verification server transmits the code file to the recovery server. The recovery server is configured to perform functional verification on the code file and restore the code after the verification is successful.
11. An electronic device for managing code files, characterized in that, include: One or more processors; A storage device, communicatively connected to the one or more processors, is used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method for managing code files as described in any one of claims 1-9.
12. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method for managing code files as described in any one of claims 1-9.