Decryption method and device based on gradle plug-in, equipment, medium and product
By decrypting the Maven repository password during the Gradle build configuration phase, the problem of password leakage caused by plaintext storage in project configuration is solved, thus enhancing the system's security.
Patent Information
- Application Number
- CN202511381565.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2025-12-16
AI Technical Summary
In existing technologies, the username and password for the Maven repository address in the project configuration are stored in plaintext, which increases the risk of password leakage.
During the configuration phase of the Gradle build, the encrypted Maven repository password is decrypted through a decryption logic function, and the required dependencies are pulled during the configuration phase.
This enhances system security, prevents the leakage of Maven repository passwords, and improves system security.
Smart Images

Figure CN121145239A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of software development technology, and in particular to a decryption method, apparatus, device, medium and product based on Gradle plugin. Background Technology
[0002] In traditional software development, many tasks need to be performed manually, such as code compilation, application packaging, and dependency installation. These repetitive tasks consume a significant amount of developers' time and energy. Therefore, efforts have been made to develop efficient, automated project build tools.
[0003] As a current project automation build tool, Gradle is used for project lifecycle phases such as compilation, testing, packaging, and deployment. Gradle is often used to manage the entire lifecycle of an application from development to release, providing a series of controls and usage templates to tightly integrate different lifecycle phases.
[0004] When using Gradle to build a project, in existing project configurations, the username and password are stored in plaintext in the code when configuring the Maven repository address. This exposed plaintext format increases the risk of external attackers obtaining the plaintext, leading to password leakage. Summary of the Invention
[0005] This invention provides a decryption method, apparatus, device, medium, and product based on a Gradle plugin to solve the problem of password leakage caused by storing the username password in plaintext in the code when configuring the Maven repository address in existing project configurations.
[0006] According to one aspect of the present invention, a decryption method based on a Gradle plugin is provided, comprising:
[0007] During the configuration phase of the Gradle build, the encrypted Maven repository password is decrypted according to the decryption logic function;
[0008] Pull the required dependencies from the Maven repository using the decrypted Maven repository password.
[0009] According to another aspect of the present invention, a decryption device based on a Gradle plugin is provided, comprising:
[0010] The decryption module is used during the configuration phase of the Gradle build to decrypt the encrypted Maven repository password according to the decryption logic function;
[0011] The pull module is used to pull the required dependencies from the Maven repository based on the decrypted Maven repository password.
[0012] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: at least one processor;
[0013] and a memory communicatively connected to the at least one processor;
[0014] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the decryption method based on the Gradle plugin as described in any embodiment of the present invention.
[0015] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the decryption method based on the Gradle plugin as described in any embodiment of the present invention.
[0016] According to another aspect of the present invention, a computer program product is provided, the computer program product comprising a computer program that, when executed by a processor, implements the decryption method based on the Gradle plugin as described in any embodiment of the present invention.
[0017] The technical solution of this invention supports storing Maven repository passwords in encrypted form. During the configuration phase of the Gradle build, the encrypted Maven repository password is decrypted to obtain the plaintext password. This solves the problem of password leakage caused by storing username passwords in plaintext in the code, and achieves the beneficial effect of enhancing system security.
[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating a decryption method based on a Gradle plugin provided in Embodiment 1 of the present invention;
[0021] Figure 2 This is a flowchart of Gradle construction provided in Embodiment 1 of the present invention;
[0022] Figure 3 A schematic diagram illustrating the calling logic of the configuration phase of Gradle build according to an embodiment of the present invention;
[0023] Figure 4 This is a flowchart illustrating a decryption method based on a Gradle plugin provided in Embodiment 2 of the present invention;
[0024] Figure 5 This is a schematic diagram of a decryption device based on a Gradle plugin provided in Embodiment 3 of the present invention;
[0025] Figure 6 This is a schematic diagram of the structure of an electronic device based on a decryption method using a Gradle plugin, according to an embodiment of the present invention. Detailed Implementation
[0026] To enable those skilled in the art to better understand the present invention, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention. It should be understood that the various steps described in the method embodiments of the present invention can be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.
[0027] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0028] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0029] It should be noted that the terms "a" and "a plurality of" used in this invention are illustrative rather than restrictive. Those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0030] The names of the messages or information exchanged between the multiple devices in the embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of these messages or information.
[0031] Example 1
[0032] Figure 1 This is a flowchart illustrating a decryption method based on a Gradle plugin provided in Embodiment 1 of the present invention. This method is applicable to situations where required dependencies are obtained during automated project building. This method can be executed by a decryption device based on a Gradle plugin, wherein the device can be implemented by software and / or hardware and is generally integrated on an electronic device. In this embodiment, the electronic device includes, but is not limited to, a computer device.
[0033] like Figure 1 As shown, Embodiment 1 of the present invention provides a decryption method based on a Gradle plugin, comprising the following steps:
[0034] S110. During the configuration phase of the Gradle build, the encrypted password of the Maven repository is decrypted according to the decryption logic function.
[0035] Gradle is an open-source automated build tool that manages the development lifecycle of software projects through customizable build scripts and plugins, and tightly integrates tasks at each stage using a rich plugin ecosystem.
[0036] This involves using Gradle's custom plugin functionality to customize the application programming interface (API), and configuring the decryption logic within that API.
[0037] In this case, the username and password for the Maven repository are encrypted using an encryption function before being stored in the code. In other words, after encryption, the username and password are stored in the code as ciphertext.
[0038] In this embodiment, during the Gradle build configuration phase, the encrypted username and password can be decrypted using a decryption logic function. Decryption is the reverse process of encryption; different encryption algorithms require corresponding decryption algorithms for decryption. No specific restrictions are placed on the encryption algorithm here.
[0039] S120. Pull the required dependencies from the Maven repository according to the decrypted Maven repository password.
[0040] In this embodiment, the Gradle build process includes three stages: initialization, configuration, and execution. During the configuration stage, the encrypted Maven repository password is decrypted, and the required dependencies are retrieved from the Maven repository based on the decrypted password.
[0041] Among them, the Maven repository can be a Maven repository. After decrypting the password of the third-party dependency library, the third-party dependency library can be unlocked with the password, and then the required dependencies can be pulled from the third-party dependency library to successfully automate the construction of project dependencies.
[0042] The required dependencies can be determined based on the task dependency graph, which is constructed during the configuration phase of the Gradle build.
[0043] Figure 2 The flowchart of Gradle construction provided in Embodiment 1 of the present invention is as follows: Figure 2 As shown, the Gradle build process includes an initialization phase, a configuration phase, and an execution phase. The initialization phase is tasked with creating the project hierarchy and creating a project instance for each project. The configuration phase is tasked with executing the build.gradle plugin for each project, completing the project configuration, creating tasks, constructing a task dependency graph, and obtaining the required dependencies. The execution phase is tasked with creating a directed acyclic graph (DAG) based on the required dependencies, assembling tasks based on the DAG, and executing the corresponding tasks by calling the task names.
[0044] This invention provides a decryption method based on a Gradle plugin. First, during the Gradle build configuration phase, the encrypted Maven repository password is decrypted using a decryption logic function. Then, the required dependencies are retrieved from the Maven repository using the decrypted password. This method supports storing the Maven repository password in ciphertext and decrypting it during the Gradle build configuration phase to obtain the plaintext password, thus preventing password leakage and enhancing system security.
[0045] Based on the above embodiments, modified embodiments of the above embodiments are proposed. It should be noted that, in order to keep the description brief, only the differences from the above embodiments are described in the modified embodiments.
[0046] In one embodiment, the password for the encrypted Maven repository is automatically encrypted by the software development platform after obtaining the Maven repository password through the code generation function.
[0047] In this scenario, the password for the third-party dependency library can be the username and password entered by the user on the front-end visual page. After obtaining the username and password, the software development platform can use its code generation capabilities to generate a `build.gradle` file using code templates and custom dynamic code. The generated `build.gradle` file stores the encrypted username and password. In one embodiment, the decryption logic function is configured by a custom Gradle plugin.
[0048] The configuration phase of the Gradle build process executes the configuration code in the build script, creates tasks for each project, and configures the dependencies and properties between tasks. Therefore, the necessary dependencies can be determined completely based on the dependencies between tasks during the configuration phase of the Gradle build process.
[0049] Figure 3 This is a schematic diagram illustrating the calling logic of the configuration phase of a Gradle build according to an embodiment of the present invention, as shown below. Figure 3 As shown, after executing the build.gradle file, the password for the encrypted Maven repository is obtained, and the decryption logic is implemented through a custom plugin.
[0050] Furthermore, Gradle custom plugins are written in separate projects.
[0051] Among them, the Gradle plugin extension function can effectively organize our compilation logic code, enabling it to be reused in different projects and engineering projects, and decryption logic can be implemented through the Gradle custom plugin interface.
[0052] Custom plugins can be written in various ways. For reusability, they are written as separate projects, which are ultimately compiled into a single JAR file that can be reused across multiple projects and teams. This invention's plugin implementation relies heavily on Gradle's official core API for integration with the build lifecycle and task management, and provides crucial security capabilities based on the RSA asymmetric encryption algorithm. Together, these two elements constitute the core technological foundation for implementing the plugin's functionality.
[0053] The official documentation provides a custom application programming interface (API) that allows users to override application functions and define decryption logic within the API.
[0054] Furthermore, the decryption logic function is implemented by the security utility class of the Gradle custom plugin.
[0055] The decryption logic function can be implemented by the MavenSecurity utility class, which implements the relevant functions for encrypting and decrypting Maven repositories.
[0056] Example 2
[0057] Figure 4 This is a flowchart illustrating a decryption method based on a Gradle plugin, provided in Embodiment 2 of the present invention. Embodiment 2 is an optimization based on the aforementioned embodiments. For details not covered in this embodiment, please refer to Embodiment 1.
[0058] like Figure 4 As shown in Embodiment 2 of the present invention, a decryption method based on a Gradle plugin includes the following steps:
[0059] S210. During the configuration phase of the Gradle build, an asymmetric encryption algorithm is called through the decryption logic function.
[0060] The encryption and decryption algorithm uses the Rivest-Shamir-Adleman asymmetric encryption algorithm. The RSA algorithm has become the preferred tool for encrypting important data and protecting sensitive information due to its strong security, flexibility and simplicity of asymmetric keys, wide industry applicability, good platform compatibility, and the ability to publicly distribute public keys without secrecy. It can effectively protect multiple aspects of information security.
[0061] S220. Use the asymmetric encryption algorithm to decrypt the password of the encrypted Maven repository.
[0062] Among them, the Maven repository can be a Maven repository.
[0063] First, the Base64 encoded password of the Maven repository is converted into a PrivateKey object. Then, the PrivateKey object is used to decode the Base64 encoded password of the Maven repository into a plaintext key using the Cipher class in decryption mode.
[0064] In this case, the password for a Base64 encoded Maven repository is usually an encrypted AES key.
[0065] S230. Pull the required dependencies from the Maven repository according to the decrypted Maven repository password.
[0066] Embodiment 2 of this invention provides a decryption method based on a Gradle plugin, which specifies the process of decrypting the encrypted Maven repository password according to a decryption logic function. This method uses an asymmetric encryption algorithm to encrypt and decrypt the Maven repository password, thereby improving the security of the Maven repository password.
[0067] Example 3
[0068] Figure 5 This is a schematic diagram of a decryption device based on a Gradle plugin provided in Embodiment 3 of the present invention. The device is applicable to situations where required dependencies are obtained during automated project building. The device can be implemented by software and / or hardware and is generally integrated into an electronic device.
[0069] like Figure 5 As shown, the device includes a decryption module 110 and a retrieval module 120.
[0070] The decryption module 110 is used to decrypt the encrypted Maven repository password according to the decryption logic function during the configuration phase of the Gradle build.
[0071] Pull module 120 is used to pull the required dependencies from the Maven repository according to the decrypted Maven repository password.
[0072] In this embodiment, the device first decrypts the encrypted Maven repository password during the configuration phase of the Gradle build using the decryption module 110, according to the decryption logic function; then, it proceeds through the decryption module 120 to retrieve the required dependencies from the Maven repository based on the decrypted Maven repository password.
[0073] This embodiment provides a decryption device based on a Gradle plugin, which can enhance system security and prevent password leakage of Maven repositories.
[0074] Furthermore, the decryption logic function is configured by a custom Gradle plugin.
[0075] Furthermore, the decryption logic function is implemented by the security utility class of the Gradle custom plugin.
[0076] Based on the above optimizations, the Gradle custom plugin is written using a separate project approach.
[0077] Furthermore, the password for the encrypted Maven repository is automatically encrypted by the software development platform through the code generation function after obtaining the password for the Maven repository.
[0078] Based on the above optimization scheme, the decryption module includes:
[0079] The calling unit is used to invoke an asymmetric encryption algorithm through a decryption logic function;
[0080] The decryption unit is used to decrypt the password of the encrypted Maven repository using the asymmetric encryption algorithm.
[0081] The aforementioned decryption device based on the Gradle plugin can execute the decryption method based on the Gradle plugin provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0082] Example 4
[0083] Figure 6 A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0084] like Figure 6As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0085] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0086] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the decryption method based on the Gradle plugin.
[0087] In some embodiments, the Gradle plugin-based decryption method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the Gradle plugin-based decryption method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the Gradle plugin-based decryption method by any other suitable means (e.g., by means of firmware).
[0088] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0089] In some embodiments, the Gradle plugin-based decryption method can be implemented as a computer program, which is implicitly included in a computer program product. When executed by a processor, the computer program implements the Gradle plugin-based decryption method of the present invention. The computer program product can be understood as a software product that primarily implements its solution through a computer program. The computer program used to implement the method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer program causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The computer program can be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a standalone software package, or entirely on a remote machine or server.
[0090] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0091] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0092] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0093] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0094] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0095] 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 be made according to 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 decryption method based on a Gradle plugin, characterized in that, The method includes: During the configuration phase of the Gradle build, the encrypted Maven repository password is decrypted according to the decryption logic function; Pull the required dependencies from the Maven repository using the decrypted Maven repository password.
2. The method according to claim 1, characterized in that, The decryption logic function is configured by a custom Gradle plugin.
3. The method according to claim 1 or 2, characterized in that, The decryption logic function is implemented by the security utility class of the Gradle custom plugin.
4. The method according to claim 2, characterized in that, The custom Gradle plugin is written in a separate project.
5. The method according to claim 1, characterized in that, The password for the encrypted Maven repository is automatically encrypted by the software development platform after obtaining the Maven repository password through the code generation function.
6. The method according to claim 1 or 5, characterized in that, The process of decrypting the encrypted Maven repository password according to the decryption logic function includes: The asymmetric encryption algorithm is invoked through the decryption logic function; The asymmetric encryption algorithm described above is used to decrypt the password of the encrypted Maven repository.
7. A decryption device based on a Gradle plugin, characterized in that, The device includes: The decryption module is used during the configuration phase of the Gradle build to decrypt the encrypted Maven repository password according to the decryption logic function; The pull module is used to pull the required dependencies from the Maven repository based on the decrypted Maven repository password.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and a memory communicatively connected to the at least one processor; The memory stores a computer program that can be executed by the at least one processor, which is then executed by the at least one processor to enable the at least one processor to perform the decryption method based on the Gradle plugin as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the decryption method based on the Gradle plugin as described in any one of claims 1-6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the decryption method based on a Gradle plugin according to any one of claims 1-6.