Code processing method and apparatus, terminal and computer readable storage medium

By analyzing front-end code through target code processing and large-scale model analysis, risky code segments are automatically identified and optimized, and target bytecode is generated. This solves the problem of front-end code optimization relying on manual intervention and achieves efficient code security and performance improvement.

CN122285463APending Publication Date: 2026-06-26BEIJING HONGTENG INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING HONGTENG INTELLIGENT TECH CO LTD
Filing Date
2024-12-25
Publication Date
2026-06-26

Smart Images

  • Figure CN122285463A_ABST
    Figure CN122285463A_ABST
Patent Text Reader

Abstract

This application discloses a code processing method, apparatus, terminal, and computer-readable storage medium. The method includes: acquiring initial front-end code; performing code analysis on the initial front-end code using a target code processing model to obtain code risk information; then, determining target risk code segments in the initial front-end code based on the code risk information; performing intermediate representation optimization processing on the target risk code segments using the code risk information to obtain target intermediate representations corresponding to the target risk code segments; then, generating target bytecode corresponding to the target intermediate representations; and replacing the target risk code segments in the initial front-end code based on the target bytecode to obtain target front-end code. This solves the technical problem of relying on manual code optimization when optimizing completed front-end code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a code processing method, apparatus, terminal, and computer-readable storage medium. Background Technology

[0002] In recent years, with the rapid development of the internet, developers typically use front-end code for web development. Optimizing the completed front-end code often relies on manual analysis. Summary of the Invention

[0003] This application provides a code processing method, apparatus, terminal, and computer-readable storage medium, which can solve the technical problem of relying on manual code optimization when optimizing completed front-end code.

[0004] In a first aspect, embodiments of this application provide a code processing method, the method comprising:

[0005] Obtain the initial front-end code, and use the target code processing model to perform code analysis on the initial front-end code to obtain code risk information;

[0006] Based on the code risk information, the target risk code segment in the initial front-end code is determined, and the intermediate representation optimization processing of the target risk code segment is performed using the code risk information to obtain the target intermediate representation corresponding to the target risk code segment;

[0007] Generate the target bytecode corresponding to the target intermediate representation, and replace the target risk code segment in the initial front-end code based on the target bytecode to obtain the target front-end code.

[0008] Optionally, the initial front-end code is analyzed using a target code processing model to obtain code risk information, including:

[0009] Based on the target code processing big model, static code analysis is performed on the initial front-end code to obtain the risk code information corresponding to the initial front-end code;

[0010] The target code processing model is used to generate risk processing strategies for the risk code information, thereby obtaining risk processing strategies for the risk code information.

[0011] Code risk information is obtained based on the risk code information and the risk handling strategy.

[0012] Optionally, the step of performing static code analysis on the initial front-end code based on the target code processing big model to obtain risk code information corresponding to the initial front-end code includes:

[0013] Based on the target code processing big model, static code performance analysis is performed on the initial front-end code to obtain code performance risk information corresponding to the initial front-end code;

[0014] Based on the target code processing big model, static code security analysis is performed on the initial front-end code to obtain code security risk information corresponding to the initial front-end code;

[0015] Based on the code performance risk information and the code security risk information, the risk code information corresponding to the initial front-end code is determined.

[0016] Optionally, determining the target risky code segment in the initial front-end code based on the code risk information includes:

[0017] Determine the risk code information corresponding to the code risk information, and determine the candidate risk code segments in the initial front-end code based on the risk code information;

[0018] Determine a risk code segment selection strategy for the candidate risk code segments, and determine the target risk code segment from the candidate risk code segments based on the risk code segment selection strategy.

[0019] Optionally, the step of using the code risk information to perform intermediate representation optimization processing on the target risk code segment to obtain the target intermediate representation corresponding to the target risk code segment includes:

[0020] Determine the risk code information corresponding to the target risk code segment, and determine the risk handling strategy corresponding to the risk code information based on the code risk information;

[0021] Determine the initial intermediate representation corresponding to the target risk code segment, and perform intermediate representation optimization processing on the initial intermediate representation based on the risk processing strategy to obtain the target intermediate representation corresponding to the target risk code segment.

[0022] Optionally, after obtaining the target front-end code, the method further includes:

[0023] In the code testing environment, perform code testing on the current target front-end code to determine the test score value corresponding to the current target front-end code;

[0024] If the test score value corresponding to the current target front-end code is less than the preset test score value, the risk code segment selection strategy is adjusted based on the test score value corresponding to the current target front-end code to update the risk code segment selection strategy.

[0025] Perform the step of determining the target risk code segment from the candidate risk code segments based on the risk code segment selection strategy;

[0026] If the test score value corresponding to the current target front-end code is greater than or equal to the preset test score value, then the target front-end code is determined to have passed the code test.

[0027] Optionally, the method further includes:

[0028] When it is determined that the target front-end code passes the code test, the code deployment information associated with the initial front-end code is obtained;

[0029] The target front-end code is deployed based on the code deployment information.

[0030] Optionally, determining the test score corresponding to the current target front-end code includes:

[0031] Obtain runtime information and memory usage information corresponding to the current target front-end code, determine the first characterization value corresponding to the runtime information, and determine the second characterization value corresponding to the memory usage information;

[0032] A first weight corresponding to the runtime information is determined, and a second weight corresponding to the memory usage information is determined; wherein the sum of the first weight and the second weight is 1;

[0033] The first representation value and the second representation value are weighted and summed based on the first weight and the second weight to obtain the test score value corresponding to the current target front-end code.

[0034] Optionally, generating the target intermediate representation corresponding to the target bytecode includes:

[0035] The target intermediate representation is compiled to obtain the target bytecode.

[0036] Secondly, embodiments of this application provide a code processing apparatus, the apparatus comprising:

[0037] The acquisition module is suitable for acquiring initial front-end code and using a target code processing model to perform code analysis on the initial front-end code to obtain code risk information.

[0038] The processing module is adapted to determine the target risk code segment in the initial front-end code based on the code risk information, and to perform intermediate representation optimization processing on the target risk code segment using the code risk information to obtain the target intermediate representation corresponding to the target risk code segment;

