CN114780101A - Code processing method and device, computer equipment and storage medium - Google Patents

Code processing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN114780101A
CN114780101A CN202210377433.3A CN202210377433A CN114780101A CN 114780101 A CN114780101 A CN 114780101A CN 202210377433 A CN202210377433 A CN 202210377433A CN 114780101 A CN114780101 A CN 114780101A
Authority
CN
China
Prior art keywords
target
code
mode
modification
compiling
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210377433.3A
Other languages
Chinese (zh)
Inventor
张清华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202210377433.3A priority Critical patent/CN114780101A/en
Publication of CN114780101A publication Critical patent/CN114780101A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/604Tools and structures for managing or administering access control systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/21Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/2141Access rights, e.g. capability lists, access control lists, access tables, access matrices

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Bioethics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Automation & Control Theory (AREA)
  • Storage Device Security (AREA)

Abstract

The present disclosure provides a code processing method, apparatus, computer device and storage medium, wherein the method comprises: acquiring a code to be processed, and compiling the code to be processed according to a target compiling mode to obtain a code compiling result; identifying a code modification identifier in the code compiling result, and determining target modification data matched with the code modification identifier in the code compiling result; determining a target modification mode of the target modification data based on the target compilation mode, wherein the target modification mode is used for indicating an access right for modifying the target modification data; and modifying the access authority of the target modified data according to the target modification mode to obtain a modified code compiling result.

Description

