Code file processing method and device
By storing the public key and private key of the target user in the code warehouse platform and the code analysis server respectively, and performing encryption and decryption processing, the risk of leakage of the enterprise when pulling the code from the server is solved, and the security of the code is guaranteed.
Patent Information
- Application Number
- CN202410316276.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-20
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-03-20
AI Technical Summary
When an enterprise pulls code from the server, there is a risk of code leakage or spread to the outside world. In particular, enterprises with high code security requirements find it difficult to effectively prevent code leakage.
By generating the public key and private key of the target user, the public key is stored in the code warehouse platform, and the private key is stored in the code analysis server. After receiving the code pull request, the code file is encrypted using the public key and sent to the code analysis server for processing. Decryption processing ensures that code files do not directly expose plain text.
It effectively reduces the risk of code leakage or external spread, ensures the security of the code, and avoids batch downloading of code on the server or external transmission.
Smart Images

Figure CN117909941B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of system security technology, and in particular to a method and device for processing a code file. Background Art
[0002] Enterprises often have users who need to pull code from the server and perform code quality inspection and analysis. Once the code is downloaded to the server's hard disk in batches, the remote login personnel may download the code to the local computer. For enterprises with high code security requirements, pulling code from the server will undoubtedly cause the risk of code leakage or external spread. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a method and device for processing a code file, which can reduce the risk of code leakage or external diffusion after the code file is pulled from the server.
[0004] In a first aspect, an embodiment of the present invention provides a method for processing a code file, comprising:
[0005] Generate the public key and private key corresponding to the target user;
[0006] The public key is stored in the code warehouse platform, and the private key is stored in the code analysis server;
[0007] Receive a code pull request sent by the target user;
[0008] Control the code warehouse platform to generate a code file corresponding to the code pull request, encrypt the code file using the public key, and send the encrypted code file to the code analysis server;
[0009] Receiving an analysis instruction for the encrypted code file;
[0010] The code analysis server is controlled to decrypt the encrypted code file according to the private key to respond to the analysis instruction.
[0011] Optionally, before controlling the code warehouse platform to generate a code file corresponding to the code pull request, the method further includes:
[0012] Receive and save permission configuration information for the target user;
[0013] The controlling the code warehouse platform to generate a code file corresponding to the code pull request includes:
[0014] Determine, based on the permission configuration information, whether the target user has permission to pull the code file;
[0015] In response to the target user having permission to pull the code file, the step of controlling the code repository platform to generate a code file corresponding to the code pull request is performed.
[0016] Optionally, after sending the encrypted code file to the code analysis server, the method further includes:
[0017] Determine the user information of the target user and the file information of the code file;
[0018] Generate a code pull log record according to the user information and the file information.
[0019] Optionally, after receiving the code pull request sent by the target user, the method further includes:
[0020] Adding the target user to a controlled group;
[0021] Receiving an execution instruction for a target application sent by the target user; wherein the target application is deployed in the code warehouse platform or the code analysis server;
[0022] Determining whether the target application is a controlled application, and determining whether the target user is in a controlled group;
[0023] In response to the target application being a controlled application and the target user being in a controlled group, refusing to process the execution instruction.
[0024] Optionally, it also includes:
[0025] Control the code analysis server to obtain an uploaded file from a preset path of a file server, and save the uploaded file in a local temporary path of the code analysis server;
[0026] Determine the uploading user corresponding to the uploaded file;
[0027] The uploaded file is moved to the user path corresponding to the uploading user, and the file owner of the uploaded file is changed to the uploading user.
[0028] Optionally, the step of saving the uploaded file in a local temporary path of the code analysis server includes:
[0029] Scanning the uploaded file in the code analysis server;
[0030] In response to the scanning result indicating that the uploaded file is a safe file, the step of saving the uploaded file in a local temporary path of the code analysis server is performed.
[0031] Optionally, before controlling the code analysis server to obtain the uploaded file from the preset path of the file server, the method further includes:
[0032] Receive and save the execution frequency input by the administrator user;
[0033] The controlling the code analysis server to obtain the uploaded file from a preset path of the file server includes:
[0034] The code analysis server is controlled to obtain the uploaded file from a preset path of the file server at the execution frequency.
[0035] In a second aspect, an embodiment of the present invention provides a code file processing device, including:
[0036] A key generation module is used to generate the public key and private key corresponding to the target user;
[0037] A key storage module, used to store the public key in the code warehouse platform and store the private key in the code analysis server;
[0038] A request receiving module, used to receive a code pull request sent by the target user;
[0039] A file sending module, used to control the code warehouse platform to generate a code file corresponding to the code pull request, encrypt the code file using the public key, and send the encrypted code file to the code analysis server;
[0040] An instruction receiving module, used for receiving an analysis instruction for the encrypted code file;
[0041] The instruction response module is used to control the code analysis server to decrypt the encrypted code file according to the private key to respond to the analysis instruction.
[0042] Optionally, the file sending module is specifically used for:
[0043] Receive and save permission configuration information for the target user;
[0044] Determine, based on the permission configuration information, whether the target user has permission to pull the code file;
[0045] In response to the target user having permission to pull the code file, the step of controlling the code repository platform to generate a code file corresponding to the code pull request is performed.
[0046] Optionally, it also includes:
[0047] A log generation module, used to determine the user information of the target user and the file information of the code file;
[0048] Generate a code pull log record according to the user information and the file information.
[0049] Optionally, it also includes:
[0050] A controlled module, used for adding the target user to a controlled group;
[0051] Receiving an execution instruction for a target application sent by the target user; wherein the target application is deployed in the code warehouse platform or the code analysis server;
[0052] Determining whether the target application is a controlled application, and determining whether the target user is in a controlled group;
[0053] In response to the target application being a controlled application and the target user being in a controlled group, refusing to process the execution instruction.
[0054] Optionally, it also includes:
[0055] A file upload module, used to control the code analysis server to obtain an uploaded file from a preset path of the file server, and save the uploaded file in a local temporary path of the code analysis server;
[0056] Determine the uploading user corresponding to the uploaded file;
[0057] The uploaded file is moved to the user path corresponding to the uploading user, and the file owner of the uploaded file is changed to the uploading user.
[0058] In a third aspect, an embodiment of the present invention provides an electronic device, including:
[0059] one or more processors;
[0060] a storage device for storing one or more programs,
[0061] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.
[0062] In a fourth aspect, an embodiment of the present invention provides a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in any of the above embodiments.
[0063] In a fifth aspect, an embodiment of the present invention provides a computer program product, including a computer program, which implements the method described in any of the above embodiments when executed by a processor.
[0064] One embodiment of the above invention has the following advantages or beneficial effects: the public key and private key of the target user are stored in the code warehouse platform and the code analysis server, respectively. After receiving the code pull request sent by the target user, the code warehouse platform is controlled to generate a code file corresponding to the code pull request, the code file is encrypted using the public key, and the encrypted code file is sent to the code analysis server. The code analysis server uses the private key to decrypt the encrypted code file and respond to the analysis instruction. Therefore, the scheme of the embodiment of the present invention utilizes the public key and private key of the target user to avoid directly exposing the plaintext of the code. After pulling the code file from the server, the risk of code leakage or external spread can be reduced.
[0065] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0067] Figure 1 It is a flowchart of a method for processing a code file provided by the first embodiment of the present invention;
[0068] Figure 2 is a flowchart of a code file processing method provided by the second embodiment of the present invention;
[0069] Figure 3 is a flowchart of a method for processing a code file provided by a third embodiment of the present invention;
[0070] Figure 4 is a flowchart of a method for managing user rights provided by a fourth embodiment of the present invention;
[0071] Figure 5 is a schematic diagram of the structure of a code file processing device provided by an embodiment of the present invention;
[0072] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0073] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0074] It should be noted that in the technical solution of the present invention, the collection, analysis, use, transmission, storage and other aspects of user personal information involved are in compliance with the provisions of relevant laws and regulations, are used for legal and reasonable purposes, are not shared, leaked or sold outside of these legal uses, and are subject to supervision and management by regulatory authorities. Necessary measures should be taken for user personal information to prevent illegal access to such personal information data, ensure that persons who have access to personal information data comply with the provisions of relevant laws and regulations, and ensure the security of user personal information. Once these user personal information data are no longer needed, the risks should be minimized by limiting or even prohibiting data collection and / or deleting data.
[0075] Figure 1 is a flowchart of a code file processing method provided by the first embodiment of the present invention, such as Figure 1 As shown, the method includes:
[0076] Step 101: Generate the public key and private key corresponding to the target user.
[0077] An asymmetric encryption algorithm may be used to generate a public key and a private key corresponding to the target user. A frequency may be preset to execute step 101 and step 102 cyclically. The preset frequency may be once a week, once a month, etc. Replacing the public key and the private key corresponding to the user at a preset frequency can reduce the risk of code leakage due to key decryption.
[0078] Step 102: Save the public key in the code warehouse platform, and save the private key in the code analysis server.
[0079] The public key can be directly saved in the code warehouse platform. The public key can also be encrypted and saved in the code warehouse platform. The private key can be directly saved in the code analysis server. The private key can also be encrypted and saved in the code analysis server.
[0080] Step 103: Receive a code pull request sent by a target user.
[0081] Step 104: Control the code warehouse platform to generate a code file corresponding to the code pull request, encrypt the code file using the public key, and send the encrypted code file to the code analysis server.
[0082] Send the encrypted code file to the code analysis server to avoid directly exposing the plain text of the code and further ensure the security of the code.
[0083] Step 105: Receive an analysis instruction for the encrypted code file.
[0084] Step 106: Control the code analysis server to decrypt the encrypted code file according to the private key to respond to the analysis instruction.
[0085] The decrypted code file is analyzed and processed corresponding to the analysis instruction to respond to the analysis instruction. After responding to the analysis instruction, the decrypted code file is deleted, that is, the plain text of the code file is not stored in the code analysis server.
[0086] In the scheme of the embodiment of the present invention, the public key and private key of the target user are respectively stored in the code warehouse platform and the code analysis server. After receiving the code pull request sent by the target user, the code warehouse platform is controlled to generate a code file corresponding to the code pull request, the code file is encrypted using the public key, and the encrypted code file is sent to the code analysis server. The code analysis server decrypts the encrypted code file according to the private key and responds to the analysis instruction. Therefore, by using the public key and private key of the target user, direct exposure of the plaintext code is avoided. After the code file is pulled from the server, the risk of code leakage or external diffusion can be reduced.
[0087] In one embodiment of the present invention, before controlling the code warehouse platform to generate a code file corresponding to a code pull request, it also includes: receiving and saving permission configuration information for a target user; controlling the code warehouse platform to generate a code file corresponding to a code pull request, including: determining whether the target user has permission to pull the code file according to the permission configuration information; in response to the target user having permission to pull the code file, executing the step of controlling the code warehouse platform to generate a code file corresponding to the code pull request. The administrator can set different permissions for different users as needed. Before a user pulls a code file, verifying the user's permissions can further prevent the code from being leaked or spread.
[0088] In one embodiment of the present invention, after sending the encrypted code file to the code analysis server, it also includes: determining the user information of the target user and the file information of the code file; generating a code pull log record based on the user information and the file information. An account, public key and private key are independently set for each user. Based on the user's account, a code pull log record is generated to ensure that the code pull behavior is traceable and auditable.
[0089] Figure 2is a flowchart of a code file processing method provided by the first embodiment of the present invention, such as Figure 2 As shown, the method includes:
[0090] Step 201: Generate a public key and a private key corresponding to a target user.
[0091] Step 202: Save the public key in the code warehouse platform, and save the private key in the code analysis server.
[0092] Step 203: Receive a code pull request sent by a target user.
[0093] Step 204: Control the code repository platform to generate a code file corresponding to the code pull request, encrypt the code file using the public key, and send the encrypted code file to the code analysis server.
[0094] Step 205: Receive an analysis instruction for the encrypted code file.
[0095] Step 206: Control the code analysis server to decrypt the encrypted code file according to the private key to respond to the analysis instruction.
[0096] Step 207: Add the target user to the controlled group.
[0097] The system has administrator groups and controlled groups. Users in the controlled group cannot execute controlled applications.
[0098] Step 208: Receive an execution instruction for a target application sent by a target user; wherein the target application is deployed in a code warehouse platform or a code analysis server.
[0099] Step 209: Determine whether the target application is a controlled application, and determine whether the target user is in a controlled group.
[0100] Controlled applications are applications that can be used for batch download or dissemination of code. Controlled applications can be all applications involving file transfer, remote copy, file synchronization, storage device mounting, network communication, etc.
[0101] Step 210: In response to the target application being a controlled application and the target user being in a controlled group, refusing to process the execution instruction.
[0102] In the solution of the embodiment of the present invention, the user who performs code pulling is added to the controlled group. Through the controlled group, the user who performs code pulling cannot execute the controlled application. After pulling the code file, the ordinary user of the server can no longer download or spread the code on the server hard disk to the external terminal or server in batches.
[0103] In one embodiment of the present invention, it also includes: controlling the code analysis server to obtain the uploaded file from the preset path of the file server, and saving the uploaded file in the local temporary path of the code analysis server; determining the uploading user corresponding to the uploaded file; moving the uploaded file to the user path corresponding to the uploading user, and changing the file owner of the uploaded file to the uploading user. In the above manner, the file can be uploaded to the code analysis server, so that the code analysis server can be used to analyze and process the uploaded file.
[0104] Before the uploaded file is saved in the local temporary path of the code analysis server, the method further includes: scanning the uploaded file in the code analysis server; in response to the scanning result indicating that the uploaded file is a safe file, executing the step of saving the uploaded file in the local temporary path of the code analysis server. By scanning the uploaded file, it is ensured that the safe file is saved in the code analysis server, and it is avoided that the uploaded file carries a Trojan virus, etc., which may cause adverse effects on the code analysis server.
[0105] In one embodiment of the present invention, before controlling the code analysis server to obtain the uploaded file from the preset path of the file server, it also includes: receiving and saving the execution frequency input by the administrator user; controlling the code analysis server to obtain the uploaded file from the preset path of the file server, including: controlling the code analysis server to obtain the uploaded file from the preset path of the file server at the execution frequency. The execution frequency can be set as needed, such as once every 5 minutes, once every half an hour, or once a day. Controlling the code analysis server to obtain the uploaded file from the preset path of the file server at the execution frequency reduces the excessive resource consumption of the code analysis server while ensuring that the uploaded file can be synchronized to the code analysis server on time.
[0106] The embodiment of the present invention also provides a code file processing system, which can realize that after the code is securely pulled to the server hard disk, the controlled user can upload the analysis script, and can ensure that the code can only be accessed on the code analysis server hard disk, and cannot be downloaded in batches or spread to the outside. The solution of the embodiment of the present invention uses a relatively low cost to achieve code security protection, and allows users to upload files or scripts for code analysis. There is no need to purchase external software or applications, and there is no subsequent maintenance cost. The system includes four modules, which are summarized as follows:
[0107] Code Pull Module: Generate SSH (Secure Shell) public and private keys based on the RSA (asymmetric encryption) algorithm in the ordinary user of the code analysis server. The code warehouse administrator account creates an ordinary code warehouse login account and adds the public key of the ordinary user of the code analysis server to the ordinary account of the code warehouse. According to the principle of minimizing permissions, the code warehouse administrator account adds code warehouse read-only permissions to the code warehouse alternative account. At this time, after the ordinary user of the code analysis server logs in, he can communicate with the code warehouse platform and pull code through the SSH protocol based on RSA algorithm authentication. The process of pulling code is completely anonymous and there is no plain text communication. It ensures that the user permissions of the code warehouse to pull code are highly controlled and the code warehouse platform login account is completely confidential.
[0108] Ordinary users can log in to the code analysis server, but cannot log in to the code warehouse platform. Through the code warehouse platform, the code pull account information can be identified based on the public key information to ensure that the code pull behavior is traceable and auditable. In a multi-user scenario, set up an independent account for each user and set it up as above.
[0109] Server user permission module: In the code analysis server account system, administrator groups and controlled groups are established. Ordinary users used to pull code are excluded from the administrator group and added to the controlled group. Through this design, a hierarchical basis for user permissions on the server is established to ensure that while retaining all permissions of administrator users, the permissions of ordinary users can be restricted. When different users want to pull or analyze code, they are individually assigned an account under a controlled group, and the login passwords of different users are kept separately.
[0110] File transfer management module: Use code analysis server administrators to set permissions for all executable files on the server involving file transfer, remote copy, file synchronization, storage device mounting, network communication, etc., to ensure that these files are only accessible and executable by the administrator group, and that controlled groups cannot access and execute such files. After the module is set up, the possibility of ordinary users of the server downloading or spreading the code on the server hard disk in batches can be blocked.
[0111] File upload module: Set up another server dedicated to uploading files, referred to as the file server. The file server opens a specific directory for ordinary users of the code pull server to upload files. The code pull server opens a specific directory for controlled users to obtain files. The administrator of the code pull server sets up a scheduled synchronization task to regularly transfer the files in the specific directory opened by the file server to the directory opened by the code pull server for ordinary users. After the transfer is completed, the permissions and owners of the synchronized files are changed to ordinary users. The following actions are all executed regularly through customized scripts without manual intervention. The scheduled execution interval can be set according to actual needs. This module ensures that ordinary users can upload files and scripts required for code analysis on the code pull server.
[0112] Figure 3 FIG. 1 is a flow chart of a method for processing a code file provided by the third embodiment of the present invention. Figure 3 As shown, the method includes:
[0113] Step 01: In the Code Warehouse platform, use the administrator user to create a common user: code_user_A. The password of this common user to log in to the Code Warehouse platform is kept confidential to users other than the Code Warehouse platform administrator.
[0114] Step 02: In the code analysis server, the administrator creates a common user: server_user_A. Generates a key pair for the common user based on the RSA algorithm. Sends the public key in the key pair to the administrator of the code warehouse platform.
[0115] Step 03: After the administrator of the code warehouse platform receives the public key of the user server_user_A sent by the code analysis server, he adds the public key to the common user code_user_A of the code warehouse platform.
[0116] Step 04: The administrator of the code warehouse platform adds read-only permissions for the corresponding code projects to code_user_A according to business needs. At this time, server_user_A can pull the relevant code projects that the code warehouse administrator allows to access to the code analysis server with read-only permissions without a password. The code warehouse platform records logs for code pull behaviors and traces the code pull history through log audits.
[0117] Figure 4 is a flow chart of a method for managing user rights provided by a fourth embodiment of the present invention, such as Figure 4 As shown, the method includes:
[0118] Step 11: The administrator of the code analysis server creates an administrator group and a controlled group respectively. Add the user server_user_A used to perform code analysis to the controlled group, and the administrator group should exclude the user server_user_A.
[0119] Step 12: File Analysis The server administrator restricts permissions for commands related to file transfer, remote copy, file synchronization, storage device mounting, and open network ports. Users in the administrator group are allowed to read and execute these commands, while users in the controlled group are prohibited from reading and executing these commands. Users who are not in the controlled group cannot transfer or distribute code files from the server through controlled commands or channels.
[0120] Step 13: After the user in the controlled group logs in to the file analysis server, he can use the key to pull the code to the file analysis server based on encrypted communication. At this time, the user can no longer transmit or lose the code to the outside.
[0121] The embodiment of the present invention also provides a method for uploading a file, which comprises the following steps:
[0122] Step 21: For server_user_A on the file analysis server, the administrator on the file server creates a corresponding user upload_user_A to enable server_user_A to upload files.
[0123] Step 22: Enable the ftp service or sftp service on the file server, and use a unified format for the storage path of user-uploaded files on the file server. For example, the storage path for uploaded files of ordinary user upload_user_A can be: / home / upload_user_A / upload.
[0124] Step 23: Write a script on the file analysis server and use the administrator user to execute the script. Regularly synchronize the contents of the preset directory under the path of the file server's unified format to the local directory of the file analysis server, and use the administrator's privileges to adjust the owner of the received files to server_user_A. The script is executed with administrator privileges throughout the process.
[0125] For scenarios where multiple users' files need to be synchronized, the preset directory can be passed into the script as a parameter by the server login user name. The script can be executed regularly to achieve the file synchronization function. At this point, on the file analysis server, different users upload files through the file server and synchronize them to the file analysis server.
[0126] Step 24: On the file analysis server, server_user_A can use the uploaded synchronized files or scripts to implement the code analysis function.
[0127] According to the solution of the embodiment of the present invention, different users can pull code from the code warehouse server to the hard disk of the code analysis server under the premise of complete isolation of permissions, but can no longer transmit the code from the hard disk of the code analysis server to the outside, spread the code, or modify the source code of the code warehouse platform. In the case of restricted file transfer permissions, custom files or scripts can still be synchronized to the code analysis server for code analysis, but files cannot be downloaded. At a very low cost, the code on the hard disk of the code analysis server can be used for multiple users on the server to access and analyze each other under the premise of permission isolation, and the code security can be guaranteed to avoid the risk of code copying and spreading to the outside.
[0128] Figure 5 is a schematic diagram of a code file processing device provided by an embodiment of the present invention. Figure 5 As shown, the device comprises:
[0129] The key generation module 501 is used to generate the public key and private key corresponding to the target user;
[0130] The key storage module 502 is used to store the public key in the code warehouse platform and store the private key in the code analysis server;
[0131] A request receiving module 503 is used to receive a code pull request sent by a target user;
[0132] The file sending module 504 is used to control the code warehouse platform to generate a code file corresponding to the code pull request, encrypt the code file using the public key, and send the encrypted code file to the code analysis server;
[0133] The instruction receiving module 505 is used to receive the analysis instruction for the encrypted code file;
[0134] The instruction response module 506 is used to control the code analysis server to decrypt the encrypted code file according to the private key to respond to the analysis instruction.
[0135] Optionally, the file sending module 504 is specifically used for:
[0136] Receive and save permission configuration information for target users;
[0137] According to the permission configuration information, determine whether the target user has the permission to pull the code file;
[0138] In response to the target user having permission to pull the code file, a step of controlling the code repository platform to generate a code file corresponding to the code pull request is executed.
[0139] Optionally, it also includes:
[0140] A log generation module, used to determine the user information of the target user and the file information of the code file;
[0141] Generate code pull log records based on user information and file information.
[0142] Optionally, it also includes:
[0143] A controlled module is used to add target users to a controlled group;
[0144] Receiving an execution instruction for a target application sent by a target user; wherein the target application is deployed in a code warehouse platform or a code analysis server;
[0145] Determining whether the target application is a controlled application, and determining whether the target user is in a controlled group;
[0146] In response to the target application being a controlled application and the target user being in a controlled group, the execution instruction is refused to be processed.
[0147] Optionally, it also includes:
[0148] The file upload module is used to control the code analysis server to obtain the uploaded file from the preset path of the file server and save the uploaded file in the local temporary path of the code analysis server;
[0149] Determine the uploading user corresponding to the uploaded file;
[0150] Move the uploaded file to the user path corresponding to the uploading user, and change the file owner of the uploaded file to the uploading user.
[0151] Optionally, the file upload module is also used to:
[0152] Scan and process the uploaded files in the code analysis server;
[0153] In response to the scanning result indicating that the uploaded file is a safe file, a step of saving the uploaded file in a local temporary path of the code analysis server is performed.
[0154] Optionally, the file upload module is also used to:
[0155] Receive and save the execution frequency input by the administrator user;
[0156] The control code analysis server obtains the uploaded file from the preset path of the file server, including:
[0157] Control the code analysis server to execute frequency and get the uploaded files from the preset path of the file server.
[0158] An embodiment of the present invention provides an electronic device, including:
[0159] one or more processors;
[0160] a storage device for storing one or more programs,
[0161] When one or more programs are executed by one or more processors, the one or more processors implement the method of any of the above embodiments.
[0162] An embodiment of the present invention provides a computer program product, including a computer program. When the computer program is executed by a processor, the computer program implements the code file processing method in the embodiment of the present invention.
[0163] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0164] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0165] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, 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, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0166] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0167] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0168] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0169] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be arranged in a processor, for example, they may be described as: a key generation module, a key storage module, a request receiving module, a file sending module, an instruction receiving module, and an instruction response module. The names of these modules do not constitute limitations on the modules themselves in certain circumstances, for example, the key generation module may also be described as a "module for generating public and private keys corresponding to the target user".
[0170] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0171] Generate the public key and private key corresponding to the target user;
[0172] The public key is stored in the code warehouse platform, and the private key is stored in the code analysis server;
[0173] Receive a code pull request sent by the target user;
[0174] Control the code warehouse platform to generate a code file corresponding to the code pull request, encrypt the code file using the public key, and send the encrypted code file to the code analysis server;
[0175] Receiving an analysis instruction for the encrypted code file;
[0176] The code analysis server is controlled to decrypt the encrypted code file according to the private key to respond to the analysis instruction.
[0177] According to the technical solution of the embodiment of the present invention, the public key and private key of the target user are respectively stored in the code warehouse platform and the code analysis server. After receiving the code pull request sent by the target user, the code warehouse platform is controlled to generate a code file corresponding to the code pull request, the code file is encrypted using the public key, and the encrypted code file is sent to the code analysis server. The code analysis server decrypts the encrypted code file according to the private key and responds to the analysis instruction. Therefore, the public key and private key of the target user are used to avoid direct exposure of the plaintext code. After the code file is pulled from the server, the risk of code leakage or external diffusion can be reduced.
[0178] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for processing a code file, characterized in that: include: Generate the public key and private key corresponding to the target user at a preset frequency; The public key is stored in the code warehouse platform, and the private key is stored in the code analysis server; Receive a code pull request sent by the target user; Control the code warehouse platform to generate a code file corresponding to the code pull request, encrypt the code file using the public key, and send the encrypted code file to the code analysis server; Receiving an analysis instruction for the encrypted code file; Controlling the code analysis server to decrypt the encrypted code file according to the private key to respond to the analysis instruction; The controlling the code analysis server to decrypt the encrypted code file according to the private key in response to the analysis instruction further includes: deleting the decrypted code file.
2. The method according to claim 1, characterized in that Before controlling the code warehouse platform to generate a code file corresponding to the code pull request, the method further includes: Receive and save permission configuration information for the target user; The controlling the code warehouse platform to generate a code file corresponding to the code pull request includes: Determine, based on the permission configuration information, whether the target user has permission to pull the code file; In response to the target user having permission to pull the code file, the step of controlling the code repository platform to generate a code file corresponding to the code pull request is performed.
3. The method according to claim 1, characterized in that After sending the encrypted code file to the code analysis server, the method further includes: Determine the user information of the target user and the file information of the code file; Generate a code pull log record according to the user information and the file information.
4. The method according to claim 1, characterized in that After receiving the code pull request sent by the target user, the method further includes: Adding the target user to a controlled group; Receiving an execution instruction for a target application sent by the target user; wherein the target application is deployed in the code warehouse platform or the code analysis server; Determining whether the target application is a controlled application, and determining whether the target user is in a controlled group; In response to the target application being a controlled application and the target user being in a controlled group, refusing to process the execution instruction.
5. The method according to claim 1, characterized in that Also includes: Control the code analysis server to obtain an uploaded file from a preset path of a file server, and save the uploaded file in a local temporary path of the code analysis server; Determine the uploading user corresponding to the uploaded file; The uploaded file is moved to the user path corresponding to the uploading user, and the file owner of the uploaded file is changed to the uploading user.
6. The method according to claim 5, characterized in that The step of saving the uploaded file in a local temporary path of the code analysis server includes: Scanning the uploaded file in the code analysis server; In response to the scanning result indicating that the uploaded file is a safe file, the step of saving the uploaded file in a local temporary path of the code analysis server is performed.
7. The method according to claim 5, characterized in that Before controlling the code analysis server to obtain the uploaded file from the preset path of the file server, the method further includes: Receive and save the execution frequency input by the administrator user; The controlling the code analysis server to obtain the uploaded file from a preset path of the file server includes: The code analysis server is controlled to obtain the uploaded file from a preset path of the file server at the execution frequency.
8. A code file processing device, characterized in that: include: A key generation module, used to generate the public key and private key corresponding to the target user at a preset frequency; A key storage module, used to store the public key in the code warehouse platform and the private key in the code analysis server; A request receiving module, used to receive a code pull request sent by the target user; A file sending module, used to control the code warehouse platform to generate a code file corresponding to the code pull request, encrypt the code file using the public key, and send the encrypted code file to the code analysis server; An instruction receiving module, used for receiving an analysis instruction for the encrypted code file; An instruction response module, used to control the code analysis server to decrypt the encrypted code file according to the private key to respond to the analysis instruction; The instruction response module is also used to delete the decrypted code file.
9. The device according to claim 8, characterized in that The file sending module is specifically used for: Receive and save permission configuration information for the target user; Determine, based on the permission configuration information, whether the target user has permission to pull the code file; In response to the target user having permission to pull the code file, the step of controlling the code repository platform to generate a code file corresponding to the code pull request is performed.
10. The device according to claim 8, characterized in that Also includes: A log generation module, used to determine the user information of the target user and the file information of the code file; Generate a code pull log record according to the user information and the file information.
11. The device according to claim 8, characterized in that Also includes: A controlled module, used for adding the target user to a controlled group; Receiving an execution instruction for a target application sent by the target user; wherein the target application is deployed in the code warehouse platform or the code analysis server; Determining whether the target application is a controlled application, and determining whether the target user is in a controlled group; In response to the target application being a controlled application and the target user being in a controlled group, refusing to process the execution instruction.
12. The device according to claim 8, characterized in that Also includes: A file upload module, used to control the code analysis server to obtain an uploaded file from a preset path of the file server, and save the uploaded file in a local temporary path of the code analysis server; Determine the uploading user corresponding to the uploaded file; The uploaded file is moved to the user path corresponding to the uploading user, and the file owner of the uploaded file is changed to the uploading user.
13. An electronic device, characterized in that: include: one or more processors; a storage device for storing 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 according to any one of claims 1 to 7.
14. A computer readable medium having a computer program stored thereon, characterized in that When the program is executed by a processor, the method described in any one of claims 1 to 7 is implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