[0039] The generation module is adapted to generate the target bytecode corresponding to the target intermediate representation, and to replace the target risk code segment in the initial front-end code based on the target bytecode to obtain the target front-end code.

[0040] Thirdly, embodiments of this application provide a terminal, the terminal comprising:

[0041] Processor; and

[0042] A memory configured to store computer-executable instructions, which, when executed, cause the processor to perform the method according to any one of the preceding claims.

[0043] Thirdly, embodiments of this application provide a computer-readable storage medium that stores one or more programs, which, when executed by a processor, implement the method described in any of the above-mentioned embodiments.

[0044] The beneficial effects of the technical solution provided in this application include at least the following: First, code risk information is obtained by analyzing the initial front-end code using a target code processing model. Then, the target risk code segment in the initial front-end code is identified using this code risk information. Next, the target risk code segment is optimized using the code risk information to obtain a target intermediate representation, thereby simplifying code logic, reducing unnecessary calculations, or improving code security. Then, the target bytecode corresponding to the intermediate representation is generated, and the target risk code segment in the initial front-end code is replaced using the target bytecode, thereby further optimizing the performance of the target risk code segment. This effectively solves the technical problem of relying on manual code optimization when optimizing completed front-end code. Attached Figure Description

[0045] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0046] Figure 1 An exemplary system architecture diagram of a code processing method provided in this application embodiment;

[0047] Figure 2 A flowchart illustrating a code processing method provided in an embodiment of this application;

[0048] Figure 3 This application provides a flowchart illustrating a process for determining code risk information.

[0049] Figure 4 This application provides a schematic diagram of a process for determining risk code information.

[0050] Figure 5 A flowchart illustrating the process of determining a target risk code segment is provided for an embodiment of this application;

[0051] Figure 6 A flowchart illustrating the process of determining an intermediate representation of a target is provided for an embodiment of this application;

[0052] Figure 7 This is a flowchart illustrating a code test for a target front-end code, provided as an embodiment of this application.

[0053] Figure 8 This application provides a flowchart illustrating a process for determining the test score value corresponding to the current target front-end code in an embodiment of the present application.

[0054] Figure 9 This is a schematic diagram of the structure of a code processing device provided in an embodiment of this application;

[0055] Figure 10 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application. Detailed Implementation

[0056] To make the features and advantages of the embodiments of this application more apparent and understandable, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the protection scope of the embodiments of this application.

[0057] In related technologies, JavaScript, as a primary front-end programming language, is widely used in front-end logic processing. However, JavaScript's dynamic nature leads to certain bottlenecks when handling complex, high-frequency operations and security protection.

[0058] When optimizing front-end code for JavaScript, compiler optimization techniques can be used, such as Profile-Guided Optimization (PGO). PGO optimizes code performance by using runtime information, specifically targeting hot paths (frequently executed code paths) in the front-end code. However, PGO optimization requires collecting runtime data at compile time, increasing the complexity of browser compilation and deployment.

[0059] When optimizing front-end code corresponding to JavaScript, manual analysis of the JavaScript code logic can be used to arrive at analysis results and make corresponding optimizations. Although manual code optimization allows for a deeper understanding of the code's structure and logic, thus enabling better identification of performance bottlenecks and potential problems, it typically requires a significant amount of time and effort, especially in large projects, where manually adjusting every detail can extend the development cycle. Furthermore, manual optimization relies heavily on the developer's experience and judgment.

[0060] Furthermore, when optimizing the front-end code corresponding to JavaScript, JavaScript code obfuscation techniques can be used. JavaScript code obfuscation is a technique designed to protect JavaScript code by transforming it into an incomprehensible form to increase its security, preventing easy analysis, reverse engineering, or theft. The obfuscated code can still run normally in the browser, but it becomes more difficult for developers to understand and modify. However, JavaScript code obfuscation techniques are often difficult to provide effective protection in practical applications. Static analysis methods can usually be used to understand the obfuscated code, and JavaScript code obfuscation often leads to a decrease in the performance of the corresponding code.

[0061] To address the related technical problems, this application provides a code processing method. The method includes: obtaining initial front-end code; performing code analysis on the initial front-end code using a target code processing model to obtain code risk information; determining target risk code segments in the initial front-end code based on the code risk information; performing intermediate representation optimization on the target risk code segments using the code risk information to obtain a target intermediate representation corresponding to the target risk code segments; generating target bytecode corresponding to the target intermediate representation; and replacing the target risk code segments in the initial front-end code based on the target bytecode to obtain the target front-end code. This solves the technical problem of relying on manual code optimization when optimizing completed front-end code.

[0062] Please see Figure 1 , Figure 1 An exemplary system architecture diagram of a code processing method provided in an embodiment of this application.

[0063] like Figure 1 As shown, the system architecture may include a terminal 101, a network 102, and a server 103. The network 102 serves as the medium for providing a communication link between the terminal 101 and the server 103. The network 102 may include various types of wired or wireless communication links, such as wired communication links including fiber optic cables, twisted-pair cables, or coaxial cables, and wireless communication links including Bluetooth communication links, Wi-Fi (Wireless Fidelity) communication links, or microwave communication links, etc.

[0064] Terminal 101 can interact with server 103 via network 102 to receive messages from or send messages to server 103. Alternatively, terminal 101 can interact with server 103 via network 102 to receive messages or data sent to server 103 by other users. Terminal 101 can be hardware or software. When terminal 101 is hardware, it can be various terminals, including but not limited to smartwatches, smartphones, tablets, laptops, and desktop computers. When terminal 101 is software, it can be installed in the terminals listed above, and can be implemented as multiple software programs or software modules (e.g., to provide distributed services) or as a single software program or software module; no specific limitation is made here.

[0065] Server 103 can be a business server providing various services. It should be noted that server 103 can be either hardware or software. When server 103 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When server 103 is software, it can be implemented as multiple software programs or software modules (e.g., used to provide distributed services), or as a single software program or software module; no specific limitations are made here.