Code processing method and device, computer equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a code processing method and apparatus, a computer device, and a storage medium.
Background
In the existing code development technology, a code developer can generally use codes developed by other code development teams and perform adjustment and improvement on the basis of the codes, so as to obtain codes meeting corresponding requirements. However, when the code used by the code developer is unstable or the code has corresponding defects, the misuse of the code may cause the system to crash. Therefore, a technical solution capable of hiding a defective or unstable code is needed to avoid system crash caused by misapplication of the code.
Disclosure of Invention
The embodiment of the disclosure at least provides a code processing method, a code processing device, computer equipment and a storage medium.
In a first aspect, an embodiment of the present disclosure provides a code processing method, where the method includes: acquiring a code to be processed, and compiling the code to be processed according to a target compiling mode to obtain a code compiling result; identifying a code modification identifier in the code compiling result, and determining target modification data matched with the code modification identifier in the code compiling result; determining a target modification mode of the target modification data based on the target compiling mode, wherein the target modification mode is used for indicating an access right for modifying the target modification data; and modifying the access authority of the target modified data according to the target modification mode to obtain a modified code compiling result.
With reference to the first aspect, an embodiment of the present disclosure provides a first possible implementation manner of the first aspect, where the determining that target modification data in the code compilation result matches the code modification identifier includes: determining byte codes matched with the code modification identifications in the code compiling result; determining the target modification data in the matched bytecode, wherein the target modification data includes at least one of: class to be modified, method to be modified, field to be modified.
With reference to the first aspect or the first possible implementation manner of the first aspect, an embodiment of the present disclosure provides a second possible implementation manner of the first aspect, where the modifying the access right of the target modification data according to the target modification mode to obtain a modified code compilation result includes: and under the condition that the target modification mode is a first modification mode, modifying the original access right of the target modification data into a first access right, wherein the first access right is used for indicating that the target modification data is hidden outwards, and the target compiling mode corresponding to the first modification mode is a compiling mode corresponding to a compiling stage of the SDK.
With reference to the second possible implementation manner of the first aspect, this disclosed embodiment provides a third possible implementation manner of the first aspect, where the modifying the access right of the target modification data to the first access right includes: determining a permission identifier in the target modification data; modifying the permission identifier to a first permission identifier, wherein the first permission identifier is an identifier corresponding to the first access permission.
With reference to the first aspect, an embodiment of the present disclosure provides a fourth possible implementation manner of the first aspect, where the target modification mode is a first compiling mode, and modifying the access right of the target modification data according to the target modification mode includes: acquiring original access authority of the target modified data before modification; and generating target identification information at the specified position of the target modification data based on the original access right, wherein the target identification information is used for indicating the original access right of the target modification data.
With reference to the fourth possible implementation manner of the first aspect, this disclosed embodiment provides a fifth possible implementation manner of the first aspect, where the modifying the access right of the target modification data according to the target modification mode to obtain a modified code compilation result includes: under the condition that the target modification mode is a second modification mode, acquiring target identification information in the target modification data; the target compiling mode corresponding to the second modification mode is a compiling mode corresponding to a compiling stage of the host; determining original access rights of the target modification data based on the target identification information; determining a permission identifier corresponding to the original access permission to obtain a second permission identifier; and modifying the authority identifier of the target modification data into a second authority identifier, wherein the second authority identifier is an identifier corresponding to the original access authority.
In a second aspect, an embodiment of the present disclosure further provides a code processing apparatus, including: the device comprises an acquisition unit, a compiling unit and a processing unit, wherein the acquisition unit is used for acquiring a code to be processed and compiling the code to be processed according to a target compiling mode to obtain a code compiling result; the identification unit is used for identifying a code modification identifier in the code compiling result and determining target modification data matched with the code modification identifier in the code compiling result; a determining unit, configured to determine a target modification mode of the target modification data based on the target compilation mode, where the target modification mode is used to indicate an access right to modify the target modification data; and the modifying unit is used for modifying the access authority of the target modified data according to the target modification mode to obtain a modified code compiling result.
In a third aspect, an embodiment of the present disclosure further provides a computer device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the computer device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect described above, or any possible implementation of the first aspect.
In a fourth aspect, the disclosed embodiments further provide a computer-readable storage medium, where a computer program is stored, and the computer program is executed by a processor to perform the steps in the first aspect or any one of the possible implementation manners of the first aspect.
According to the above description, the code to be processed may be obtained first, and the code to be processed may be compiled according to the target compiling mode to obtain the code compiling result. Thereafter, a code modification identifier may be identified in the code compilation result, and target modification data in the code compilation result that matches the code modification identifier may be determined. Therefore, the position of the target modification data can be better determined in the code compiling result through the code modification identifier, and the accuracy of the determined target modification data is further improved. Then, a target modification mode corresponding to the target modification data may be determined based on the target compiling mode, and the access right of the target modification data is modified according to the target modification mode, so as to obtain a modified code compiling result. Therefore, the code execution stability of the modified code compiling result can be ensured in the execution process, so that unstable codes or system crash caused by defective codes in the execution process can be avoided, and the code operation accuracy is improved. Meanwhile, the reuse rate of the codes to be processed can be improved, so that the development efficiency of the codes is improved.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required in the embodiments will be briefly described below, and the drawings herein incorporated in and forming a part of the specification illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the technical solutions of the present disclosure. It is appreciated that the following drawings depict only certain embodiments of the disclosure and are therefore not to be considered limiting of its scope, for those skilled in the art will be able to derive additional related drawings therefrom without the benefit of the inventive faculty.
FIG. 1 is a flow chart illustrating a method of code processing provided by an embodiment of the present disclosure;
FIG. 2 shows a flowchart of a method for modifying original access right of target modification data into a first access right according to an embodiment of the present disclosure;
fig. 3 is a flowchart illustrating a method for modifying access rights of target modification data according to a target modification mode in a case that the target modification mode is a first modification mode according to an embodiment of the present disclosure;
fig. 4 is a flowchart illustrating a method for modifying access rights of target modified data according to a target modification mode to obtain a modified code compilation result according to an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a code processing apparatus provided in an embodiment of the present disclosure;
fig. 6 shows a schematic diagram of a computer device provided by an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure, as generally described and illustrated in the figures herein, could be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure, presented in the figures, is not intended to limit the scope of the claimed disclosure, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making creative efforts, shall fall within the protection scope of the disclosure.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The term "and/or" herein merely describes an associative relationship, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
According to research, in the existing code development technology, a code developer can generally use codes developed by other code development teams and adjust and improve the codes on the basis of the codes, so that the codes meeting the corresponding requirements are obtained. However, when the code used by the code developer is unstable or has corresponding defects, the misuse of the code may cause the system to crash. Therefore, a technical solution capable of hiding the defective or unstable code is needed to avoid the system crash caused by the misuse of the code.
Based on the above research, the present disclosure provides a code processing method, apparatus, computer device, and storage medium. According to the above description, the code to be processed may be obtained first, and the code to be processed may be compiled according to the target compiling mode to obtain the code compiling result. Thereafter, a code modification identifier may be identified in the code compilation result, and target modification data in the code compilation result that matches the code modification identifier may be determined. Therefore, the position of the target modification data can be better determined in the code compiling result through the code modification identifier, and the accuracy of the determined target modification data is further improved. Then, a target modification mode corresponding to the target modification data may be determined based on the target compilation mode, and the access right of the target modification data is modified according to the target modification mode, so as to obtain a modified code compilation result. Therefore, the code execution stability of the modified code compiling result can be ensured in the execution process, so that unstable codes or system crash caused by defective codes in the execution process can be avoided, and the code operation accuracy is improved. Meanwhile, the reuse rate of the codes to be processed can be improved, so that the development efficiency of the codes is improved.
To facilitate understanding of the present embodiment, a code processing method disclosed in the embodiments of the present disclosure is first described in detail, and an execution subject of the code processing method provided in the embodiments of the present disclosure is generally a computer device with certain computing power.
Referring to fig. 1, a flowchart of a code processing method provided by the embodiment of the present disclosure is shown, where the method includes steps S101 to S107, where:
s101: and acquiring a code to be processed, and compiling the code to be processed according to a target compiling mode to obtain a code compiling result.
Here, the target compiling mode may be the first compiling mode or the second compiling mode. The first compiling mode may be used to indicate a compiling mode corresponding to a compiling stage of an SDK (Software Development Kit), or may be understood as a compiling mode for compiling to-be-processed code corresponding to the SDK Kit. Wherein the second compilation mode may be used to indicate a compilation mode corresponding to a compilation phase of the host.
For example, the first compiling mode may be understood as a compiling mode corresponding to a development kit when running compiling; the second compiling mode can be understood as a compiling mode corresponding to an APP (Application program) running and compiling.
In the embodiment of the present disclosure, the to-be-processed code may be a code in Java language, or may also be a code in Python language, and the present disclosure does not limit the type of the to-be-processed code, so as to meet the actual requirement.
In the embodiment of the present disclosure, after the to-be-processed code is obtained, the target compiling mode may be determined first, and the to-be-processed code is compiled according to the determined target compiling mode, so as to obtain a code compiling result. The code compiling result may be a byte code file.
S103: and identifying a code modification identifier in the code compiling result, and determining target modification data matched with the code modification identifier in the code compiling result.
In the embodiment of the present disclosure, the code modification identifier may be understood as an identifier for indicating a modified part of the code, for example, the code modification identifier may be @ Hide, or the code modification identifier may also be @ concept, and the content of the code modification identifier is not particularly limited by the present disclosure, so as to be implemented.
In an embodiment of the present disclosure, the target modification data is used to indicate code data to be modified, for example, the target modification data may be at least one of: class to be modified, method to be modified, field to be modified. The present disclosure does not specifically limit the target modification data to meet the actual requirements.
In the embodiment of the disclosure, after the code compiling result is obtained, the code modification identifier may be identified in the code compiling result, and the target modification data matching with the code modification identifier in the code compiling result may be determined.
S105: determining a target modification mode of the target modification data based on the target compilation mode, wherein the target modification mode is used for indicating an access right for modifying the target modification data.
In the embodiment of the present disclosure, the target modification mode may be used to indicate an access right for modifying the target modification data, where the access right may be used to indicate visibility of the target modification data to other classes (or methods, or fields) contained in the code compilation result (or may also be understood as the code to be processed).
In the embodiment of the present disclosure, the access right may include at least the following: public (public), protected (protected), private (private), packet access rights (default).
In the embodiment of the present disclosure, a target modification mode corresponding to the target modification data may be determined based on the target compilation mode. For example, when the target compiling mode is the first compiling mode, the target modification mode corresponding to the target modification data may be determined as the first modification mode, and when the target compiling mode is the second compiling mode, the target modification mode corresponding to the target modification data may be determined as the second modification mode. The first modification mode can be used for indicating that the access right of the target modification data is modified to be a mode hidden from the outside, and the second modification mode can be used for indicating that the access right of the target modification data is modified to be a mode not hidden from the outside.
For example, the first modification mode corresponding to the target modification data may be: and modifying the access right of the target modification data to be private. For example, the access right of the target modification data can be modified from public to private.
For a second modification mode corresponding to the target modification data, the second modification mode may be: the access rights of the target modification data are modified to be common. For example, the access right of the target modification data can be modified from private to public.
S107: and modifying the access authority of the target modified data according to the target modification mode to obtain a modified code compiling result.
In the embodiment of the present disclosure, after the access right of the target modification data is modified according to the target modification mode, a modified code compiling result may be obtained.
For example, when the target modification mode is the first modification mode, the obtained modified code compilation result hides the target modification data, and at this time, in the process of executing the modified code compilation result, the code compilation result corresponding to the target modification data cannot be executed. For another example, when the target modification mode is the second modification mode, the obtained modified code compiling result does not hide the target modification data, and at this time, in the process of executing the modified code compiling result, the code compiling result corresponding to the target modification data may be executed.
According to the above description, the code to be processed may be obtained first, and the code to be processed may be compiled according to the target compiling mode to obtain the code compiling result. Thereafter, a code modification identifier may be identified in the code compilation result, and target modification data in the code compilation result that matches the code modification identifier may be determined. Therefore, the position of the target modification data can be better determined in the code compiling result through the code modification identifier, and the accuracy of the determined target modification data is further improved. Then, a target modification mode corresponding to the target modification data may be determined based on the target compiling mode, and the access right of the target modification data is modified according to the target modification mode, so as to obtain a modified code compiling result. Therefore, the compiling result of the modified code can ensure the stability of code execution in the executing process, so that unstable codes or system crash caused by defective codes in the executing process can be avoided, and the running accuracy of the codes is improved. Meanwhile, the reuse rate of the codes to be processed can be improved, so that the development efficiency of the codes is improved.
In an alternative embodiment, for S103: determining target modification data matched with the code modification identifier in the code compiling result, specifically comprising the following steps:
step S1031: determining byte codes matched with the code modification identifications in the code compiling result;
step S1032: determining the target modification data in the matched bytecode, wherein the target modification data includes at least one of: class to be modified, method to be modified, field to be modified.
In the embodiments of the present disclosure, the bytecode may be understood as a file containing a computer-executable program. The bytecode may be obtained by compiling code (i.e., source code) written by a developer. For example, the code compilation result may be understood as a bytecode.
In the disclosed embodiment, the bytecode matching the code modification identification can be determined in the code compilation result. For example, in the case that the code modification identifier is @ high (or @ common), the location of the code modification identifier @ high may be determined in the code compilation result, and the data subsequent to the location of the code modification identifier @ high may be determined as the bytecode matching the code modification identifier @ high.
Then, target modification data may be determined in the determined matching bytecode, where the target modification data may be at least one of: class to be modified, method to be modified, field to be modified.
In specific implementation, the bytecode corresponding to the first class (or method or field) after the position of the code modification identifier @ Hide may be determined as target modification data.
In the above embodiment, by determining the bytecode matched with the code modification identifier in the code compiling result and determining the target modification data in the matched bytecode, modification of the code to be processed caused by directly determining the code to be processed as the target modification data can be avoided, so that invariance and reusability of the code to be processed can be ensured, and time cost and labor cost for re-editing the code to be processed can be saved.
In an optional embodiment, on the basis of steps S1031 to S1032, with respect to S107: modifying the access authority of the target modified data according to the target modification mode to obtain a modified code compiling result, which specifically comprises the following processes:
and under the condition that the target modification mode is a first modification mode, modifying the original access right of the target modification data into a first access right, wherein the first access right is used for indicating that the target modification data is hidden outwards, and the target compiling mode corresponding to the first modification mode is a compiling mode corresponding to a compiling stage of the SDK.
In the embodiment of the present disclosure, after the target modification data is determined in the matched bytecode, the access right of the target modification data may be modified according to the target modification mode.
In a specific implementation, a target modification mode corresponding to the target compiling mode may be determined based on the target compiling mode, and then the access right of the target modification data may be modified according to the determined target modification mode.
For example, in a case where the target coding mode is the above-described first coding mode, it may be determined that a target modification mode corresponding to the target coding mode is the first modification mode. After that, the original access right of the target modification data can be modified into the first access right according to the first modification mode.
The original access right can be understood as the access right corresponding to the target modified data before modification.
The first access right is used for indicating that the target modification data is hidden from the outside, so that the original access right of the target data is data which is not hidden from the outside. At this time, it may be determined that the original access right may be any one of the following: public (public), protected (protected), package access rights (default).
In the above embodiment, the original access right of the target modification data may be modified to be hidden from outside when the target modification mode is the first modification mode, so that the access right of the target modification data may be modified to be hidden from outside in the compilation stage of the SDK, thereby avoiding an execution failure or an execution crash phenomenon caused by instability of the target modification data, and further ensuring accuracy and stability of execution.
In an alternative embodiment, as shown in fig. 2, the following are addressed: modifying the original access right of the target modification data into a first access right, and specifically comprising the following steps:
step S21: determining a permission identifier in the target modification data;
step S22: modifying the permission identifier to a first permission identifier, wherein the first permission identifier is an identifier corresponding to the first access permission.
In the embodiment of the present disclosure, the right identifier may be understood as an identifier of an access right, for example, in a case that the access right is public (public), a right identifier corresponding to the access right is public. As another example, in the case that the access right is protected (protected), the right identifier corresponding to the access right is protected. This is not further enumerated here.
In this embodiment of the present disclosure, the first permission identifier is an identifier corresponding to the first access permission, that is, the first permission identifier is a permission identifier corresponding to externally hidden target modification data, and at this time, the first permission identifier may be a private.
In the embodiment of the present disclosure, in the case that the original access right of the target modification data is modified to the first access right, the authority identifier in the target modification data may be determined by the original access right of the target modification data, and then the authority identifier is modified to the first authority identifier.
In a specific implementation, after the permission identifier is determined, a bytecode modification function is called to modify the permission identifier into the first permission identifier. Wherein the bytecode modification function may be a javasist function.
In the above embodiment, the permission identifier in the target modification data may be determined first, and then the permission identifier is modified into the first permission identifier, so that the target modification data can be hidden from the outside simply and quickly.
In an alternative embodiment, as shown in fig. 3, in the case that the target modification mode is the first modification mode, for S107: modifying the access right of the target modified data according to the target modification mode, which specifically comprises the following steps:
step S31: acquiring original access authority of the target modified data before modification;
step S32: and generating target identification information at the specified position of the target modification data based on the original access right, wherein the target identification information is used for indicating the original access right of the target modification data.
In the embodiment of the present disclosure, the specified position of the target data may be at the end of the target data, or may be at the beginning of the target data, and the specified position of the target data is not specifically limited by the present disclosure, so as to be implemented as the standard.
In embodiments of the present disclosure, the target identification information may be used to indicate the original access rights of the target modification data. For example, in the case where the original access rights of the target modification data are public (public), the target identification information may be: the modify is 1, or the target identification information may be: the modification is 0, and the content of the target identification information is not particularly limited in this disclosure, so as to meet the actual needs.
In the embodiment of the present disclosure, before modifying the target modification data according to the target modification mode, an original access right of the target modification data may be obtained first, and target identification information may be generated at a specified position of the target modification data based on the original access right.
In the above embodiment, in the case that the access right of the target modified data is modified according to the target modification mode, the original access right of the target modified data before modification is acquired, and the target identification information is generated based on the original access right, so that the original access right information of the target modified data can be retained. Meanwhile, the target identification information can also be used as identification information for finishing modifying the target modification data, so that the target modification data can be determined to be modified on the basis of the target identification information.
In an alternative embodiment, as shown in fig. 4, on the basis of step S31 to step S32, for S107: modifying the access right of the target modified data according to the target modification mode to obtain a modified code compiling result, and specifically comprising the following steps of:
step S41: under the condition that the target modification mode is a second modification mode, acquiring target identification information in the target modification data; the target compiling mode corresponding to the second modification mode is a compiling mode corresponding to a compiling stage of the host; (ii) a
Step S42: determining original access rights of the target modification data based on the target identification information;
step S43: determining a permission identifier corresponding to the original access permission to obtain a second permission identifier;
step S44: and modifying the authority identifier of the target modification data into a second authority identifier, wherein the second authority identifier is an identifier corresponding to the original access authority.
In the embodiment of the present disclosure, in a case that the target compiling mode is the second compiling mode, it may be determined that the target modification mode is the second modification mode based on the target compiling mode. In the case that the target modification mode is the second modification mode, the target identification information in the target modification data may be obtained first, and then the original access right of the target modification data may be determined based on the target identification information.
For example, when the target identification information is as described above: if the modify is 1, it may be determined that the original access right of the target data is public (public).
Thereafter, a rights identifier corresponding to the original access rights may be determined, resulting in a second rights identifier. The second permission identifier may be understood as an original access permission to restore the target modified data, for example, the second permission identifier may indicate a permission identifier that does not hide the target modified data from the outside.
For example, when the original access right is public (public), the second right identifier may be public.
The rights identifier of the target modification data may then be modified to a second rights identifier.
In specific implementation, a bytecode modification function may be called to modify the permission identifier of the target modification data to a second permission identifier. Wherein the bytecode modification function can be a javasist function.
In the above embodiment, when the target modification mode is the second modification mode, the target identification information in the target modification data may be obtained, and the original access right of the target modification data may be determined based on the target identification information. Then, after determining the second permission identifier corresponding to the original access permission, the permission identifier of the target modification data may be modified into the second permission identifier. Therefore, the compiling result of the modified code can be smoothly executed in the host execution stage, and the phenomenon that the code to be processed fails in the host stage is further avoided.
It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.
Based on the same inventive concept, a code processing apparatus corresponding to the code processing method is also provided in the embodiments of the present disclosure, and since the principle of solving the problem of the apparatus in the embodiments of the present disclosure is similar to the code processing method in the embodiments of the present disclosure, the implementation of the apparatus may refer to the implementation of the method, and the repeated parts are not described again.
Referring to fig. 5, a schematic diagram of a code processing apparatus provided in an embodiment of the present disclosure is shown, where the apparatus includes: an acquisition unit 51, a recognition unit 52, a determination unit 53, a modification unit 54; wherein, the first and the second end of the pipe are connected with each other,
the obtaining unit 51 is configured to obtain a code to be processed, and compile the code to be processed according to a target compilation mode to obtain a code compilation result;
a recognition unit 52, configured to recognize a code modification identifier in the code compilation result, and determine target modification data matching the code modification identifier in the code compilation result;
a determining unit 53, configured to determine a target modification mode of the target modification data based on the target compiling mode, where the target modification mode is used to indicate an access right to modify the target modification data;
and a modifying unit 54, configured to modify the access right of the target modified data according to the target modification mode, so as to obtain a modified code compiling result.
According to the above description, the code to be processed may be obtained first, and the code to be processed may be compiled according to the target compiling mode to obtain the code compiling result. Thereafter, a code modification identifier may be identified in the code compilation result, and target modification data in the code compilation result that matches the code modification identifier may be determined. Therefore, the position of the target modification data can be better determined in the code compiling result through the code modification identifier, and the accuracy of the determined target modification data is further improved. Then, a target modification mode corresponding to the target modification data may be determined based on the target compilation mode, and the access right of the target modification data is modified according to the target modification mode, so as to obtain a modified code compilation result. Therefore, the code execution stability of the modified code compiling result can be ensured in the execution process, so that unstable codes or system crash caused by defective codes in the execution process can be avoided, and the code operation accuracy is improved. Meanwhile, the reuse rate of the codes to be processed can be improved, so that the development efficiency of the codes is improved.
In a possible embodiment, the identification unit is further configured to: determining byte codes matched with the code modification identifications in the code compiling result; determining the target modification data in the matched bytecode, wherein the target modification data includes at least one of: class to be modified, method to be modified, field to be modified.
In a possible embodiment, the modifying unit is further configured to: and under the condition that the target modification mode is a first modification mode, modifying the original access right of the target modification data into a first access right, wherein the first access right is used for indicating that the target modification data is hidden outwards, and a target compiling mode corresponding to the first modification mode is a compiling mode corresponding to a compiling stage of the SDK.
In a possible embodiment, the modifying unit is further configured to: determining a permission identifier in the target modification data; modifying the permission identifier to a first permission identifier, wherein the first permission identifier is an identifier corresponding to the first access permission.
In a possible embodiment, the modifying unit is further configured to: under the condition that a target modification mode is a first modification mode, acquiring original access permission of the target modification data before modification; and generating target identification information at a specified position of the target modification data based on the original access right, wherein the target identification information is used for indicating the original access right of the target modification data.
In a possible implementation, the modifying unit is further configured to: under the condition that the target modification mode is a second modification mode, acquiring target identification information in the target modification data; the target compiling mode corresponding to the second modification mode is a compiling mode corresponding to a compiling stage of the host; determining original access rights of the target modification data based on the target identification information; determining a permission identifier corresponding to the original access permission to obtain a second permission identifier; and modifying the authority identifier of the target modification data into a second authority identifier, wherein the second authority identifier is an identifier corresponding to the original access authority.
The description of the processing flow of each module in the device and the interaction flow between the modules may refer to the related description in the above method embodiments, and will not be described in detail here.
Corresponding to the code processing method in fig. 1, an embodiment of the present disclosure further provides a computer device 600, as shown in fig. 6, a schematic structural diagram of the computer device 600 provided in the embodiment of the present disclosure includes:
a processor 61, memory 62, and bus 63; the memory 62 is used for storing execution instructions and includes a memory 621 and an external memory 622; the memory 621 is also called an internal memory, and is used for temporarily storing the operation data in the processor 61 and the data exchanged with the external memory 622 such as a hard disk, the processor 61 exchanges data with the external memory 622 through the memory 621, and when the computer device 600 operates, the processor 61 communicates with the memory 62 through the bus 63, so that the processor 61 executes the following instructions:
acquiring a code to be processed, and compiling the code to be processed according to a target compiling mode to obtain a code compiling result;
identifying a code modification identifier in the code compiling result, and determining target modification data matched with the code modification identifier in the code compiling result;
determining a target modification mode of the target modification data based on the target compilation mode, wherein the target modification mode is used for indicating an access right for modifying the target modification data;
and modifying the access authority of the target modified data according to the target modification mode to obtain a modified code compiling result.
The embodiments of the present disclosure also provide a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the code processing method described in the above method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.
The embodiments of the present disclosure further provide a computer program product, where the computer program product carries a program code, and instructions included in the program code may be used to execute the steps of the code processing method in the foregoing method embodiments, which may be specifically referred to in the foregoing method embodiments and are not described herein again.
The computer program product may be implemented by hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied in a computer storage medium, and in another alternative embodiment, the computer program product is embodied in a Software product, such as a Software Development Kit (SDK) or the like.
It can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working process of the system and the apparatus described above may refer to the corresponding process in the foregoing method embodiment, and details are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, apparatus, and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in software functional units and sold or used as a stand-alone product, may be stored in a non-transitory computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present disclosure. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are merely specific embodiments of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, but not to limit the technical solutions, and the scope of the present disclosure is not limited thereto, and although the present disclosure is described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: those skilled in the art can still make modifications or changes to the embodiments described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the technical scope of the disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present disclosure, and should be construed as being included therein. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (9)

