Code tracing method, electronic equipment, storage medium and program product
By implanting encrypted traceability information when compiling the program package and decrypting it when needed, the problem of unreliable traceability information in the production environment is solved, efficient and accurate traceability information acquisition is achieved, and information security is ensured.
Patent Information
- Application Number
- CN202410756292.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-11-08
AI Technical Summary
In a production environment, developers are unable to record the traceability information of the program package in a timely manner, resulting in poor reliability when querying traceability information in the integrated system, and they cannot accurately obtain detailed information such as compiler information, compilation time and code branches.
By automatically implanting encrypted traceability information when compiling the package and using decryption components to decrypt when it is necessary to obtain traceability information of the target package, including compiler information, compilation time and code branches.
It realizes code traceability with high traceability accuracy and high efficiency, ensures the reliability and confidentiality of the traceability information of the program package, and avoids the risk of information leakage.
Smart Images

Figure CN118916033A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a code tracing method, electronic equipment, storage medium and program product. Background Art
[0002] When using an application, if an application fails, it is necessary to trace the source of the application package to determine the source information of the package. The source information may include version information, compiler information, compilation time, etc.
[0003] In the related art, an integrated system can be maintained, and the traceability information of each program package can be recorded in the integrated system. When the program package needs to be traced, the traceability information of the program package can be queried in the integrated system. In the actual application process, when encountering an urgent problem in the production environment and needing to update the program package, the developer may not be able to record the traceability information of the program package in the integrated system in time, making it impossible for the integrated system to record comprehensive traceability information of all program packages. In this way, when querying the traceability information of the program package in the integrated system, the traceability information of the program package may not exist in the integrated system, making it impossible to query the traceability information of the program package in the integrated system, resulting in poor reliability of querying the traceability information. Summary of the invention
[0004] The embodiments of the present application provide a code tracing method, an electronic device, a storage medium, and a program product to achieve high tracing accuracy and high efficiency.
[0005] In a first aspect, an embodiment of the present application provides a code tracing method, comprising:
[0006] Obtain a traceability request, which is used to request traceability of a target package;
[0007] According to the tracing request, a target program package is obtained, where the target program package is obtained by compiling the target source code, and the target program package includes encrypted tracing information, where the encrypted tracing information is added to the target program package when the target source code is compiled;
[0008] Identify and obtain encrypted traceability information in the target program package;
[0009] The traceability information of the target program package is determined according to the encrypted traceability information, where the traceability information includes at least one of the following: compiler information, compilation time, code branch, or identifier of the code repository to which the target program package is submitted.
[0010] In a possible implementation, identifying and obtaining encrypted traceability information in a target program package includes:
[0011] Identify multiple files in a target package;
[0012] According to the file type of each file in the multiple files, a target file is determined in the multiple files, and the file type of the target file is a preset type;
[0013] Determine the encrypted provenance information in the target file.
[0014] In a possible implementation, the method is applied to an electronic device, wherein the electronic device includes a decryption component; determining the traceability information of a target program package according to the encrypted traceability information includes:
[0015] Get the decryption key;
[0016] According to the decryption key, the encrypted traceability information is decrypted by the decryption component to obtain the traceability information; wherein the decryption component is independently deployed in the internal network of the developer organization.
[0017] In a possible implementation, the method further includes:
[0018] During the compilation process of the target source code, obtaining compilation environment information for compiling the target source code;
[0019] Performing text recognition processing on the compilation environment information to determine the traceability information in the compilation environment information;
[0020] Determine a preset encryption key, and encrypt the traceability information using the preset encryption key to obtain encrypted traceability information;
[0021] An initial program package after compiling the target source code is determined, and a target program package is obtained based on the encrypted traceability information and the initial program package.
[0022] In a possible implementation, performing text recognition processing on the compilation environment information to determine the traceability information in the compilation environment information includes:
[0023] Determine multiple preset fields;
[0024] According to the plurality of preset fields, the compilation environment information is identified and processed to determine a field value corresponding to each preset field in the compilation environment information;
[0025] According to a plurality of preset fields and a field value corresponding to each preset field, traceability information is generated, and the traceability information includes a plurality of preset fields and a field value corresponding to each preset field.
[0026] In a possible implementation, the initial program package includes multiple file packages; and a target program package is obtained according to the encrypted traceability information and the initial program package, including:
[0027] Performing a hash operation on each file package through a hash algorithm to obtain first fingerprint information of each file package;
[0028] The encrypted tracing information and the first fingerprint information corresponding to each file package are respectively added to the initial program package to obtain the target program package.
[0029] In a possible implementation manner, the target program package further includes a plurality of file packages and first fingerprint information of each file package; and the method further includes:
[0030] receiving a start request corresponding to a target program package;
[0031] According to the start request, obtaining first fingerprint information of each file package in the target program package;
[0032] Performing a hash operation on each file package through hash distribution to obtain second fingerprint information of each file package;
[0033] Get the traceability information in the target package;
[0034] Determine a verification result of the target program package according to the first fingerprint information of each file package, the second fingerprint information of each file package, and the traceability information, where the verification result is verification passed or verification failed;
[0035] If the verification result is passed, the target package is started.
[0036] In a possible implementation, determining the verification result of the target program package according to the first fingerprint information of each file package, the second fingerprint information of each file package, and the traceability information includes:
[0037] Determine a fingerprint verification result according to the first fingerprint information of each file package and the second fingerprint information of each file package;
[0038] Determine the code modification status of the target program package according to the traceability information, where the code modification status is used to indicate whether there is any uncommitted modified code in the target program package;
[0039] If the fingerprint verification result is verification passed, and the code modification status indicates that there is no uncommitted modification code in the target program package, then the verification result is determined to be verification passed;
[0040] If the fingerprint verification result is verification failure, or the code modification status indicates that there is unsubmitted modified code in the target program package, then the verification result is determined to be verification failure.
[0041] In a possible implementation, determining a fingerprint verification result according to the first fingerprint information of each file package and the second fingerprint information of each file package includes:
[0042] For any file package, determine whether the first fingerprint information of the file package and the second fingerprint information of the file package are the same, if yes, determine that the file package status of the file package is a verification passed status, if not, determine that the file package status of the file package is a verification failed status;
[0043] If the file package statuses of the multiple file packages are respectively in the verification passed status, then the fingerprint verification result is determined to be the verification passed;
[0044] If the file package status of a file package among the multiple file packages is in a verification failure status, it is determined that the fingerprint verification result is verification failure.
[0045] In a possible implementation, determining the code modification status of the target program package according to the traceability information includes:
[0046] Obtain code modification indicators in traceability information;
[0047] If the code modification indicator is a first value, determining that the code modification status indicates that uncommitted modified code exists in the target program package;
[0048] If the code modification indicator is the second value, it is determined that the code modification status indicates that there is no uncommitted modified code in the target package.
[0049] In a second aspect, an embodiment of the present application provides a code tracing device, including:
[0050] A traceability request acquisition module is used to obtain a traceability request, and the traceability request is used to request to trace the target program package;
[0051] A target program package acquisition module is used to acquire a target program package according to a traceability request. The target program package is obtained by compiling a target source code. The target program package includes encrypted traceability information. The encrypted traceability information is added to the target program package when the target source code is compiled.
[0052] An identification module, used to identify and obtain encrypted traceability information in a target program package;
[0053] The determination module is used to determine the traceability information of the target program package according to the encrypted traceability information, where the traceability information includes at least one of the following: compiler information, compilation time, code branch, or identifier of the code repository to which the target program package is submitted.
[0054] In a third aspect, an embodiment of the present application provides a code tracing device, including: a memory, a processor;
[0055] The memory stores computer-executable instructions;
[0056] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.
[0057] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.
[0058] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.
[0059] The code tracing method, electronic device, storage medium and program product provided in the embodiments of the present application can determine the traceability information of the target program package by identifying and decrypting the encrypted traceability information in the program package after obtaining the traceability request, and can instantly and accurately obtain the compiler information, compilation time, code branch, or identification of the code repository submitted to the target program package, thereby achieving high traceability accuracy and high efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0061] Figure 1 A flowchart of a code tracing method provided in one embodiment of the present application;
[0062] Figure 2 A flowchart of a code tracing method provided in one embodiment of the present application;
[0063] Figure 3 A flowchart of a code tracing method provided in one embodiment of the present application;
[0064] Figure 4 A flowchart of a code tracing method provided in one embodiment of the present application;
[0065] Figure 5 A flowchart of a code tracing method provided in one embodiment of the present application;
[0066] Figure 6 A flowchart of a code tracing method provided in one embodiment of the present application;
[0067] Figure 7 A flowchart of a code tracing method provided in one embodiment of the present application;
[0068] Figure 8 A flowchart of a code tracing method provided in one embodiment of the present application;
[0069] Fig. 9 A flowchart of a code tracing method provided in one embodiment of the present application;
[0070] Fig.10 A flowchart of a code tracing method provided in one embodiment of the present application;
[0071] Fig.11 A schematic diagram of the structure of the code tracing device provided by this application;
[0072] Fig.12 A schematic diagram of the structure of the code tracing device provided for this application.
[0073] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0074] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0075] In the current application system delivery practice, there is a problem that the relationship between the actual delivered and deployed packages and the source code is difficult to manage. For customized development, this problem is particularly prominent when there are multiple project branch versions of the same basic project. To address this problem, the existing technical solutions mainly use the following means to manage versions, and all of them have disadvantages to varying degrees:
[0076] 1. Introduce a continuous integration system, and through institutionalized management and other methods, stipulate that the delivered packages can only be obtained from the continuous integration system. Rely on the continuous integration system to manage the generated package products. However, although the package products generated by the continuous integration system are managed in a unified manner, for larger projects, the generation efficiency of the continuous integration system is low and not flexible enough. When encountering urgent problems in the production environment and needing to update the package, in practice, the continuous integration system is often skipped, and the developer directly generates the package for replacement, which makes it difficult to manage.
[0077] 2. Use containerization technology to make the program package into an executable program image and manage it through the image name and label. When using containerization technology, similar situations also exist. When encountering urgent problems that need to be dealt with, there is a practice of skipping the image creation step and directly replacing the program package in the container.
[0078] 3. In the compilation process, use open source tools to add the version information of the current source code to the generated program package. This solution can solve the problem of version association between the program package and the source code to a certain extent. However, the existing open source tools (represented by the git-commit-id-plugin plug-in) only contain limited information. If the developer directly generates the program package, and there are code modifications that have not been submitted during generation, such plug-ins can only record "modifications" without recording the details of the modifications, such as additions, deletions, and modified file lists. The inventor speculates that in order to avoid leakage of source code information, overly detailed information is deliberately avoided.
[0079] Combining the above scenarios, it can be seen that in the existing technology, the management method through continuous integration system or containerization technology has the problem of human skipping, which leads to poor traceability reliability, while the method of implanting source code information has the technical problem of insufficient information recording or poor confidentiality.
[0080] The code tracing method provided in the present application solves the technical problems of poor reliability or poor confidentiality of querying traceability information in the prior art by automatically embedding encrypted traceability information in the program package when compiling the program package and decrypting the encrypted traceability information when tracing is needed.
[0081] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0082] Figure 1 Schematic diagram of the code tracing method provided for this application Figure 1 ,like Figure 1 As shown, the method includes:
[0083] S101. Obtain a traceability request, where the traceability request is used to request traceability of a target program package.
[0084] Among them, the traceability request can refer to a request initiated by the user to trace the target package according to actual needs. Specifically, the package is generated by the source code through a process such as compilation and packaging. In this process, the source code is converted into a form that the computer can understand and organized into executable files or library files. The package is usually associated with a specific version of the source code. The package may contain a copy of the source code or a link to the source code repository.
[0085] Exemplarily, tracing the source of the target program package may refer to querying in a code repository to obtain source code corresponding to the target program package, or may refer to obtaining version information, modification history, and other related tracing information of the target program package.
[0086] S102. Obtain a target program package according to a tracing request. The target program package is obtained by compiling a target source code. The target program package includes encrypted tracing information. The encrypted tracing information is added to the target program package when the target source code is compiled.
[0087] Among them, encrypted traceability information may refer to traceability information obtained through encryption algorithm processing. When the traceability information is encrypted traceability information, its content cannot be read directly and needs to be restored to the original traceability information through the corresponding decryption algorithm before the details of the traceability information can be known.
[0088] Specifically, the encrypted traceability information records the traceability information such as the version information and modification information of the source code, which is added to the program package when the program package and the source code are compiled. For example, a compilation plug-in can be used to capture the current compilation environment information as the traceability information during each compilation.
[0089] In a specific example, the captured information may include one or more of the following:
[0090] GIT repository information: the code branch name corresponding to the currently compiled code, the most recent commit ID, etc.;
[0091] Author information: GIT user name, email address and other information configured in the current compilation environment;
[0092] GIT repository status details: whether there are any differences between the currently compiled code and the code repository, and the details of the differences, including the file names and status of all changes.
[0093] S103: Identify and obtain encrypted traceability information in the target program package.
[0094] The encrypted traceability information is processed by the compiled plug-in and stored in the program package in the form of a specific file, which can be identified. Figure 2As shown, identifying and obtaining encrypted traceability information in a target program package may include the following sub-steps:
[0095] S201. Determine a plurality of files in a target program package.
[0096] Specifically, the program package may include data information such as multiple different types of files, which are used to record different information, including encrypted traceability information. Exemplarily, the encrypted traceability information is stored separately in a file, distinguished from other information data.
[0097] S202: Determine a target file from among the multiple files according to the file type of each file in the multiple files, where the file type of the target file is a preset type.
[0098] Specifically, the program package may include multiple different file types, each used to store different data information. Among them, the target file may be a file storing encrypted traceability information, and the target file is determined to obtain the encrypted traceability information. For the target file, the file types of multiple files can be traversed to obtain a file that meets the preset file type as the target file.
[0099] In an exemplary embodiment, the encrypted traceability information is stored in the git.properties file. Typically, git.properties can be a text file that contains property information related to the Git version control system, such as the version, commit ID, build time, etc. of the Git project. This file type is usually regarded as an ordinary text file (textfile), and its content can be viewed and edited through a text editor or command line tool. At this point, the target file can be determined by searching for a file with a preset type of git.properties.
[0100] S203: Determine the encrypted traceability information in the target file.
[0101] For example, taking the target file as git.properties, which stores encrypted traceability information, for example, the encrypted traceability information is expressed as a ciphertext, that is, the specific information therein cannot be directly read.
[0102] S104. Determine the traceability information of the target program package according to the encrypted traceability information, where the traceability information includes at least one of the following: compiler information, compilation time, code branch, or identifier of the code repository to which the target program package is submitted.
[0103] Specifically, the traceability information of the target package can be determined by decrypting the encrypted traceability information, and the traceability information includes at least one of the following: compiler information, compilation time, code branch, or identifier of the code repository to which the target package is submitted.
[0104] In an exemplary embodiment, the code tracing method provided by the present application is applied to an electronic device, and the electronic device includes a decryption component. Figure 3 As shown, determining the traceability information of the target package according to the encrypted traceability information may include the following sub-steps:
[0105] S301, obtaining a decryption key.
[0106] The decryption key is used to decrypt the encrypted traceability information. Specifically, the encrypted traceability information can be encrypted by a specific encryption algorithm, which corresponds to a specific decryption key. The encrypted traceability information can be restored to the traceability information before encryption using the correct decryption key.
[0107] S302. Decrypt the encrypted traceability information through a decryption component according to the decryption key to obtain traceability information; wherein the decryption component is independently deployed in the internal network of the developer organization.
[0108] Specifically, corresponding to the encryption component, the encrypted traceability information can be decrypted using the decryption component according to the decryption key to obtain the traceability information. The decryption component can be a software or hardware component for decrypting data, and is used to restore the encrypted data to its original form for further processing or analysis.
[0109] In one of the embodiments, for user-friendliness, the decryption component can be presented in the form of a web page. Because the background program involves a decryption algorithm, the system can be independently deployed in the internal network of the developer organization. Exemplarily, the decryption component can be implemented using any programming language, such as the Python+Streamlit technology stack. Specifically, the user can paste the encrypted traceability information into the decryption component, and after being processed by the background program of the decryption component, the decrypted information can be obtained, such as the producer of the program package, the production time, the corresponding code library branch and submission id at the time of production, whether the local code has been modified in the code library, and if so, the specific modification list and other information.
[0110] A code tracing method provided in an embodiment of the present application determines the tracing information of a target program package by identifying and decrypting the encrypted tracing information in the program package after obtaining a tracing request. The method can instantly and accurately obtain the compiler information, compilation time, code branch, or identifier of the code repository to which the target program package is submitted, thereby achieving the effect of b008a3880dd97cd3c50b7456c4fbe94b.
[0111] In a possible implementation, Figure 4 As shown, a code tracing method provided in an embodiment of the present application may also include the following steps:
[0112] S401. During the compilation process of the target source code, the compilation environment information for compiling the target source code is obtained.
[0113] The target source code is the source code corresponding to the target package to be traced, and the target package is obtained by compiling the target source code and adding relevant information. Exemplarily, the source code can be compiled using the aforementioned compilation plug-in, or the compilation plug-in can be embedded in an existing compilation process. During each compilation, the compilation plug-in can obtain the compilation environment information for compiling the target source code.
[0114] S402: Perform text recognition processing on the compilation environment information to determine the traceability information in the compilation environment information.
[0115] The text recognition process may refer to the process of scanning the text in the document to identify and extract information. Specifically, the compilation environment information may include a variety of traceability information and non-traceability information. By performing text recognition on the compilation environment information and extracting information that meets specific conditions, the traceability information can be determined in the compilation environment information.
[0116] In a possible implementation, Figure 5 As shown, performing text recognition processing on the compilation environment information to determine the traceability information in the compilation environment information may include the following steps:
[0117] S501: Determine multiple preset fields.
[0118] The preset field may be a field corresponding to a certain traceability information in the traceability information. For example, the preset field may include git.branch, git.build.time, etc., which respectively represent the source code submission branch name and the compilation environment system time during compilation and other traceability information.
[0119] S502: Perform identification processing on the compilation environment information according to multiple preset fields to determine a field value corresponding to each preset field in the compilation environment information.
[0120] Among them, the field value can be the specific data information corresponding to the preset field, which is used to refer to the detailed information of the traceability information. For example, through the preset field git.branch, it can be identified that git.branch = master-dev, where master-dev is the field value corresponding to git.branch, indicating that the submission branch name of the source code is master-dev. Through the preset field git.build.time, it can be identified that git.build.time = 2024-04-23T23\:13\:34+0800, where git.build.time = 2024-04-23T23\:13\:34+0800 is the field value of git.build.time, indicating that the compilation environment system time during compilation is 23\:13\:34 on 2024-04-23.
[0121] S503. Generate traceability information according to multiple preset fields and field values corresponding to each preset field, where the traceability information includes multiple preset fields and field values corresponding to each preset field.
[0122] In an exemplary embodiment, according to multiple preset fields and the field value corresponding to each preset field, the traceability information is generated, and the traceability information includes multiple preset fields and the field value corresponding to each preset field. The traceability information as shown in the following example can be obtained: (wherein the information text is an excerpt, ... represents the content not displayed; the line starting with # is the comment information of the next line of information; not all compiled information is displayed)
[0123] #Branch name
[0124] git.branch=master-dev
[0125] #Compile environment system time
[0126] git.build.time=2024-04-23T23\:13\:34+0800
[0127] #Compile environment code repository submission id (short)
[0128] git.commit.id.abbrev=9fdcefa
[0129] #Compile environment code repository submission id (full)
[0130] #The user's email address for the most recent commit during compilation
[0131] git.commit.user.email=LY+ / tzpEL501NGcYk+ytI
[0132] #The username of the last commit during compilation
[0133] git.commit.user.name=5t7E+xDR / DCxKIiM…
[0134] git.commit.id.full=9fdcefad8abf7035f7688d320f93b549fe7c7dbf
[0135] #Is there a difference between the compilation environment code and the code repository
[0136] git.dirty=true
[0137] The compilation environment information is displayed in text form, and the traceability information can be determined in the compilation environment information by performing text recognition processing on the compilation environment information. For example, by performing text recognition processing on "git.build.time=2024-04-23T23\:13\:34+0800", the information "compilation environment system time at compile time" in the traceability information can be determined.
[0138] S403: Determine a preset encryption key, and encrypt the traceability information using the preset encryption key to obtain encrypted traceability information.
[0139] Specifically, information such as the compiler user's email address, the compiler user's name or alias, and the difference details between the compilation environment code and the code repository can be encrypted to prevent the package user from directly obtaining the above-mentioned traceability information and source code information, thereby preventing source code information from being leaked.
[0140] The encryption key can be a confidential value / algorithm defined and held by the developer, which is used to encrypt the data. For example, AES (Advanced Encryption Standard) can be used to encrypt the traceability information. AES is a symmetric encryption algorithm, and its encryption key and decryption key are the same. Exemplarily, encryption using AES can include the following steps:
[0141] 1. Generate a key: First, you need to generate an encryption key of appropriate length. AES supports multiple key lengths, such as 128 bits, 192 bits, and 256 bits.
[0142] 2. Encrypt data: Use the generated key to encrypt the data to be encrypted.
[0143] 3. Output ciphertext: The encrypted data is called ciphertext, which can be transmitted or stored in an insecure environment.
[0144] By determining the preset encryption key and using the above-mentioned AES encryption process, the information that needs to be kept confidential in the traceability information can be encrypted to obtain encrypted traceability information.
[0145] S404: Determine an initial program package after compiling the target source code, and obtain a target program package based on the encrypted traceability information and the initial program package.
[0146] After compiling the target source code, an initial program package can be obtained, which includes an executable file or library file compiled from the source code. Further, other information, such as traceability information, license and copyright, can be added to the initial program package to facilitate users to obtain relevant information.
[0147] Exemplarily, in the process of using the above-mentioned compilation plug-in to compile the source code and the program package, the compilation plug-in can further process the initial program package, and in the case of determining the initial program package after the target source code is compiled, and according to the encrypted traceability information and the initial program package, obtain the target program package. Specifically, the encrypted traceability information can be stored in a corresponding file, and the file can be packaged into the program package as part of the program package. Exemplarily, when the compilation plug-in is applied to the Java platform, the file of the encrypted traceability information can be packaged into a JAR package as part of the target program package.
[0148] The code tracing method provided in the embodiment of the present application, by using a compilation plug-in, automatically captures and encrypts the traceability information during the program package compilation process, packages the encrypted traceability information and adds it to the program package, ensures that the traceability information is added to the program package, achieves the effect of improving the traceability accuracy, and encrypts the information with high confidentiality requirements, reducing the risk of information leakage.
[0149] In a possible implementation, Figure 6 As shown, the initial program package includes multiple file packages; obtaining the target program package according to the encrypted traceability information and the initial program package may also include the following steps:
[0150] S601: Perform a hash operation on each file package using a hash algorithm to obtain first fingerprint information of each file package.
[0151] The fingerprint information of the program package may refer to a unique identifier generated by processing the program package or the file package in the program package. Exemplarily, the fingerprint information may be a hash value obtained after hash processing, or a hash value obtained by hashing. For example, MD5 (Message-Digest Algorithm 5) may be used to perform a hash operation on the program package or the file package to obtain the corresponding fingerprint information.
[0152] Specifically, the embodiment of the present application can use the aforementioned compilation plug-in to traverse the generated program package content, perform MD5 fingerprint calculation on each file package therein, and obtain fingerprint information corresponding to each file package as the first fingerprint information. The file package can be a JAR package.
[0153] S602: Add the encrypted tracing information and the first fingerprint information corresponding to each file package to the initial program package to obtain a target program package.
[0154] Specifically, for the initial program package obtained by compiling the source code, the encrypted traceability information and the first fingerprint information may be added therein to obtain the target program package.
[0155] To improve the traceability accuracy of the target package, a self-check can be performed when the target package is started to confirm that the current source code in the target package still matches the encrypted traceability information and fingerprint information added during compilation, that is, the target package has not been modified after the encrypted traceability information and fingerprint information are added.
[0156] In a possible implementation, the target program package further includes multiple file packages and first fingerprint information of each file package; Figure 7 As shown, the code tracing method provided in the embodiment of the present application may also include the following:
[0157] S701: Receive a startup request corresponding to a target program package.
[0158] Exemplarily, a self-check plug-in can be used to perform a self-check on a program package. Specifically, when the program package is started, the self-check plug-in accepts a start request of the target program package and enters a self-check program according to the start request. Furthermore, the self-check step can include self-check verification of traceability information and self-check verification of fingerprint information.
[0159] S702: Acquire first fingerprint information of each file package in the target program package according to the start request.
[0160] S703: Perform a hash operation on each file package through hash distribution to obtain second fingerprint information of each file package.
[0161] The fingerprint information can be verified by obtaining the current fingerprint information of the target package as the second fingerprint information, and extracting the first fingerprint information stored in the package for comparison to determine whether the current source code in the target package is modified from the source code corresponding to the first fingerprint information.
[0162] S704: Obtain traceability information in the target program package.
[0163] Specifically, the traceability information has been encrypted by compiling the plug-in and added to the target package. The self-check plug-in can obtain the encrypted traceability information in the target package by searching for a preset file type. For example, the self-check plug-in can also be configured with a corresponding decryption algorithm. For the traceability information that needs to be decrypted, the self-check plug-in can obtain it by decrypting the encrypted traceability information.
[0164] S705: Determine a verification result of the target program package according to the first fingerprint information of each file package, the second fingerprint information of each file package, and the traceability information, where the verification result is verification passed or verification failed.
[0165] Specifically, the self-check plug-in can perform a self-check on the target program package according to the first fingerprint information of each file package, the second fingerprint information of each file package and the traceability information to determine the verification result of the target program package, where the verification result is verification passed or verification failed.
[0166] In a possible implementation, Figure 8 As shown, determining the verification result of the target program package according to the first fingerprint information of each file package, the second fingerprint information of each file package, and the traceability information may include the following sub-steps:
[0167] S801. Determine a fingerprint verification result according to first fingerprint information of each file package and second fingerprint information of each file package.
[0168] For example, the self-check plug-in can be used to determine whether the first fingerprint information of the file package and the second fingerprint information of the file package are the same for any file package. If yes, the file package status of the file package is determined to be a verification passed status, and if not, the file package status of the file package is determined to be a verification failed status.
[0169] Further, if the file package status of the multiple file packages are respectively in the verification pass status, the fingerprint verification result is determined to be verification pass. If the file package status of the multiple file packages is in the verification fail status, the fingerprint verification result is determined to be verification fail.
[0170] S802: Determine the code modification status of the target program package according to the traceability information, where the code modification status is used to indicate whether there is any uncommitted modified code in the target program package.
[0171] Exemplarily, the code modification status of the target package can be determined by obtaining a code modification indicator in the traceability information. If the code modification indicator is a first value, it is determined that the code modification status indicates that there is uncommitted modified code in the target package; if the code modification indicator is a second value, it is determined that the code modification status indicates that there is no uncommitted modified code in the target package.
[0172] Among them, the code modification indicator can be git.dirty. Specifically, in Git, git.dirty usually refers to an internal status mark, which is used to indicate whether the status of the work area and index (i.e., the temporary storage area) is clean (clean) or has uncommitted changes (dirty). When there are uncommitted modifications in the work area or index, git.dirty will be set to true, indicating that the Git repository is in a "dirty" state, that is, there are modifications to the source code in the target package, and the modifications have not been submitted to the code repository. Correspondingly, the first value of the code modification indicator can be true, that is, when git.dirty=true, it means that there are uncommitted modified code in the target package. Exemplarily, the second value can be empty or other numerical values to represent that there are no uncommitted modified code in the target package.
[0173] S803: If the fingerprint verification result is verification passed, and the code modification status indicates that there is no uncommitted modification code in the target program package, then the verification result is determined to be verification passed.
[0174] Specifically, the self-check plug-in may be configured to determine that the verification result is verification passed when the fingerprint verification result is verification passed and the code modification status indicates that there is no uncommitted modified code in the target program package.
[0175] S804: If the fingerprint verification result is verification failure, or the code modification status indicates that there is unsubmitted modified code in the target program package, then the verification result is determined to be verification failure.
[0176] For target packages whose fingerprint verification results indicate that the verification failed, or whose code modification status indicates that there are unsubmitted modified codes in the target package, it can be determined that the self-test failed, and the target package will not be started. Furthermore, the file names that failed the self-test can also be output. For example, if there is a JAR package in the traceability information that contains git.dirty=true, that is, the compilation environment code is different from the code repository, then the file name of the JAR package is output to the console. If any fingerprint information does not match, or the file is not found, or there are new files, it is considered that the package has been modified, and the relevant file name is output to the console to facilitate relevant staff to check the package and files.
[0177] Optionally, you can also choose to continue starting the program according to the configuration of the deployment environment (determine whether it is a safe mode according to environment variables); or refuse to start and exit.
[0178] S706: If the verification result is passed, start the target program package.
[0179] When both the traceability information self-check verification and the fingerprint information self-check verification pass, the self-check plug-in determines to start the target package. If there is information that fails the verification, the target package will not be started to avoid deviations in subsequent traceability steps.
[0180] The code tracing method provided in the embodiment of the present application uses a self-check plug-in to perform a self-check on the program package when the program package is started, and uses the injected information to implement application self-integrity detection, so as to promptly confirm whether the deployed application has been modified.
[0181] In order to further explain the solution of the embodiment of the present application, a specific example is provided below. In a specific example, the code tracing method provided by the present application is executed by a compile plug-in, a self-check plug-in and a decryption plug-in.
[0182] Among them, the compilation plug-in contains two main functions:
[0183] a) JAR package information embedding (encryption).
[0184] b) Package fingerprint implantation.
[0185] The main process of compiling plug-ins is as follows Fig. 9 As shown, in the process of compiling the source code into the program component, the current compilation environment information is captured, encrypted and written into a file. The written file is included in the program component. In the process of packaging the program component into a deployable program package (i.e., the target program package), the generated program package is traversed, and the fingerprint information of each program component is calculated and recorded.
[0186] Specifically, step S01: inject source code information:
[0187] It is embedded into the existing compilation process through plug-ins. During each compilation, the current compilation environment information is captured. The captured information includes the following:
[0188] GIT repository information: the code branch name corresponding to the currently compiled code, the most recent commit ID, etc.;
[0189] Author information: GIT user name, email address and other information configured in the current compilation environment;
[0190] GIT repository status details: whether there are any differences between the currently compiled code and the code repository, and the details of the differences, including the file names and status of all changes.
[0191] The captured content is saved into files and packaged into JAR archives as part of the program components.
[0192] Sensitive parts of the captured content will be encrypted, including usernames, email addresses, file names that are different from those in the code base, status, and other details. (Any encryption algorithm can be used, such as the AES symmetric encryption algorithm)
[0193] For example, an actual generation case is as follows (encrypted information is excerpted, and lines starting with # are comments to explain the information):
[0194] #Branch name
[0195] git.branch=master-dev
[0196] #Compile environment system time
[0197] git.build.time=2024-04-23T23\:13\:34+0800
[0198] #Compile environment user email
[0199] git.build.user.email=LY+ / tzpEL501NGcYk+yt…
[0200] #Compilation environment user name
[0201] git.build.user.name=5t7E+xDR / DCxKIiM…
[0202] #Compile environment code repository submission id (short)
[0203] git.commit.id.abbrev=9fdcefa
[0204] #Compile environment code repository submission id (full)
[0205] git.commit.id.full=9fdcefad8abf7035f7688d320f93b549fe7c7dbf
[0206] #The user's email address for the most recent commit during compilation
[0207] git.commit.user.email=LY+ / tzpEL501NGcYk+ytI
[0208] #The username of the last commit during compilation
[0209] git.commit.user.name=5t7E+xDR / DCxKIiM…
[0210] #Details of the difference between compilation environment code and code repository
[0211] git.detail.diff=H2SYec9U1iBfPGMkhtKCXG8KfqqDovc6oSaAfQdijgqlcE2ZNk…
[0212] #Is there a difference between the compilation environment code and the code repository
[0213] git.dirty=true
[0214] In the above example, we can see that the user's email address, name, details of the difference between the compilation environment code and the code repository, etc. are stored in an encrypted form to avoid source code information leakage.
[0215] Step S02: inject fingerprint information.
[0216] By means of a plug-in, a post-processing step is added to the generated deployable package, the generated package content is traversed, and the fingerprint of each JAR package is calculated (any hash value algorithm can be used, MD5 is used as an example here). The calculated fingerprint information is stored in a file and attached to the package.
[0217] The self-check plug-in can also be called a program package self-check system, which is called in the program startup script and is used to perform self-check on the program package status when the program is started. It includes two steps, respectively checking the information generated in steps S01 and S02.
[0218] The main process of the self-check plug-in is as follows Fig.10 As shown, after the program starts the script, the program package self-check is performed, including S03: traversing the JAR package, calculating the fingerprint information, and comparing it with the recorded value; and S04: traversing the JAR package and screening the source code information contained therein. If the self-check passes, the program will continue to be started; if it fails automatically and in the safe mode, the startup script will be exited. If the self-check fails but is not in the safe mode, the program can also be started.
[0219] Specifically, step S03: verifying fingerprint information.
[0220] This step verifies the fingerprint information of the package. The hash value of the file can be calculated directly through Linux commands, so this step can be implemented using Linux Shell script programming. The verification script code logic is as follows:
[0221] 1. Read the stored fingerprint information file;
[0222] 2. Traverse each piece of data and separate the file name and fingerprint information;
[0223] 2.1 Search for the corresponding file name on disk, and if it exists, recalculate the fingerprint.
[0224] 2.2 Compare the calculated fingerprint with the stored fingerprint information to see if they are consistent.
[0225] 3. Traverse the program component files and check whether there are corresponding items in the fingerprint information file.
[0226] If any fingerprint information does not match, or the file is not found, or there are new files, the package is considered to be modified, the relevant file name is output to the console, and the self-test is determined to have failed.
[0227] Step S04: Verify the source code status.
[0228] This step can be performed simultaneously with S03. In this step, the JAR packages of all program components will be decompressed, and the source code information injected by S01 will be read. This step can be written in go language considering the cross-platform requirements. After reading the source code information, it is mainly determined whether it contains git.dirty=true, that is, whether there is a difference between the compilation environment code and the code repository. If so, the file name of the JAR package is output to the console. If there is a difference in any JAR package, the self-check fails.
[0229] Based on the results of S03 and S04, if the self-check fails, the self-check system will output the name of the file that caused the self-check to fail. Then, according to the configuration of the deployment environment (determine whether it is a safe mode according to the environment variables), you can choose to continue to start the program; or refuse to start and exit.
[0230] The decryption plug-in can also be called a source code information decryption system. Since the sensitive information in the JAR package is encrypted, when the problem needs to be investigated and the source code needs to be traced, the implanted information can be copied and handed over to the decryption system for decryption to obtain detailed source code traceability information. After copying all the implanted information content and pasting it into this component, you can get the decrypted information, including the producer of the JAR package, the production time, the corresponding code library branch and submission id, whether the local code has been modified from the code library, and if so, the specific modification list and other information.
[0231] For user-friendliness, this component is presented in the form of a web page. Because the background program involves decryption algorithms, the system needs to be independently deployed in the internal network of the developer organization. This component can be implemented using any programming language (here we take Python+Streamlit technology stack as an example).
[0232] After pasting the case in step S01 into the webpage of this component, the decrypted information can be obtained as follows (part of the data is sample data)
[0233] git.branch=master-dev
[0234] git.build.time=2024-04-23T23\:13\:34+0800
[0235] git.build.user.email=zhangsan@example.com
[0236] git.build.user.name=zhangsan
[0237] git.commit.id.abbrev=9fdcefa
[0238] git.commit.id.full=9fdcefad8abf7035f7688d320f93b549fe7c7dbf
[0239] git.commit.user.email=zhangsan@example.com
[0240] git.commit.user.name=zhangsan
[0241] git.detail.diff=MODIFY com / example / Main.java
[0242] git.dirty=true
[0243] From the above information, we can know that the JAR package was compiled by zhangsan on the evening of April 23, 2024, based on the master-dev branch, with a commit id of 9fdcefa. At the same time, the Main.java file was modified locally but not submitted to the code repository. This completes the source code traceability.
[0244] Fig.11 A schematic diagram of the structure of the code tracing device provided in this application, such as Fig.11As shown, the code tracing device 110 provided in this embodiment includes:
[0245] A traceability request acquisition module 1101 is used to acquire a traceability request, where the traceability request is used to request to trace the target program package;
[0246] The target program package acquisition module 1102 is used to acquire the target program package according to the tracing request. The target program package is obtained by compiling the target source code. The target program package includes encrypted tracing information. The encrypted tracing information is added to the target program package when the target source code is compiled.
[0247] An identification module 1103 is used to identify and obtain encrypted traceability information in a target program package;
[0248] The determination module 1104 is used to determine the traceability information of the target package according to the encrypted traceability information, where the traceability information includes at least one of the following: compiler information, compilation time, code branch, or identifier of the code repository to which the target package is submitted.
[0249] In a possible implementation, the identification module is further used for:
[0250] Identify multiple files in a target package;
[0251] According to the file type of each file in the multiple files, a target file is determined in the multiple files, and the file type of the target file is a preset type;
[0252] Determine the encrypted provenance information in the target file.
[0253] In a possible implementation, the method is applied to an electronic device, wherein the electronic device includes a decryption component; and the determination module is further used to:
[0254] Get the decryption key;
[0255] According to the decryption key, the encrypted traceability information is decrypted by the decryption component to obtain the traceability information; wherein the decryption component is independently deployed in the internal network of the developer organization.
[0256] In a possible implementation, the device further includes an encryption module, which is used to:
[0257] During the compilation process of the target source code, obtaining compilation environment information for compiling the target source code;
[0258] Performing text recognition processing on the compilation environment information to determine the traceability information in the compilation environment information;
[0259] Determine a preset encryption key, and encrypt the traceability information using the preset encryption key to obtain encrypted traceability information;
[0260] An initial program package after compiling the target source code is determined, and a target program package is obtained based on the encrypted traceability information and the initial program package.
[0261] In a possible implementation, the encryption module is further used for:
[0262] Determine multiple preset fields;
[0263] According to the plurality of preset fields, the compilation environment information is identified and processed to determine a field value corresponding to each preset field in the compilation environment information;
[0264] According to a plurality of preset fields and a field value corresponding to each preset field, traceability information is generated, and the traceability information includes a plurality of preset fields and a field value corresponding to each preset field.
[0265] In a possible implementation, the initial program package includes multiple file packages; the encryption module is further used for:
[0266] Performing a hash operation on each file package through a hash algorithm to obtain first fingerprint information of each file package;
[0267] The encrypted tracing information and the first fingerprint information corresponding to each file package are respectively added to the initial program package to obtain the target program package.
[0268] In a possible implementation, the target program package further includes a plurality of file packages and first fingerprint information of each file package; the device further includes a self-checking module for:
[0269] receiving a start request corresponding to a target program package;
[0270] According to the start request, obtaining first fingerprint information of each file package in the target program package;
[0271] Performing a hash operation on each file package through hash distribution to obtain second fingerprint information of each file package;
[0272] Get the traceability information in the target package;
[0273] Determine a verification result of the target program package according to the first fingerprint information of each file package, the second fingerprint information of each file package, and the traceability information, where the verification result is verification passed or verification failed;
[0274] If the verification result is passed, the target package is started.
[0275] In a possible implementation manner, the self-check module is further used to:
[0276] Determine a fingerprint verification result according to the first fingerprint information of each file package and the second fingerprint information of each file package;
[0277] Determine the code modification status of the target program package according to the traceability information, where the code modification status is used to indicate whether there is any uncommitted modified code in the target program package;
[0278] If the fingerprint verification result is verification passed, and the code modification status indicates that there is no uncommitted modification code in the target program package, then the verification result is determined to be verification passed;
[0279] If the fingerprint verification result is verification failure, or the code modification status indicates that there is unsubmitted modified code in the target program package, then the verification result is determined to be verification failure.
[0280] In a possible implementation manner, the self-check module is further used to:
[0281] For any file package, determine whether the first fingerprint information of the file package and the second fingerprint information of the file package are the same, if yes, determine that the file package status of the file package is a verification passed status, if not, determine that the file package status of the file package is a verification failed status;
[0282] If the file package statuses of the multiple file packages are respectively in the verification passed status, then the fingerprint verification result is determined to be the verification passed;
[0283] If the file package status of a file package among the multiple file packages is in a verification failure status, it is determined that the fingerprint verification result is verification failure.
[0284] In a possible implementation manner, the self-check module is further used to:
[0285] Obtain code modification indicators in traceability information;
[0286] If the code modification indicator is a first value, determining that the code modification status indicates that uncommitted modified code exists in the target program package;
[0287] If the code modification indicator is the second value, it is determined that the code modification status indicates that there is no uncommitted modified code in the target package.
[0288] The code tracing device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be described in detail here.
[0289] Fig.12 This is a schematic diagram of the structure of the code tracing device provided by this application. Fig.12As shown, the electronic device 120 provided in this embodiment includes: at least one processor 1201 and a memory 1202. Optionally, the device 120 also includes a communication component 1203. The processor 1201, the memory 1202 and the communication component 1203 are connected via a bus 1204.
[0290] In a specific implementation process, at least one processor 1201 executes the computer-executable instructions stored in the memory 1202, so that at least one processor 1201 executes the above method.
[0291] The specific implementation process of the processor 1201 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0292] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0293] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.
[0294] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0295] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0296] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.
[0297] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0298] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0299] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0300] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0301] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0302] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0303] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0304] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A code tracing method, characterized in that: include: Obtaining a tracing request, where the tracing request is used to request tracing of a target program package; According to the tracing request, the target program package is obtained by compiling the target source code, and the target program package includes encrypted tracing information, and the encrypted tracing information is added to the target program package when the target source code is compiled; Identifying and obtaining the encrypted traceability information in the target program package; According to the encrypted traceability information, the traceability information of the target program package is determined, and the traceability information includes at least one of the following: compiler information, compilation time, code branch, or identifier of the code repository to which the target program package is submitted.
2. The method according to claim 1, characterized in that The step of identifying and obtaining the encrypted traceability information in the target program package includes: determining a plurality of files in the target package; Determine a target file among the multiple files according to the file type of each file among the multiple files, wherein the file type of the target file is a preset type; The encrypted traceability information is determined in the target file.
3. The method according to claim 1 or 2, characterized in that: The method is applied to an electronic device, wherein the electronic device includes a decryption component; determining the tracing information of the target program package according to the encrypted tracing information includes: Get the decryption key; According to the decryption key, the encrypted traceability information is decrypted by the decryption component to obtain the traceability information; wherein the decryption component is independently deployed in the internal network of the developer organization.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: During the compilation process of the target source code, obtaining compilation environment information for compiling the target source code; Performing text recognition processing on the compilation environment information to determine the traceability information in the compilation environment information; Determine a preset encryption key, and encrypt the traceability information using the preset encryption key to obtain the encrypted traceability information; An initial program package after compiling the target source code is determined, and the target program package is obtained according to the encrypted tracing information and the initial program package.
5. The method according to claim 4, characterized in that The performing text recognition processing on the compilation environment information to determine the traceability information in the compilation environment information includes: Determine multiple preset fields; According to the plurality of preset fields, identification processing is performed on the compilation environment information to determine a field value corresponding to each preset field in the compilation environment information; The traceability information is generated according to the multiple preset fields and the field value corresponding to each preset field, and the traceability information includes the multiple preset fields and the field value corresponding to each preset field.
6. The method according to claim 4 or 5, characterized in that: The initial program package includes a plurality of file packages; the target program package is obtained according to the encrypted tracing information and the initial program package, including: Performing a hash operation on each file package through a hash algorithm to obtain first fingerprint information of each file package; The encrypted tracing information and the first fingerprint information corresponding to each file package are respectively added to the initial program package to obtain the target program package.
7. The method according to any one of claims 1 to 6, characterized in that: The target program package also includes a plurality of file packages and first fingerprint information of each file package; the method further includes: receiving a start request corresponding to the target program package; According to the startup request, obtaining first fingerprint information of each file package in the target program package; Performing a hash operation on each file package through hash distribution to obtain second fingerprint information of each file package; Acquiring the traceability information in the target program package; Determine a verification result of the target program package according to the first fingerprint information of each file package, the second fingerprint information of each file package and the traceability information, wherein the verification result is verification passed or verification failed; If the verification result is that the verification is passed, the target program package is started.
8. The method according to claim 7, characterized in that The step of determining the verification result of the target program package according to the first fingerprint information of each file package, the second fingerprint information of each file package, and the traceability information includes: Determine a fingerprint verification result according to the first fingerprint information of each file package and the second fingerprint information of each file package; Determining a code modification status of the target program package according to the traceability information, wherein the code modification status is used to indicate whether there is any uncommitted modified code in the target program package; If the fingerprint verification result is verification passed, and the code modification status indicates that there is no uncommitted modification code in the target program package, then determining that the verification result is verification passed; If the fingerprint verification result is verification failure, or the code modification status indicates that unsubmitted modified code exists in the target program package, then it is determined that the verification result is verification failure.
9. The method according to claim 8, characterized in that The step of determining the fingerprint verification result according to the first fingerprint information of each file package and the second fingerprint information of each file package includes: For any file package, determine whether the first fingerprint information of the file package and the second fingerprint information of the file package are the same; if so, determine that the file package status of the file package is a verification passed status; if not, determine that the file package status of the file package is a verification failed status; If the file package states of the multiple file packages are respectively in the verification passed state, determining the fingerprint verification result is verification passed; If the file package status of a file package among the multiple file packages is a verification failure status, it is determined that the fingerprint verification result is verification failure.
10. The method according to claim 8 or 9, characterized in that: The step of determining the code modification status of the target program package according to the tracing information includes: Obtaining a code modification indicator in the traceability information; If the code modification indicator is a first value, determining that the code modification status indicates that uncommitted modified code exists in the target program package; If the code modification indicator is a second value, determining that the code modification status indicates that there is no uncommitted modified code in the target package.
11. A code tracing device, characterized in that: include: A traceability request acquisition module, used to acquire a traceability request, wherein the traceability request is used to request to trace the target program package; A target program package acquisition module, used to acquire the target program package according to a tracing request, wherein the target program package is obtained by compiling a target source code, and the target program package includes encrypted tracing information, and the encrypted tracing information is added to the target program package when the target source code is compiled; An identification module, used for identifying and obtaining the encrypted traceability information in the target program package; A determination module is used to determine the traceability information of the target program package based on the encrypted traceability information, wherein the traceability information includes at least one of the following: compiler information, compilation time, code branch, or identifier of the code repository to which the target program package is submitted.
12. A code tracing device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 10 when executed by a processor.
14. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