[0066] In this embodiment, terminal 101 can obtain initial front-end code, perform code analysis on the initial front-end code using a target code processing model to obtain code risk information; determine the target risk code segment in the initial front-end code based on the code risk information, perform intermediate representation optimization on the target risk code segment using the code risk information to obtain the target intermediate representation corresponding to the target risk code segment; generate the target bytecode corresponding to the target intermediate representation, and replace the target risk code segment in the initial front-end code based on the target bytecode to obtain the target front-end code.

[0067] It should be understood that the number of terminals, networks, and servers mentioned above is merely illustrative, and can be any number of terminals, networks, and servers depending on implementation needs. Of course, in one embodiment provided in this application, the system architecture may not include servers.

[0068] Please see Figure 2 , Figure 2 This is a flowchart illustrating a code processing method provided in an embodiment of this application. The execution entity in this embodiment can be a terminal executing the code processing method, a processor within the terminal executing the code processing method, or a code processing service within the terminal executing the code processing method. For ease of description, the following example uses a processor within a terminal as the execution entity to illustrate the specific execution process of the code processing method.

[0069] like Figure 2 As shown, the code processing methods include:

[0070] S202: Obtain the initial front-end code, and use the target code processing model to perform code analysis on the initial front-end code to obtain code risk information.

[0071] The process involves obtaining initial front-end code through web development. To optimize this initial code, it is input into a target code processing model. This model analyzes the initial front-end code to identify potential risky code segments and generate corresponding risk management strategies. The initial front-end code includes, but is not limited to, JavaScript code.

[0072] For example, code risk information includes risky code information and risk handling strategies. The risky code information records the number of candidate risky code segments and the specific location of each segment. For instance, the code segment from line A to line B is the first candidate risky code segment, and the code segment from line C to line D is the second candidate risky code segment. Furthermore, the risky code information also records the risk information corresponding to each candidate risky code segment, such as code performance risk (high-complexity loops, redundant calculations, etc.) or code security risk (vulnerabilities in code security logic, etc.). The risk handling strategy is the strategy for handling the risk information corresponding to each candidate risky code segment; that is, the risk handling strategy.

[0073] Furthermore, to obtain the target code processing model, the basic code processing model can be trained. Specifically, the basic code processing model can be trained using sample front-end code and the corresponding sample code risk information. The basic code processing model outputs reference code risk information corresponding to the sample front-end code. Based on the reference code risk information and the sample code risk information, a model loss function is constructed, and the model loss value corresponding to the model loss function in the current training round is determined. The model parameters of the basic code processing model are adjusted using the model loss value until the basic code processing model completes training and the target code processing model is obtained.

[0074] S204: Based on code risk information, determine the target risk code segment in the initial front-end code, and use the code risk information to perform intermediate representation optimization processing on the target risk code segment to obtain the target intermediate representation corresponding to the target risk code segment.

[0075] This process involves parsing the code risk information to obtain the risk code information. Since the risk code information records the number of candidate risk code segments and the specific location of each candidate segment, a target risk code segment can be selected from the candidate segments. For example, candidate risk code segments and their corresponding risk information can be pushed to the user interface for the user to select. After the user makes a selection, a risk code segment selection strategy is generated based on the user's selection information, and the selected candidate risk code segment is used as the target risk code segment.

[0076] After identifying the target risky code segment, a corresponding risk handling strategy is determined. This strategy, found in the code risk information, is then used to optimize the intermediate representation of the target risky code segment. Specifically, the initial intermediate representation corresponding to the target risky code segment is optimized using the risk handling strategy to obtain the target intermediate representation. This optimization includes, but is not limited to, merging similar code, eliminating redundant code, and patching security vulnerabilities, thereby simplifying code logic, reducing unnecessary computation, or improving code security. The target intermediate representation obtained after optimization typically utilizes processor power and memory resources more effectively, reducing resource waste. Furthermore, because unnecessary complexity and redundancy are removed, the optimized target intermediate representation often has better readability.

[0077] It's important to note that intermediate representation is an abstract representation generated by the compiler when processing source code. It's a language that lies between the high-level representation of the source program and the low-level representation of the target machine. Intermediate representation aims to facilitate program analysis and optimization by the compiler, reduce the difficulty of converting from the source language to the target language, and improve the ease of use and performance of program analysis and optimization.

[0078] S206: Generate the target intermediate representation corresponding to the target bytecode, and replace the target risk code segment in the initial front-end code based on the target bytecode to obtain the target front-end code.

[0079] The target bytecode can be in binary instruction format, specifically WebAssembly bytecode. WebAssembly bytecode can be executed in a browser at near-native speed because it is binary code that runs directly in a virtual machine. This can effectively improve the computational efficiency and shorten the computation time for computationally intensive tasks (such as image processing, encryption algorithms, and physics simulations).

[0080] Therefore, by generating the target bytecode corresponding to the intermediate representation, the performance of the target risky code segment is further optimized. Then, the target bytecode is used to replace the target risky code segment in the initial front-end code, resulting in the optimized target front-end code corresponding to the initial front-end code.

[0081] For example, generating the target bytecode corresponding to the target intermediate representation in S206 includes: compiling the target intermediate representation to obtain the target bytecode. Specifically, this can be compiling the target intermediate representation to obtain WebAssembly bytecode.

[0082] In the embodiments provided in this application, code risk information is obtained by analyzing the initial front-end code using a target code processing model. Then, the code risk information is used to identify target risky code segments in the initial front-end code, and intermediate representation optimization is performed on these target risky code segments to obtain target intermediate representations. This simplifies code logic, reduces unnecessary computation, or improves code security. Subsequently, target bytecode corresponding to the intermediate representation is generated, and the target bytecode is used to replace the target risky code segments in the initial front-end code, further optimizing the performance of these target risky code segments. This effectively solves the technical problem of relying on manual code optimization when optimizing completed front-end code.