1. A code processing method, comprising:
acquiring a code to be processed, and compiling the code to be processed according to a target compiling mode to obtain a code compiling result;
identifying a code modification identifier in the code compiling result, and determining target modification data matched with the code modification identifier in the code compiling result;
determining a target modification mode of the target modification data based on the target compiling mode, wherein the target modification mode is used for indicating an access right for modifying the target modification data;
and modifying the access authority of the target modified data according to the target modification mode to obtain a modified code compiling result.
2. The method of claim 1, wherein the determining that the code compilation result matches the code modification identifier comprises:
determining byte codes matched with the code modification identifications in the code compiling result;
determining the target modification data in the matched bytecode, wherein the target modification data includes at least one of: class to be modified, method to be modified, field to be modified.
3. The method according to claim 1 or 2, wherein the modifying the access right of the target modification data according to the target modification mode to obtain a modified code compiling result comprises:
and under the condition that the target modification mode is a first modification mode, modifying the original access right of the target modification data into a first access right, wherein the first access right is used for indicating that the target modification data is hidden outwards, and a target compiling mode corresponding to the first modification mode is a compiling mode corresponding to a compiling stage of the SDK.
4. The method of claim 3, wherein modifying the original access right of the target modification data to a first access right comprises:
determining a permission identifier in the target modification data;
and modifying the authority identifier into a first authority identifier, wherein the first authority identifier is an identifier corresponding to the first access authority.
5. The method of claim 1, wherein the target modification mode is a first modification mode, and wherein modifying the access right of the target modification data according to the target modification mode comprises:
acquiring original access authority of the target modified data before modification;
and generating target identification information at the specified position of the target modification data based on the original access right, wherein the target identification information is used for indicating the original access right of the target modification data.
6. The method of claim 5, wherein the modifying the access right of the target modification data according to the target modification mode to obtain a modified code compilation result comprises:
under the condition that the target modification mode is a second modification mode, acquiring target identification information in the target modification data; the target compiling mode corresponding to the second modification mode is a compiling mode corresponding to a compiling stage of the host;
determining original access rights of the target modification data based on the target identification information;
determining a permission identifier corresponding to the original access permission to obtain a second permission identifier;
and modifying the authority identifier of the target modification data into a second authority identifier, wherein the second authority identifier is an identifier corresponding to the original access authority.
7. A code processing apparatus, comprising:
the device comprises an acquisition unit, a processing unit and a compiling unit, wherein the acquisition unit is used for acquiring a code to be processed and compiling the code to be processed according to a target compiling mode to obtain a code compiling result;
the identification unit is used for identifying a code modification identifier in the code compiling result and determining target modification data matched with the code modification identifier in the code compiling result;
a determining unit, configured to determine a target modification mode of the target modification data based on the target compilation mode, where the target modification mode is used to indicate an access right to modify the target modification data;
and the modifying unit is used for modifying the access authority of the target modified data according to the target modification mode to obtain a modified code compiling result.
8. A computer device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when the computer device is running, the machine-readable instructions, when executed by the processor, performing the steps of the code processing method of any of claims 1 to 6.
9. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, which computer program, when being executed by a processor, performs the steps of a code processing method according to any one of claims 1 to 6.
CN202210377433.3A 2022-04-11 2022-04-11 Code processing method and device, computer equipment and storage medium Pending CN114780101A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210377433.3A CN114780101A (en) 2022-04-11 2022-04-11 Code processing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210377433.3A CN114780101A (en) 2022-04-11 2022-04-11 Code processing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114780101A true CN114780101A (en) 2022-07-22

