A code protection method, device, equipment and medium
By adopting a code-level protection method, the problems of team collaboration barriers and poor readability caused by code protection in existing technologies are solved, thereby improving code security and management efficiency.
Patent Information
- Application Number
- CN202011002918.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-22
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2040-09-22
AI Technical Summary
Existing technologies for code protection suffer from challenges such as team collaboration barriers and poor code readability. Methods such as access control, code obfuscation, and watermarking cannot effectively guarantee code security and also affect management efficiency.
The code classification protection method is adopted. By obtaining the access request from the developer's terminal, the confidentiality level of the target code is determined, and the request is responded to according to the preset access policy corresponding to the confidentiality level, including whitelist binding, compilation and storage policies for different code repositories.
It effectively ensures code security, improves code management efficiency, guarantees code security and readability, and allows for reasonable team collaboration.
Smart Images

Figure CN112100581B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and in particular to a code protection method, device, equipment and medium. Background Art
[0002] Source code is the core asset of software companies and the foundation of software companies. Code protection is an issue that software development companies have always been concerned about. Source code protection technology basically adopts the following methods: permission control, code obfuscation, code hiding, and watermarking. Among them, the disadvantage of the principle of minimizing permission control is that it may cause obstacles to team collaboration and affect work efficiency, while the disadvantages of control methods such as code obfuscation, code hiding, and code watermarking are that they make the code poorly readable and can be restored through certain means. Summary of the invention
[0003] In view of this, the purpose of this application is to provide a code protection method, device, equipment and medium, which can effectively ensure the security of the code and improve the efficiency of code management. The specific scheme is as follows:
[0004] In a first aspect, the present application discloses a code protection method, comprising:
[0005] Get the code access request sent by the developer terminal;
[0006] Determining a confidentiality level of a target code corresponding to the code access request;
[0007] The code access request is responded to according to a preset access policy corresponding to the confidentiality level.
[0008] Optionally, determining the confidentiality level of the target code corresponding to the code access request includes:
[0009] Determine the target code repository where the target code corresponding to the code access request is located; wherein codes of different confidentiality levels are stored in different code repositories;
[0010] A confidentiality level of the object code is determined based on the object code repository.
[0011] Optionally, determining the confidentiality level of the target code based on the target code repository includes:
[0012] If the target code repository is a core code repository, determining that the confidentiality level of the target code is level one;
[0013] Accordingly, responding to the code access request according to the preset access policy corresponding to the confidentiality level includes:
[0014] Acquire developer account information and device information of the developer terminal from the access request;
[0015] Determine whether the developer account information and the device information exist in the first authorization whitelist of the core code repository;
[0016] If so, the target code is compiled to obtain a compilation package, and then the compilation package is transmitted to the integrated compilation server corresponding to the core code repository, and returning the corresponding target code to the developer terminal is prohibited.
[0017] Optionally, determining the confidentiality level of the target code corresponding to the code access request based on the target code repository includes:
[0018] If the target code repository is an authorized code repository, determining that the confidentiality level of the target code is level 2;
[0019] Accordingly, responding to the code access request according to the preset access policy corresponding to the confidentiality level includes:
[0020] Acquire developer account information and device information of the developer terminal from the access request;
[0021] Determine whether the developer account information and the device information are in the second authorization whitelist of the authorization code repository;
[0022] If so, the object code is allowed to be returned to the developer terminal.
[0023] Optionally, determining the confidentiality level of the target code corresponding to the code access request based on the target code repository includes:
[0024] If the target code repository is a common code repository, determining that the confidentiality level of the target code is level three;
[0025] Obtaining developer account information from the access request and determining an access operation corresponding to the access request; wherein the access operation includes a read operation and a write operation;
[0026] If the access operation is a read operation, determining whether the developer account information exists in the read authorization group of the common code repository, and if so, returning the target code to the developer terminal;
[0027] If the access operation is a write operation, it is determined whether the developer account information exists in the write authorization group of the common code repository. If so, the developer terminal is allowed to update the modified target code to the common code repository.
[0028] Optionally, the code protection method further includes:
[0029] The first authorization whitelist is created in advance, and the developer account information in the first authorization whitelist is bound to the device information.
[0030] In a second aspect, the present application discloses a code protection device, comprising:
[0031] A code access request acquisition module is used to acquire a code access request sent by a developer terminal;
[0032] A code confidentiality level determination module, used to determine the confidentiality level of the target code corresponding to the code access request;
[0033] The code access request response module is used to respond to the code access request according to a preset access policy corresponding to the confidentiality level.
[0034] Optionally, the code confidentiality level determination module specifically includes:
[0035] A target code repository determination submodule is used to determine the target code repository where the target code corresponding to the code access request is located; wherein codes of different confidentiality levels are stored in different code repositories;
[0036] The code confidentiality level determination submodule is used to determine the confidentiality level of the target code based on the target code repository.
[0037] In a third aspect, the present application discloses an electronic device, comprising:
[0038] Memory, used to store computer programs;
[0039] The processor is used to execute the computer program to implement the aforementioned code protection method.
[0040] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program, wherein the computer program implements the aforementioned code protection method when executed by a processor.
[0041] It can be seen that the present application first obtains the code access request sent by the developer terminal, then determines the confidentiality level of the target code corresponding to the code access request, and finally responds to the code access request according to the preset access policy corresponding to the confidentiality level. In other words, the present application performs hierarchical protection on the code, and responds to the code access request according to the access policy corresponding to the confidentiality level of the code, so that the security of the code can be effectively guaranteed and the efficiency of code management can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0043] Figure 1 A flow chart of a code protection method disclosed in this application;
[0044] Figure 2 This is a schematic diagram of the structure of a code protection device disclosed in this application;
[0045] Figure 3 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0046] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0047] Source code is the core asset of software companies and the foundation of software companies. Code protection is an issue that software development companies have always been concerned about. Source code protection technology basically adopts the following methods: permission control, code obfuscation, code hiding, and watermarking. Among them, the disadvantage of the principle of minimizing permission control is that it may cause obstacles to team collaboration and affect work efficiency, while the disadvantages of control methods such as code obfuscation, code hiding, and code watermarking are that they make the code poorly readable and can be restored through certain means.
[0048] See also Figure 1 As shown, the embodiment of the present application discloses a code protection method, including:
[0049] Step S11: Obtain a code access request sent by a developer terminal.
[0050] Step S12: Determine the confidentiality level of the target code corresponding to the code access request.
[0051] In a specific implementation, the target code repository where the target code corresponding to the code access request is located can be determined; wherein codes of different confidentiality levels are stored in different code repositories; and then the confidentiality level of the target code is determined based on the target code repository.
[0052] Step S13: responding to the code access request according to the preset access policy corresponding to the confidentiality level.
[0053] In a specific implementation, if the target code repository is a core code repository, the confidentiality level of the target code is determined to be level one; accordingly, the code access request is responded to according to the preset access policy corresponding to the confidentiality level, including: obtaining the developer account information and the device information of the developer terminal from the access request; determining whether the developer account information and the device information exist in the first authorization whitelist of the core code repository; if so, compiling the target code to obtain a compilation package, and then transmitting the compilation package to the integrated compilation server corresponding to the core code repository, and prohibiting the corresponding target code from being returned to the developer terminal. Specifically, the compilation package is transmitted to the integrated compilation server so that the integrated compilation server performs corresponding product updates based on the compilation package. It should be pointed out that the compilation package is a component or a plug-in, and the integrated compilation server can use the compilation package corresponding to the core code and the compilation package corresponding to other codes to perform product updates.
[0054] Specifically, this embodiment can create a core code warehouse rep1. For access requests to rep1, the visitor account information, IP, MAC address and other information are first obtained. If they do not exist in the rep1 authorization file, the access request is denied. After the user successfully logs in, the first-level code can be compiled locally on the code storage device, and the package is automatically transferred to the integrated compilation server after compilation. In addition, the integrated compilation server uniquely corresponds to the core code warehouse, and the core code warehouse and the integrated compilation server are bound through the warehouse's file transfer account and the integrated compilation server path, that is, the integrated environment requires pre-authentication.
[0055] In addition, this embodiment pre-creates the first authorization whitelist and binds the developer account information in the first authorization whitelist with the device information. That is, the developer account information and access device can be restricted, and only the specified developer account is allowed to access the core code repository on the specified device.
[0056] That is, the code with the highest confidentiality level, i.e., the first confidentiality level, can be stored in the core code repository. This part of the code is rarely changed, and the code development collaborators at this level can be controlled to 1-2 people, who can access it through a whitelist. The code storage device is locally compiled, the code is stored independently, and only fixed personnel have operation permissions.
[0057] In addition, the present embodiment can also generate a verification code corresponding to the compilation package, and back it up to obtain a backup verification code, and then transmit the target data packet including the compilation package and the verification code to the integrated compilation server, so that the integrated compilation server uses the verification code in the target data packet and the backup verification code to compare and verify, and updates the core component corresponding to the target code if the verification passes, wherein the verification code can be an md5 value.
[0058] If the target code repository is an authorized code repository, it is determined that the confidentiality level of the target code is level two; accordingly, the code access request is responded to according to the preset access policy corresponding to the confidentiality level, including: obtaining the developer account information and the device information of the developer terminal from the access request; determining whether the developer account information and the device information exist in the second authorization whitelist of the authorized code repository; if so, allowing the target code to be returned to the developer terminal.
[0059] That is, code with a higher confidentiality level, that is, confidentiality level 2, can be stored in the authorized code repository. Code at this level involves collaborative development by multiple people, so it is stored centrally. The code is stored in the authorized code repository. The authorized code repository is accessed through a whitelist, including account detection and hardware environment monitoring. Bind the account to its hardware environment. When the developer submits a copy application for the code to be copied, the requested code is automatically pulled to the application directory after the application is approved, and the copy range is within the authorized code repository. That is, the developer terminal can send a corresponding code access request and read the corresponding code. If the developer terminal modifies the read code, the modified code is sent to the authenticated integrated compilation server for compilation, that is, it is sent to the integrated compilation server that uniquely corresponds to the authorized code repository for compilation. The authentication of the integrated compilation server can refer to the relevant content disclosed above.
[0060] If the target code repository is a common code repository, determine that the confidentiality level of the target code is level three; obtain the developer account information from the access request and determine the access operation corresponding to the access request; wherein the access operation includes a read operation and a write operation; if the access operation is a read operation, determine whether the developer account information exists in the read authorization group of the common code repository, and if so, return the target code to the developer terminal; if the access operation is a write operation, determine whether the developer account information exists in the write authorization group of the common code repository, and if so, allow the developer terminal to update the modified target code to the common code repository.
[0061] That is, the code with a lower confidentiality level, i.e., the confidentiality level 3, can be stored in the general code warehouse. The code at this level involves collaborative development by multiple people, so it is stored centrally. And the code at this level is allowed to be copied by the authorized group through authorized access. The compilation and certification process can refer to the corresponding content of the aforementioned secondary code.
[0062] It should be pointed out that the code classification can be adjusted according to actual needs, that is, it is not limited to level one, level two, and level three, and more levels can be refined for hierarchical protection.
[0063] That is, the present application can pre-create a level classification table to divide the code into protection levels. Levels include but are not limited to level one, level two, and level three, which are stored in corresponding code repositories, and access policies are formulated for different code levels: Level one code, high technical confidentiality level, few changes. Adopt whitelist access, prohibit copying, local compilation, independent storage; Level two code, medium technical confidentiality level, adjusted with business. Adopt whitelist access, authorized copying, remote compilation, centralized storage; Level three code, low technical confidentiality level, adjusted with business. Adopt whitelist access, allow copying, remote compilation, centralized storage.
[0064] See also Figure 2 As shown, the embodiment of the present application discloses a code protection device, including:
[0065] A code access request acquisition module 11 is used to acquire a code access request sent by a developer terminal;
[0066] A code confidentiality level determination module 12, used to determine the confidentiality level of the target code corresponding to the code access request;
[0067] The code access request response module 13 is used to respond to the code access request according to a preset access policy corresponding to the confidentiality level.
[0068] It can be seen that the present application first obtains the code access request sent by the developer terminal, then determines the confidentiality level of the target code corresponding to the code access request, and finally responds to the code access request according to the preset access policy corresponding to the confidentiality level. In other words, the present application performs hierarchical protection on the code, and responds to the code access request according to the access policy corresponding to the confidentiality level of the code, so that the security of the code can be effectively guaranteed and the efficiency of code management can be improved.
[0069] The code confidentiality level determination module specifically includes:
[0070] A target code repository determination submodule is used to determine the target code repository where the target code corresponding to the code access request is located; wherein codes of different confidentiality levels are stored in different code repositories;
[0071] The code confidentiality level determination submodule is used to determine the confidentiality level of the target code based on the target code repository.
[0072] In a specific implementation, the code confidentiality level determination submodule is specifically used to determine that the confidentiality level of the target code is level one if the target code repository determination submodule determines that the target code repository is a core code repository; correspondingly, the code access request response module 13 is specifically used to obtain the developer account information and the device information of the developer terminal from the access request; determine whether the developer account information and the device information exist in the first authorization whitelist of the core code repository; if so, compile the target code to obtain a compilation package, and then transmit the compilation package to the integrated compilation server corresponding to the core code repository, and prohibit returning the corresponding target code to the developer terminal. If the target code repository determination submodule determines that the target code repository is an authorized code repository, the confidentiality level of the target code is determined to be level two; correspondingly, the code access request response module 13 is specifically used to obtain the developer account information and the device information of the developer terminal from the access request; determine whether the developer account information and the device information exist in the second authorization whitelist of the authorized code repository; if so, allow the target code to be returned to the developer terminal. If the target code repository determination submodule determines that the target code repository is a common code repository, the confidentiality level of the target code is determined to be level three; accordingly, the code access request response module 13 is specifically used to obtain the developer account information from the access request and determine the access operation corresponding to the access request; wherein the access operation includes a read operation and a write operation; if the access operation is a read operation, it is determined whether the developer account information exists in the read authorization group of the common code repository, and if so, the target code is returned to the developer terminal; if the access operation is a write operation, it is determined whether the developer account information exists in the write authorization group of the common code repository, and if so, the developer terminal is allowed to update the modified target code to the common code repository.
[0073] The apparatus further includes: a first authorization whitelist creation module, configured to pre-create the first authorization whitelist and bind the developer account information and device information in the first authorization whitelist.
[0074] See also Figure 3 As shown, an embodiment of the present application discloses an electronic device, including a processor 21 and a memory 22; wherein the memory 22 is used to store a computer program; and the processor 21 is used to execute the computer program to implement the code protection method disclosed in the aforementioned embodiment.
[0075] For the specific process of the above code protection method, reference may be made to the corresponding contents disclosed in the above embodiments, which will not be described in detail here.
[0076] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the code protection method disclosed in the aforementioned embodiment.
[0077] For the specific process of the above code protection method, reference may be made to the corresponding contents disclosed in the above embodiments, which will not be described in detail here.
[0078] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0079] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0080] The above is a detailed introduction to a code protection method, device, equipment and medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A code protection method, characterized in that: include: Get the code access request sent by the developer terminal; Determining a confidentiality level of a target code corresponding to the code access request; Responding to the code access request according to a preset access policy corresponding to the confidentiality level; Wherein, determining the confidentiality level of the target code corresponding to the code access request includes: Determine the target code repository where the target code corresponding to the code access request is located; wherein codes of different confidentiality levels are stored in different code repositories; Determining a confidentiality level of the target code based on the target code repository; Wherein, determining the confidentiality level of the target code based on the target code repository includes: If the target code repository is a core code repository, determining that the confidentiality level of the target code is level one; Accordingly, responding to the code access request according to the preset access policy corresponding to the confidentiality level includes: Acquire developer account information and device information of the developer terminal from the access request; Determine whether the developer account information and the device information exist in the first authorization whitelist of the core code repository; If yes, compile the target code to obtain a compilation package, then transmit the compilation package to the integrated compilation server corresponding to the core code repository, and prohibit returning the corresponding target code to the developer terminal; If the target code repository is an authorized code repository, determining that the confidentiality level of the target code is level 2; Accordingly, responding to the code access request according to the preset access policy corresponding to the confidentiality level includes: Acquire developer account information and device information of the developer terminal from the access request; Determine whether the developer account information and the device information are in the second authorization whitelist of the authorization code repository; If yes, allowing the object code to be returned to the developer terminal; If the target code repository is a common code repository, determining that the confidentiality level of the target code is level three; Obtaining developer account information from the access request and determining an access operation corresponding to the access request; wherein the access operation includes a read operation and a write operation; If the access operation is a read operation, determining whether the developer account information exists in the read authorization group of the common code repository, and if so, returning the target code to the developer terminal; If the access operation is a write operation, determining whether the developer account information exists in the write authorization group of the common code repository, and if so, allowing the developer terminal to update the modified target code to the common code repository; The step of transmitting the compilation package to the integrated compilation server corresponding to the core code repository includes: Generate a verification code corresponding to the compilation package, and back it up to obtain a backup verification code; transmit the target data packet including the compilation package and the verification code to the integrated compilation server, so that the integrated compilation server uses the verification code in the target data packet and the backup verification code to compare and verify, and if the verification passes, update the core component corresponding to the target code, wherein the verification code is an md5 value.
2. The code protection method according to claim 1, characterized in that: Also includes: The first authorization whitelist is created in advance, and the developer account information in the first authorization whitelist is bound to the device information.
3. A code protection device, characterized in that: include: A code access request acquisition module is used to acquire a code access request sent by a developer terminal; A code confidentiality level determination module, used to determine the confidentiality level of the target code corresponding to the code access request; A code access request response module, used to respond to the code access request according to a preset access policy corresponding to the confidentiality level; The code confidentiality level determination module specifically includes: A target code repository determination submodule is used to determine the target code repository where the target code corresponding to the code access request is located; wherein codes of different confidentiality levels are stored in different code repositories; A code confidentiality level determination submodule, used to determine the confidentiality level of the target code based on the target code repository; The code confidentiality level determination submodule specifically performs: if the target code repository is a core code repository, determining that the confidentiality level of the target code is level one; Accordingly, responding to the code access request according to the preset access policy corresponding to the confidentiality level includes: Acquire developer account information and device information of the developer terminal from the access request; Determine whether the developer account information and the device information exist in the first authorization whitelist of the core code repository; If yes, compile the target code to obtain a compilation package, then transmit the compilation package to the integrated compilation server corresponding to the core code repository, and prohibit returning the corresponding target code to the developer terminal; If the target code repository is an authorized code repository, determining that the confidentiality level of the target code is level 2; Accordingly, responding to the code access request according to the preset access policy corresponding to the confidentiality level includes: Acquire developer account information and device information of the developer terminal from the access request; Determine whether the developer account information and the device information are in the second authorization whitelist of the authorization code repository; If yes, allowing the object code to be returned to the developer terminal; If the target code repository is a common code repository, determining that the confidentiality level of the target code is level three; Obtaining developer account information from the access request and determining an access operation corresponding to the access request; wherein the access operation includes a read operation and a write operation; If the access operation is a read operation, determining whether the developer account information exists in the read authorization group of the common code repository, and if so, returning the target code to the developer terminal; If the access operation is a write operation, determining whether the developer account information exists in the write authorization group of the common code repository, and if so, allowing the developer terminal to update the modified target code to the common code repository; The step of transmitting the compilation package to the integrated compilation server corresponding to the core code repository includes: Generate a verification code corresponding to the compilation package, and back it up to obtain a backup verification code; transmit the target data packet including the compilation package and the verification code to the integrated compilation server, so that the integrated compilation server uses the verification code in the target data packet and the backup verification code to compare and verify, and if the verification passes, update the core component corresponding to the target code, wherein the verification code is an md5 value.
4. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the code protection method according to any one of claims 1 or 2.
5. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, implements the code protection method according to any one of claims 1 or 2.
Citation Information
Patent Citations
Secure privilege level execution and access protection
CN105431858A
Code management method and device
CN109815646A
Code compiling method and device for software development project, equipment and storage medium
CN110569035A
File permission control method and device, computer equipment and storage medium
CN110781507A
Code hosting and collaborating system
CN111475197A