[0083] Please see Figure 3 , Figure 3 This is a schematic diagram illustrating a process for determining code risk information, provided as an embodiment of this application. Figure 3 As shown in S202, the target code processing model is used to perform code analysis on the initial front-end code to obtain code risk information, including:

[0084] S302: Based on the target code processing model, perform static code analysis on the initial front-end code to obtain risk code information corresponding to the initial front-end code.

[0085] The process involves inputting the initial front-end code into a target code processing model, which then performs model processing on the initial front-end code to conduct static code analysis. Here, static code analysis is used to scan, check, and analyze the code performance and security risks corresponding to the initial front-end code without executing the code, thereby obtaining risk code information related to the initial front-end code.

[0086] The risk code information records the number of candidate risk code segments and the specific location of each candidate risk code segment. For example, the code segment from line A to line B is the first candidate risk code segment, and the code segment from line C to line D is the second candidate risk code segment. In addition, the risk code information also records the risk information corresponding to the candidate risk code segments, such as the existence of code performance risks (high complexity loops, repeated calculations, etc.) or code security risks (vulnerabilities in code security logic, etc.).

[0087] S304: Utilize the target code processing model to generate risk handling strategies for risk code information, thereby obtaining risk handling strategies for risk code information.

[0088] In this process, after generating the risk code information corresponding to the initial front-end code, the target code processing model continues to process the risk code information and uses the risk information corresponding to the candidate risk code segments recorded in the risk code information to generate a risk handling strategy for the risk code information.

[0089] When the risk code information is code performance risk information, the corresponding risk handling strategy is used to eliminate the corresponding code performance risk. For example, if the risk information corresponding to the candidate risk code segment is that the code segment contains a high-complexity loop, the corresponding risk handling strategy is used to guide the elimination of the high-complexity loop; or, if the risk information corresponding to the candidate risk code segment is that the code segment contains duplicate calculations, the corresponding risk handling strategy is used to guide the simplification of the duplicate calculations.

[0090] When the risk code information is a code security risk, the corresponding risk handling strategy is used to eliminate the corresponding code security risk. For example, if the risk information corresponding to a candidate risky code segment is that the code segment has a code security logic vulnerability, the corresponding risk handling strategy is used to guide the vulnerability patching.

[0091] S306: Obtain code risk information based on risk code information and risk handling strategies.

[0092] After determining the risk code information and risk handling strategy, the corresponding risk code information and risk handling strategy are associated to obtain the code risk information. It should be noted that the number of associated risk code information and risk handling strategy pairs in the code risk information can be one or more.

[0093] In the embodiments provided in this application, a large-scale target code processing model is used to perform static code analysis on the initial front-end code to obtain risk code information, avoiding the need to collect additional runtime code data and simplifying the code analysis process. Furthermore, the large-scale target code processing model is used to generate risk handling strategies from the risk code information, making the risk handling strategies more targeted. Finally, the risk code information and risk handling strategies are used to obtain code risk information. In this embodiment, the process of determining code risk information is automated, effectively avoiding reliance on manual code analysis.

[0094] Please see Figure 4 , Figure 4 This is a schematic diagram illustrating a process for determining risk code information, provided as an embodiment of this application. Figure 4 As shown in S302, static code analysis is performed on the initial front-end code based on the target code processing model to obtain risk code information corresponding to the initial front-end code, including:

[0095] S402: Based on the target code processing big model, perform static code performance analysis on the initial front-end code to obtain code performance risk information corresponding to the initial front-end code.

[0096] The code performance risk information includes performance risk code information and performance risk handling strategies. The performance risk code information records the number of first candidate risk code segments with performance risks, as well as the specific location corresponding to each first candidate risk code segment. In addition, the performance risk code information also records the specific performance risk information corresponding to the first candidate risk code segment.

[0097] For example, the target code processing model can include a code performance analysis sub-model. Based on the code performance analysis sub-model, static code performance analysis can be performed on the initial front-end code to obtain code performance risk information corresponding to the initial front-end code.

[0098] The code performance analysis sub-model can be obtained by training the base model. Specifically, the base model can be trained using the first sample front-end code and the corresponding sample code performance risk information. The base model outputs reference code performance risk information for the first sample front-end code. Based on the reference code performance risk information and the sample code performance risk information, a first model loss function is constructed. The first model loss value corresponding to the first model loss function in the current training round is determined. The model parameters of the base model are adjusted using the first model loss value until the base model completes training and the code performance analysis sub-model is obtained.

[0099] For example, static code performance analysis of the initial front-end code based on the code performance analysis sub-model can identify performance bottlenecks such as complex DOM (Document Object Model) operations, synchronous network requests, and blocking computations.

[0100] S404: Based on the target code processing big model, perform static code security analysis on the initial front-end code to obtain code security risk information corresponding to the initial front-end code.

[0101] The code security risk information includes security risk code information and security risk handling strategies. The security risk code information records the number of second candidate risk code segments with security risks, as well as the specific location of each second candidate risk code segment. In addition, the security risk code information also records the specific security risk information corresponding to the second candidate risk code segment.

[0102] For example, the target code processing model can include a code security analysis sub-model. Based on the code security analysis sub-model, static code security analysis can be performed on the initial front-end code to obtain code security risk information corresponding to the initial front-end code.

[0103] The code security analysis sub-model can be obtained by training the base model. Specifically, the base model can be trained using the second sample front-end code and the corresponding sample code security risk information. The base model outputs reference code security risk information for the second sample front-end code. Based on the reference code security risk information and the sample code security risk information, a second model loss function is constructed. The second model loss value corresponding to the second model loss function in the current training round is determined. The model parameters of the base model are adjusted using the second model loss value until the base model completes training and the code security analysis sub-model is obtained.

[0104] For example, by performing static analysis of the initial front-end code from ten years ago based on the code security analysis sub-model, it is possible to identify code security vulnerabilities that do not encrypt user input and pose a risk of code injection.

[0105] S406: Based on code performance risk information and code security risk information, determine the risk code information corresponding to the initial front-end code.