Family

ID=82429269

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210377433.3A Pending CN114780101A (en) 2022-04-11 2022-04-11 Code processing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114780101A (en)

Similar Documents

Publication Publication Date Title
CN110825363B (en) Intelligent contract acquisition method and device, electronic equipment and storage medium
CN110059456B (en) Code protection method, code protection device, storage medium and electronic equipment
CN111414391A (en) Method and system for accessing multiple data sources
US10409572B2 (en) Compiled file normalization
CN112685410A (en) Business rule checking method and device, computer equipment and storage medium
CN113296786A (en) Data processing method and device, electronic equipment and storage medium
US8769498B2 (en) Warning of register and storage area assignment errors
CN110688320B (en) Global variable detection method and device and terminal equipment
CN114780101A (en) Code processing method and device, computer equipment and storage medium
CN111625225A (en) Program specified data output method and device
CN107817972B (en) Cache code processing method and device, storage medium and electronic equipment
CN108897532B (en) Method and device for class factory registration and electronic equipment
CN113703753B (en) Method and device for product development and product development system
CN112069052A (en) Abnormal object detection method, device, equipment and storage medium
CN114706586A (en) Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium
CN114356342A (en) Compiling method and device
CN114218261A (en) Data query method and device, storage medium and electronic equipment
CN113127005A (en) Method and device for generating executable file and computer storage medium
CN110327626B (en) Virtual server creation method and device
CN110377367B (en) Component configuration method and device, electronic terminal and computer readable storage medium
CN109697216B (en) Clearing transaction information processing method, device and system
CN112925523A (en) Object comparison method, device, equipment and computer readable medium
US10671397B2 (en) Reduced save and restore instructions for call-clobbered registers
CN114579135B (en) Installation package generation method and device
US20240152363A1 (en) Management device, communication system, management method, and non-transitory computer-readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Douyin Vision Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: Tiktok vision (Beijing) Co.,Ltd.

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Tiktok vision (Beijing) Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: BEIJING BYTEDANCE NETWORK TECHNOLOGY Co.,Ltd.