[0106] Specifically, code performance risk information refers to risky code that poses a performance risk, while code security risk information refers to risky code that poses a security risk. Therefore, code performance risk information and code security risk information are different types of risky code information, and these two types can be used to determine the risky code information corresponding to the initial front-end code.

[0107] In the embodiments provided in this application, code performance risk information corresponding to the initial front-end code is determined by static code performance analysis, and code security risk information corresponding to the initial front-end code is determined by static code security analysis. Thus, the risk code information corresponding to the initial front-end code is determined by using the code performance risk information and the code security risk information, so that the risk code information can characterize the security risk and performance risk of the initial front-end code.

[0108] Please see Figure 5 , Figure 5 This is a flowchart illustrating a method for determining a target risk code segment, as provided in an embodiment of this application. Figure 5 As shown, S204 identifies target risky code segments in the initial front-end code based on code risk information, including:

[0109] S502: Determine the risk code information corresponding to the code risk information, and determine the candidate risk code segments in the initial front-end code based on the risk code information.

[0110] Since the number of risk codes and risk handling strategies associated with each other in the code risk information can be one or more pairs, each risk code in the code risk information can be identified. Furthermore, since the risk code information records the corresponding candidate risk code segments, all candidate risk code segments in the initial front-end code can be determined using each risk code information.

[0111] S504: Determine the risk code segment selection strategy for candidate risk code segments, and determine the target risk code segment from the candidate risk code segments based on the risk code segment selection strategy.

[0112] This process involves pushing candidate risk code segments and their corresponding risk information to the user interface for selection. After the user makes a selection, a risk code segment selection strategy is generated based on the user's choice. The target risk code segment is then determined from the candidate risk code segments using this strategy. The target risk code segment is, as the name suggests, the candidate risk code segment selected by the user.

[0113] Of course, the risk level corresponding to the candidate risk code segment can also be identified. Candidate risk code segments with a risk level greater than or equal to a preset risk level are selected as candidate risk code segments. Then, a risk code segment selection strategy is generated based on the selected candidate risk code segments, and the target risk code segment is determined based on the risk code segment selection strategy. It is easy to understand that the higher the risk level, the greater the risk of the candidate risk code segment.

[0114] In the embodiments provided in this application, candidate risky code segments in the initial front-end code are determined by risky code information. Then, a risky code segment selection strategy is determined for the candidate risky code segments, and the target risky code segment is determined from the candidate risky code segments using the risky code segment selection strategy, thereby determining the code segment that needs to be optimized.

[0115] Please see Figure 6 , Figure 6 This is a schematic diagram illustrating a process for determining an intermediate representation of a target, provided as an embodiment of this application. For example... Figure 6 As shown, in S204, code risk information is used to perform intermediate representation optimization processing on the target risk code segment to obtain the target intermediate representation corresponding to the target risk code segment, including:

[0116] S602: Determine the risk code information corresponding to the target risk code segment, and determine the risk handling strategy corresponding to the risk code information based on the code risk information.

[0117] Specifically, after identifying the target risk code segment, the risk code information corresponding to the target risk code segment is queried from the code risk information. Then, the risk handling strategy associated with the risk code information is determined, thereby obtaining the risk handling strategy corresponding to the risk code information.

[0118] S604: Determine the initial intermediate representation corresponding to the target risk code segment, and perform intermediate representation optimization processing on the initial intermediate representation based on the risk processing strategy to obtain the target intermediate representation corresponding to the target risk code segment.

[0119] After identifying the target risk code segment, an intermediate representation transformation is performed on the target risk code segment to obtain the initial intermediate representation corresponding to the target risk code segment. Then, a risk handling strategy is used to optimize the initial intermediate representation to obtain the target intermediate representation corresponding to the target risk code segment. This optimization includes, but is not limited to, merging similar code, eliminating redundant code, and patching security vulnerabilities, thereby simplifying code logic, reducing unnecessary calculations, or improving code security.

[0120] In the embodiments provided in this application, by determining the risk handling strategy corresponding to the target risk code segment, the target risk code segment is converted into an initial intermediate representation. Then, the risk handling strategy is used to perform intermediate representation optimization processing on the initial intermediate representation to obtain the target intermediate representation, thereby specifically simplifying the code logic, reducing unnecessary calculations, or improving code security.

[0121] Please see Figure 7 , Figure 7 This is a schematic diagram illustrating a process for code testing of target front-end code, provided as an embodiment of this application. Figure 7 As shown, after obtaining the target front-end code in S206, the method further includes:

[0122] S702: Perform code testing on the current target front-end code in the code testing environment to determine the test score value corresponding to the current target front-end code.

[0123] Specifically, the target front-end code is run in the code testing environment to perform the corresponding target task, and the runtime and memory usage information of the target front-end code are obtained. Then, the test score value of the target front-end code is generated using the runtime and memory usage information.

[0124] S704: If the test score value corresponding to the current target front-end code is less than the preset test score value, the risk code segment selection strategy will be adjusted based on the test score value corresponding to the current target front-end code to update the risk code segment selection strategy.

[0125] Among them, the preset test score value is obtained. When the test score value corresponding to the current target front-end code is less than the preset test score value, it indicates that the current target front-end code still needs further optimization. Therefore, the score difference between the test score value and the preset test score value can be calculated, and the risk code segment selection strategy can be adjusted using the score difference.

[0126] For example, when the prior risk code segment selection strategy is determined based on the risk level corresponding to the candidate risk code segment and the preset risk level, the preset risk level can be lowered accordingly based on the score difference, thereby updating the preset risk level. Similarly, candidate risk code segments with a risk level greater than or equal to the preset risk level can be selected as candidate risk code segments. Then, the current risk code segment selection strategy is generated based on the selected candidate risk code segments, thereby updating the risk code segment selection strategy.

[0127] S706: The steps to determine the target risk code segment from the candidate risk code segments by performing a risk code segment selection strategy.

[0128] The process involves several steps. After updating the risk code segment selection strategy, step S504 is executed to determine the target risk code segment from the candidate risk code segments based on the risk code segment selection strategy. Next, step S204 is executed to optimize the intermediate representation of the target risk code segment using code risk information to obtain the target intermediate representation corresponding to the target risk code segment. Then, step S206 is executed to generate the target bytecode corresponding to the target intermediate representation, and to replace the target risk code segment in the initial front-end code based on the target bytecode to obtain the target front-end code. Finally, step S702 is executed again. Detailed descriptions of each step are omitted here.

[0129] S708: If the test score value corresponding to the current target front-end code is greater than or equal to the preset test score value, then the target front-end code is determined to have passed the code test.

[0130] Specifically, when the test score value corresponding to the current target front-end code is greater than or equal to the preset test score value, it indicates that the current target front-end code has been optimized, and therefore it can be determined that the target front-end code has passed the code test.

[0131] For example, when the target front-end code passes code testing, the code deployment information associated with the initial front-end code is obtained; the target front-end code is then deployed based on this information. Here, the code deployment information can be the code deployment location within the web application corresponding to the initial front-end code. After determining the code deployment information, the target front-end code is deployed to the corresponding code deployment location to replace the initial front-end code, thereby significantly improving the performance of the web application and providing users with a near-native experience.

[0132] In the embodiments provided in this application, the target risky code segment is continuously adjusted by continuously adjusting the risky code segment selection strategy, thereby continuously adjusting the optimization strategy for the initial front-end code. When the test score value corresponding to the current target front-end code is greater than or equal to the preset test score value, it indicates that the current target front-end code has been optimized, and thus it can be determined that the target front-end code has passed the code test.

[0133] Please see Figure 8 , Figure 8 This is a flowchart illustrating a process for determining the test score value corresponding to the current target front-end code, provided as an embodiment of this application. Figure 8 As shown, S702 determines the test score value corresponding to the current target front-end code, including:

[0134] S802: Obtain the runtime information and memory usage information corresponding to the current target front-end code, determine the first characterization value corresponding to the runtime information, and determine the second characterization value corresponding to the memory usage information.

[0135] Specifically, the target front-end code is run in the code testing environment to execute the corresponding target task, and the runtime and memory usage information of the target front-end code are obtained.

[0136] Obtain a first mapping table between runtime and corresponding representation parameters, and query the first representation value of runtime corresponding to the runtime information based on the first mapping table. Obtain a second mapping table between memory usage distribution information and corresponding representation parameters, and query the second representation value corresponding to the memory usage distribution information in the memory usage information based on the second mapping table. Here, the memory usage distribution information is the memory usage information that changes over time.

[0137] S804: Determine the first weight corresponding to the runtime information and the second weight corresponding to the memory usage information; wherein the sum of the first weight and the second weight is 1.

[0138] This allows setting a first weight and a second weight based on user needs. When users prioritize code runtime, the first weight can be set higher than the second weight; when users prioritize memory usage, the second weight can be set higher than the first weight. When users value both code runtime and memory usage equally, the first weight can be set equal to the second weight. Simply put, the first weight is greater than or equal to 0 and less than or equal to 1, and the second weight is greater than or equal to 0 and less than or equal to 1.

[0139] S806: The first and second representation values ​​are weighted and summed based on the first and second weights to obtain the test score value corresponding to the current target front-end code.

[0140] When the first weight is α, the second weight is γ, the first representation value is x, and the second representation value is y, the weighted summation of the first and second representation values ​​based on the first and second weights can be expressed as α×x+γ×y, thus obtaining the corresponding test score value Z, i.e. Z=α×x+γ×y.

[0141] In the embodiments provided in this application, a first representation value corresponding to runtime information is determined, a second representation value corresponding to memory usage information is determined, and a first weight corresponding to runtime information and a second weight corresponding to memory usage information are obtained. Then, the first representation value and the second representation value are weighted and summed based on the first weight and the second weight to obtain the test score value corresponding to the current target front-end code.

[0142] Please see Figure 9 , Figure 9 This is a schematic diagram of the structure of a code processing device provided in an embodiment of this application. Figure 9 As shown, the code processing device 900 includes:

[0143] Module 910 is suitable for acquiring initial front-end code and using the target code processing model to perform code analysis and processing on the initial front-end code to obtain code risk information.

[0144] The processing module 920 is adapted to determine the target risk code segment in the initial front-end code based on code risk information, and to perform intermediate representation optimization processing on the target risk code segment using code risk information to obtain the target intermediate representation corresponding to the target risk code segment.

[0145] The generation module 930 is adapted to generate the target bytecode corresponding to the target intermediate representation, and to replace the target risk code segment in the initial front-end code based on the target bytecode to obtain the target front-end code.

[0146] Optionally, the acquisition module 910 includes:

[0147] The static analysis unit is suitable for performing static code analysis on the initial front-end code based on the target code processing large model to obtain risk code information corresponding to the initial front-end code.

[0148] The risk handling strategy determination unit is suitable for using the target code processing large model to process the risk code information to generate risk handling strategies, thereby obtaining risk handling strategies for the risk code information.

[0149] The code risk information determination unit is suitable for obtaining code risk information based on risky code information and risk handling strategies.

[0150] Optionally, the static analysis unit includes:

[0151] The code performance static analysis subunit is suitable for performing static code performance analysis on the initial front-end code based on the target code processing large model, and obtaining code performance risk information corresponding to the initial front-end code.

[0152] The code security static analysis subunit is suitable for performing code security static analysis on the initial front-end code based on the target code processing large model, and obtaining code security risk information corresponding to the initial front-end code.

[0153] The risk code information determination subunit is suitable for determining the risk code information corresponding to the initial front-end code based on code performance risk information and code security risk information.

[0154] Optionally, the processing module 920 includes:

[0155] The candidate risk code segment determination unit is suitable for determining each risk code information corresponding to the code risk information, and determining the candidate risk code segments in the initial front-end code based on the risk code information.

[0156] The target risk code segment determination unit is adapted to determine a risk code segment selection strategy for candidate risk code segments, and to determine the target risk code segment from the candidate risk code segments based on the risk code segment selection strategy.

[0157] Optionally, the processing module 920 includes:

[0158] The risk handling strategy determination unit is suitable for determining the risk code information corresponding to the target risk code segment, and determining the risk handling strategy corresponding to the risk code information based on the code risk information.

[0159] The target intermediate representation determination unit is suitable for determining the initial intermediate representation corresponding to the target risk code segment, and performing intermediate representation optimization processing on the initial intermediate representation based on the risk processing strategy to obtain the target intermediate representation corresponding to the target risk code segment.

[0160] Optionally, the code processing device 900 further includes:

[0161] The testing module is suitable for testing the current target front-end code in a code testing environment and determining the test score value corresponding to the current target front-end code.

[0162] The first execution module is adapted to adjust the risk code segment selection strategy based on the test score value corresponding to the current target front-end code if the test score value corresponding to the current target front-end code is less than the preset test score value, so as to update the risk code segment selection strategy.

[0163] The steps for determining the target risk code segment from candidate risk code segments based on a risk code segment selection strategy;

[0164] The second execution module is adapted to determine that the target front-end code passes the code test if the test score value corresponding to the current target front-end code is greater than or equal to the preset test score value.

[0165] Optionally, the code processing device 900 further includes:

[0166] The code deployment information determination module is suitable for obtaining the code deployment information associated with the initial front-end code when the target front-end code passes the code test.

[0167] The deployment module is suitable for deploying target front-end code based on code deployment information.

[0168] Optionally, the test module includes:

[0169] The characterization value determination unit is adapted to obtain runtime information and memory usage information corresponding to the current target front-end code, determine the first characterization value corresponding to the runtime information, and determine the second characterization value corresponding to the memory usage information.

[0170] The weight determination unit is adapted to determine the first weight corresponding to runtime information and the second weight corresponding to memory usage information; wherein the sum of the first weight and the second weight is 1.

[0171] The test score determination unit is adapted to perform a weighted summation of the first representation value and the second representation value based on the first weight and the second weight to obtain the test score value corresponding to the current target front-end code.

[0172] Optionally, the generation module 930 is also adapted to compile the target intermediate representation to obtain the target bytecode.

[0173] Please see Figure 10 , Figure 10 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application. Figure 10 As shown, terminal 1000 may include: at least one processor 1001, at least one network interface 1004, user interface 1003, memory 1005, and at least one communication bus 1002.

[0174] The communication bus 1002 is used to realize the connection and communication between these components.

[0175] The user interface 1003 may include a display screen and a camera. Optionally, the user interface 1003 may also include a standard wired interface and a wireless interface.

[0176] The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).

[0177] The processor 1001 may include one or more processing cores. The processor 1001 connects to various parts within the terminal 1000 using various interfaces and lines, and performs various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 1005, and by calling data stored in the memory 1005. Optionally, the processor 1001 may be implemented using at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 1001 may integrate one or more of the following: CPU (Central Processing Unit), GPU (Graphics Processing Unit), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content to be displayed on the screen; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 1001 and may be implemented as a separate chip.

[0178] The memory 1005 may include RAM (Random Access Memory) or ROM (Read-Only Memory). Optionally, the memory 1005 may include a non-transitory computer-readable storage medium. The memory 1005 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 1005 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001. Figure 10 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a code processing program.

[0179] exist Figure 10In the terminal 1000 shown, the user interface 1003 is mainly used to provide an input interface for the user and to obtain the user's input data; while the processor 1001 can be used to call the code processing program stored in the memory 1005 and specifically perform the following operations:

[0180] Obtain the initial front-end code, and use the target code processing model to perform code analysis on the initial front-end code to obtain code risk information;

[0181] Based on code risk information, target risk code segments in the initial front-end code are identified. The intermediate representation of the target risk code segments is then optimized using the code risk information to obtain the target intermediate representation corresponding to the target risk code segments.

[0182] The target intermediate representation is generated to correspond to the target bytecode. Based on the target bytecode, the target risk code segment in the initial front-end code is replaced to obtain the target front-end code.

[0183] Optionally, when processor 1001 executes code analysis processing on the initial front-end code using the target code processing large model to obtain code risk information, it specifically performs the following:

[0184] Based on the target code processing big model, static code analysis is performed on the initial front-end code to obtain risk code information corresponding to the initial front-end code;

[0185] The target code processing model is used to process the risk code information to generate risk processing strategies, resulting in risk processing strategies for the risk code information.

[0186] Code risk information is obtained based on risk code information and risk handling strategies.

[0187] Optionally, when processor 1001 performs static code analysis on the initial front-end code based on the target code processing model to obtain risk code information corresponding to the initial front-end code, it specifically executes:

[0188] Based on the target code processing big model, static code performance analysis is performed on the initial front-end code to obtain code performance risk information corresponding to the initial front-end code;

[0189] Based on the target code processing big model, static code security analysis is performed on the initial front-end code to obtain code security risk information corresponding to the initial front-end code;

[0190] Based on code performance risk information and code security risk information, the risk code information corresponding to the initial front-end code is determined.

[0191] Optionally, when processor 1001 executes the target risk code segment determined in the initial front-end code based on code risk information, it specifically executes:

[0192] Identify the risk code information corresponding to the code risk information, and determine the candidate risk code segments in the initial front-end code based on the risk code information;

[0193] Determine the risk code segment selection strategy for candidate risk code segments, and determine the target risk code segment from the candidate risk code segments based on the risk code segment selection strategy.

[0194] Optionally, when the processor 1001 performs intermediate representation optimization processing on the target risk code segment using code risk information to obtain the target intermediate representation corresponding to the target risk code segment, the specific execution is as follows:

[0195] Determine the risk code information corresponding to the target risk code segment, and determine the risk handling strategy corresponding to the risk code information based on the code risk information;

[0196] Determine the initial intermediate representation corresponding to the target risk code segment, and perform intermediate representation optimization processing on the initial intermediate representation based on the risk processing strategy to obtain the target intermediate representation corresponding to the target risk code segment.

[0197] Optionally, after obtaining the target front-end code, the processor 1001 executes the following:

[0198] In the code testing environment, perform code testing on the current target front-end code to determine the test score value corresponding to the current target front-end code;

[0199] If the test score value corresponding to the current target front-end code is less than the preset test score value, the risk code segment selection strategy will be adjusted based on the test score value corresponding to the current target front-end code to update the risk code segment selection strategy.

[0200] The steps for determining the target risk code segment from candidate risk code segments based on a risk code segment selection strategy;

[0201] If the test score value corresponding to the current target front-end code is greater than or equal to the preset test score value, then the target front-end code is determined to have passed the code test.

[0202] Alternatively, the processor 1001 is also adapted to perform:

[0203] When the target front-end code passes code testing, obtain the code deployment information associated with the initial front-end code;

[0204] Deploy the target front-end code based on the code deployment information.

[0205] Optionally, when processor 1001 determines the test score value corresponding to the current target front-end code, it specifically executes:

[0206] Obtain the runtime and memory usage information corresponding to the current target front-end code, determine the first representation value corresponding to the runtime information, and determine the second representation value corresponding to the memory usage information;

[0207] Determine the first weight corresponding to runtime information and the second weight corresponding to memory usage information; wherein the sum of the first weight and the second weight is 1.

[0208] The first and second representation values ​​are weighted and summed based on the first and second weights to obtain the test score value corresponding to the current target front-end code.

[0209] Optionally, when the processor 1001 executes the execution of the target bytecode corresponding to the target intermediate representation, it specifically performs the following: compiling the target intermediate representation to obtain the target bytecode.

[0210] This application also provides a computer-readable storage medium that stores one or more programs that, when executed by a processor, implement the method described in any one of the above-described embodiments.

[0211] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0212] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0213] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module.

[0214] If the integrated module is implemented as a software functional module 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 this application embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0215] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments of this application.

[0216] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0217] The above is a description of a code processing method, apparatus, terminal, and computer-readable storage medium provided in the embodiments of this application. For those skilled in the art, based on the ideas of the embodiments of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation on the embodiments of this application.

Claims

1. A code processing method, wherein, The method includes: Obtain the initial front-end code, and use the target code processing model to perform code analysis on the initial front-end code to obtain code risk information; Based on the code risk information, the target risk code segment in the initial front-end code is determined, and the intermediate representation optimization processing of the target risk code segment is performed using the code risk information to obtain the target intermediate representation corresponding to the target risk code segment; Generate the target bytecode corresponding to the target intermediate representation, and replace the target risk code segment in the initial front-end code based on the target bytecode to obtain the target front-end code.

2. The method according to claim 1, wherein, The initial front-end code is analyzed using a target code processing model to obtain code risk information, including: Based on the target code processing big model, static code analysis is performed on the initial front-end code to obtain the risk code information corresponding to the initial front-end code; The target code processing model is used to generate risk processing strategies for the risk code information, thereby obtaining risk processing strategies for the risk code information. Code risk information is obtained based on the risk code information and the risk handling strategy.

3. The method according to claim 2, wherein, The step of performing static code analysis on the initial front-end code based on the target code processing big model to obtain risk code information corresponding to the initial front-end code includes: Based on the target code processing big model, static code performance analysis is performed on the initial front-end code to obtain code performance risk information corresponding to the initial front-end code; Based on the target code processing big model, static code security analysis is performed on the initial front-end code to obtain code security risk information corresponding to the initial front-end code; Based on the code performance risk information and the code security risk information, the risk code information corresponding to the initial front-end code is determined.

4. The method according to claim 2, wherein, The step of determining the target risk code segment in the initial front-end code based on the code risk information includes: Determine the risk code information corresponding to the code risk information, and determine the candidate risk code segments in the initial front-end code based on the risk code information; Determine a risk code segment selection strategy for the candidate risk code segments, and determine the target risk code segment from the candidate risk code segments based on the risk code segment selection strategy.

5. The method according to claim 4, wherein, The step of using the code risk information to perform intermediate representation optimization processing on the target risk code segment to obtain the target intermediate representation corresponding to the target risk code segment includes: Determine the risk code information corresponding to the target risk code segment, and determine the risk handling strategy corresponding to the risk code information based on the code risk information; Determine the initial intermediate representation corresponding to the target risk code segment, and perform intermediate representation optimization processing on the initial intermediate representation based on the risk processing strategy to obtain the target intermediate representation corresponding to the target risk code segment.

6. The method according to claim 4, wherein, After obtaining the target front-end code, the method further includes: In the code testing environment, perform code testing on the current target front-end code to determine the test score value corresponding to the current target front-end code; If the test score value corresponding to the current target front-end code is less than the preset test score value, the risk code segment selection strategy is adjusted based on the test score value corresponding to the current target front-end code to update the risk code segment selection strategy. Perform the step of determining the target risk code segment from the candidate risk code segments based on the risk code segment selection strategy; If the test score value corresponding to the current target front-end code is greater than or equal to the preset test score value, then the target front-end code is determined to have passed the code test.

7. The method according to claim 6, wherein, The method further includes: When it is determined that the target front-end code passes the code test, the code deployment information associated with the initial front-end code is obtained; The target front-end code is deployed based on the code deployment information.

8. A code processing apparatus, wherein, The device includes: The acquisition module is suitable for acquiring initial front-end code and using a target code processing model to perform code analysis on the initial front-end code to obtain code risk information. The processing module is adapted to determine the target risk code segment in the initial front-end code based on the code risk information, and to perform intermediate representation optimization processing on the target risk code segment using the code risk information to obtain the target intermediate representation corresponding to the target risk code segment; The generation module is adapted to generate the target bytecode corresponding to the target intermediate representation, and to replace the target risk code segment in the initial front-end code based on the target bytecode to obtain the target front-end code.

9. A terminal, wherein, The terminal includes: Processor; and A memory configured to store computer-executable instructions, which, when executed, cause the processor to perform the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, wherein, The computer-readable storage medium stores one or more programs that, when executed by a processor, implement the method of any one of claims 1 to 7.