Script processing method and device, electronic equipment and readable storage medium
By loading user-generated scripts into a sandbox environment and running them on the server of the network service platform, the problem of long function development cycles in existing technologies is solved, enabling the rapid deployment of user-required functions.
Patent Information
- Application Number
- CN202211676354.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-26
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2042-12-26
AI Technical Summary
Existing online service platforms suffer from long development cycles and slow deployment when facing users' specific needs, requiring lengthy processes such as complex requirement clarification, solution formulation, development coding, and functional testing and verification.
In the server of the network service platform, the target script generated by the user is stored in a specified path and loaded into a preset sandbox environment for execution. The sandbox environment is isolated from the main resource environment and executes the operations defined by the target script.
By running user-programmed scripts in a sandbox environment, the development process for user-required features is simplified, the development cycle is shortened, and the features needed by users can be launched quickly.
Smart Images

Figure CN116225397B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of information technology, and particularly relates to a script processing method and device, an electronic device and a readable storage medium. BACKGROUND
[0002] A network service platform provides network resource services such as media resources and educational resources for Internet clients based on Internet technology. The existing network service platform is usually configured with general functions such as response body rewriting, request header processing and basic anti-theft link, and meets the basic needs of users of the network service platform through function matching.
[0003] However, the existing network service platform needs to establish a new development task to meet the special needs of users such as customized services, which generally includes complex and lengthy processes such as requirement clarification, scheme formulation, development coding, function testing and verification. Therefore, the existing network service platform has the problem of long development cycle and slow online of functions for user needs. SUMMARY
[0004] The present application provides a script processing method, device, electronic device and readable storage medium to solve the problem of long development cycle and slow online of functions for user needs of the existing network service platform.
[0005] To solve the above technical problems, the present application is implemented as follows:
[0006] In a first aspect, the present application provides a script processing method applied to a server of a network service platform, the method comprising:
[0007] storing a target script to a specified path; the target script being a script programmed by a user of the server;
[0008] loading the target script from the specified path to a preset sandbox environment of the server; the sandbox environment being isolated from a main resource environment in the server;
[0009] running the target script in the sandbox environment to perform an operation defined by the target script.
[0010] Optionally, the running the target script in the sandbox environment to perform an operation defined by the target script comprises:
[0011] running the target script in the sandbox environment to send a target resource specified by a client request to the client in response to the client request; the client request being a request submitted by the client to the server.
[0012] Optionally, the target script comprises a global task script and a request and response processing script; and the running of the target script in the sandbox environment comprises:
[0013] In the case that the server performs initialization, running the global task script in the sandbox environment to perform an initialization task defined by the global task script, performing a timing task defined by the global task script according to a preset time, and obtaining an execution result of the global task script;
[0014] Running the request and response processing script in the sandbox environment to send a target resource specified by the client request to the client according to the execution result in response to the client request.
[0015] Optionally, the server comprises a shared memory, and the sandbox environment comprises a built-in interface; after the loading of the target script from the specified path into the preset sandbox environment of the server, the method further comprises:
[0016] allocating a corresponding memory for the target script from the shared memory as a target memory;
[0017] The sending of the target resource specified by the client request to the client according to the execution result in response to the client request comprises:
[0018] In response to the client request, sending the target resource specified by the client request to the client based on the execution result, the built-in interface and the target memory.
[0019] Optionally, the execution result comprises an access rule of the server; and the sending of the target resource specified by the client request to the client based on the execution result, the built-in interface and the target memory comprises:
[0020] performing a first security verification on the client request according to the access rule to obtain a first verification result;
[0021] In the case that the first verification result indicates that the client request conforms to the access rule of the server, accessing the target memory through the built-in interface, and sending the target resource to the client based on a resource in the target memory.
[0022] Optionally, the execution result comprises a network address of an authentication server corresponding to the server; and the sending of the target resource specified by the client request to the client based on the execution result, the built-in interface and the target memory comprises:
[0023] sending a security verification instruction to the authentication server according to the network address of the authentication server; the security verification instruction comprises the client request, and is used to instruct the authentication server to perform second security verification on the client request and return a second verification result generated by the authentication server to the server;
[0024] in a case where the second verification result indicates that the client request meets the access rule of the server, accessing the target memory through the built-in interface, and sending the target resource to the client based on the resource in the target memory.
[0025] Optionally, the execution result further comprises a network address of a source server corresponding to the server; and the sending of the target resource to the client based on the resource in the target memory comprises:
[0026] in a case where the target resource exists in the resource in the target memory, directly sending the target resource in the target memory to the client;
[0027] in a case where the target resource does not exist in the resource in the target memory, sending a resource acquisition instruction to the source server according to the network address of the source server; the resource acquisition instruction is used to instruct the source server to send the target resource to the server, so that the server stores the target resource in the target memory; and after the server stores the target resource in the target memory, the target resource in the target memory is sent to the client.
[0028] Optionally, the allocating of the corresponding memory in the shared memory to the target script as the target memory comprises:
[0029] accessing a shared memory of the server through the built-in interface, and selecting a currently idle memory area from the shared memory;
[0030] obtaining a target identifier corresponding to the selected memory area, and establishing an address mapping between the target script and the memory area corresponding to the target identifier according to the target identifier, so as to allocate the memory area corresponding to the target identifier to the target script as the target memory.
[0031] Optionally, after the running of the target script in the sandbox environment, the method further comprises:
[0032] capturing a running abnormal result of the target script through the sandbox environment, and performing a specified operation based on the running abnormal result;
[0033] releasing the target memory corresponding to the target script, so that the server allocates the target memory to scripts of other users.
[0034] Optionally, the executing a specified operation based on the running exception result comprises:
[0035] analyzing the running exception result to determine whether the running exception result meets a preset reporting condition;
[0036] generating an error log based on the running exception result through the sandbox environment in a case where the reporting condition is met;
[0037] sending the error log to a log processing component for feedback to a user by the log processing component.
[0038] Optionally, the running exception result comprises a code error and / or an interface calling error of the target script; and the generating an error log based on the running exception result through the sandbox environment comprises:
[0039] generating an error log based on a preset script rule and the code error and / or the interface calling error through the sandbox environment; the script rule comprises a code syntax rule and an interface calling rule.
[0040] Optionally, after the running the request and response processing script in the sandbox environment, the method further comprises:
[0041] obtaining a processing result of the request and response processing script for the client request;
[0042] generating an access log of the client accessing the server this time based on the processing result, and storing the access log to a specified area.
[0043] In a second aspect, the present application provides a script processing device applied to a server of a network service platform, the device comprising:
[0044] a storage module configured to store a target script to a specified path; the target script is a script programmed by a user of the server;
[0045] a loading module configured to load the target script from the specified path to a preset sandbox environment of the server; the sandbox environment is isolated from a main resource environment in the server;
[0046] a running module configured to run the target script in the sandbox environment to execute an operation defined by the target script.
[0047] In a third aspect, the present application provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the script processing method when executing the program.
[0048] In a fourth aspect, the present application provides a readable storage medium, when the instructions in the storage medium are executed by the processor of an electronic device, the electronic device can execute the script processing method.
[0049] In the embodiments of the present application, the target script is stored in a specified path, the target script is loaded into a preset sandbox environment of a server from the specified path, and the target script is run in the sandbox environment to execute the operation defined by the target script. In this way, since the target script is a script generated by user programming for the server, the function of user self-programming can be realized by running the target script, thereby meeting the needs of the user.
[0050] Compared with the prior art, the operation of developing the function to meet the needs of the user can be realized by relying on the network service platform, and the complex processes such as clarification of needs and acceptance of functions between the user and the network service platform can be avoided in order to realize the function to meet the needs of the user, thereby shortening the development cycle of the function. The target script generated by user programming is loaded into the sandbox environment of the server to run, so as to realize the function to meet the needs of the user, thereby quickly putting the function required by the user online on the network service platform. BRIEF DESCRIPTION OF DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can also obtain other drawings according to these drawings without creative labor.
[0052] Figure 1 is a step flowchart of a script processing method provided by an embodiment of the present application;
[0053] Figure 2 is an application scenario diagram of a script processing method provided by an embodiment of the present application;
[0054] Figure 3 is an architecture level diagram of a network server provided by an embodiment of the present application;
[0055] Figure 4 is a flowchart of another script processing method provided by an embodiment of the present application;
[0056] Figure 5 is a structural diagram of a script processing device provided by an embodiment of the present application;
[0057] Figure 6 is a structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0058] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0059] Figure 1 is a step flowchart of a script processing method provided by an embodiment of the present application, as shown in the figure, the script processing method is applied to a server of a network service platform, and the method can include the following steps. Figure 1
[0060] In step S1, a target script is stored to a specified path; the target script is a script programmed by a user of the server.
[0061] In the embodiments of the present application, the user of the network service platform can program based on the programming language supported by the server, and generate a script that can realize the function required by the user. It should be noted that the script is an executable file written in a specific descriptive language and according to a certain format. The server can be a server supporting Lua script language, and a large number of Lua libraries are integrated in the server, which can realize the running of the script written based on Lua in the server. The specified path can be a special path allocated by the server for the user in advance, which is used to store the script issued by the user.
[0062] Optionally, the network service platform of the embodiments of the present application can be a content delivery network (CDN) service platform. The CDN service platform can make the network user obtain the required content nearby through the intelligent virtual network composed of the node servers placed at various places in the network, solve the network congestion, and improve the response speed of the network user accessing the website. The CDN service platform is used to provide network resource service for the client accessing the server of the CDN service platform. Alternatively, the network service platform of the embodiments of the present application can be a database service platform, which is used to provide transaction processing and data access service for the client accessing the database server of the database service platform.
[0063] In the embodiment, a user of a server of a network service platform can issue a target script to the server, and the server can send the target script to a designated path pre-assigned to the user, i.e., a specified path, for storage, so that the target script can be found by searching the specified path.
[0064] In step S2, the target script is loaded from the specified path to a preset sandbox environment of the server; the sandbox environment is isolated from a main resource environment in the server.
[0065] In the embodiment, a sandbox environment for running a user script is pre-set in the server, so that the running environment of the user script is isolated from a main resource environment in the server. It should be noted that a sandbox is a virtual execution environment, and a program running in the sandbox cannot have a permanent impact on a hard disk, so the user script can be isolated from the server.
[0066] In the embodiment, the target script can be found and obtained by searching the specified path, the server loads the target script and loads the target script into the preset sandbox environment, and waits for the script to be executed in the sandbox environment.
[0067] In step S3, the target script is run in the sandbox environment to perform an operation defined by the target script.
[0068] In the embodiment, the sandbox environment can include pre-set interfaces and functions, and the target script is run in the sandbox environment, so that the functions represented by the code in the target script can be executed by calling the interfaces and functions in the sandbox environment, thereby implementing the operation defined by the target script.
[0069] In the embodiment, the target script is stored in the specified path, the target script is loaded from the specified path to the preset sandbox environment of the server, and the target script is run in the sandbox environment to perform the operation defined by the target script. In this way, since the target script is a script programmed by a user of the server, the function of user self-programming can be implemented by running the target script, thereby meeting the needs of the user.
[0070] Compared with the prior art, the operation of developing a function to meet the needs of the user by relying on a network service platform can avoid the complex processes of clarifying the needs, function acceptance, etc. between the user and the network service platform, so that the development cycle of the function can be shortened. The target script programmed by the user is loaded into the sandbox environment of the server to run, so that the function to meet the needs of the user is implemented, thereby quickly launching the function needed by the user on the network service platform.
[0071] Optionally, step S3 can include the following steps:
[0072] Step S31, running the target script in the sandbox environment to send the target resource specified by the client request to the client in response to the client request; the client request is a request submitted by the client to the server.
[0073] In the embodiment of the present application, the service object of the server is a network user, and the server can provide corresponding network resources according to the demand of the network user. The client refers to the terminal of the network user, which can be a personal computer, a mobile phone or other devices. When the network user needs a network resource such as an image, the client can send a request to the CDN, which can include the address of the client, the content of the requested resource, etc. This is only an example, and the embodiment of the present application does not limit this.
[0074] In the embodiment of the present application, by running the target script in the sandbox environment, the client request can be responded to, the data file generated according to the content of the resource requested by the client is taken as the target resource, and the target resource specified by the client request is sent to the client according to the address of the client.
[0075] In the embodiment of the present application, by running the target script in the sandbox environment, the request submitted by the client to the server can be responded to, the target resource specified by the client request is sent to the client, and thus the network content service is provided for the client based on the target script running in the sandbox environment of the server.
[0076] Optionally, the target script includes a global task script and a request and response processing script; step S31 can include the following steps:
[0077] Step S311, in the case that the server performs initialization, running the global task script in the sandbox environment to execute the initialization task defined by the global task script, execute the timing task defined by the global task script according to the preset time, and obtain the execution result of the global task script.
[0078] In the embodiment of the present application, the global task script is a script for executing global tasks, including initialization tasks and timing tasks. The initialization task is a task that needs to be executed when the server is initialized, and the timing task is a task that needs to be executed at a preset time. For example, the global task can include: periodically pulling the black and white list from a remote server, obtaining the network address of the source server, periodically synchronizing the variable data to the local data synchronization task, etc.
[0079] In the embodiment of the present application, when the server enters the process initialization stage, the global task script is run in the sandbox environment, and the server background daemon is accessed through the interface of the sandbox. The initialization task defined by the global task script is executed through the background daemon process to obtain the execution result of the initialization task, such as obtaining the network address of the source server. The timing task defined by the global task script is executed according to the preset time to obtain the execution result of the timing task, such as obtaining and updating the black and white list of the server.
[0080] In step S312, the request and response processing script is run in the sandbox environment to send the target resource specified by the client request to the client according to the execution result in response to the client request.
[0081] In the embodiment of the present application, the request and response processing script is used to respond to the client request and perform corresponding processing according to the client request. The request and response processing script can include a request processing part and a response processing part, which are used to perform request processing on the client request, such as anti-stealing link authentication, remote server authentication, and other security verification methods, and to perform response processing on the client request, such as request header rewriting, response content rewriting, and other operations. It should be noted that the request and response processing script is triggered by the client request, and the client request can be one or more. For any client request, the request and response processing script independently executes the processing logic in the script for the client request. For multiple client requests, the request and response processing script can concurrently execute the response processing logic.
[0082] In the embodiment of the present application, the server receives the client request, and responds to the client request by running the request and response processing script in the sandbox environment. According to the synchronization data in the execution result of the global task script, such as the black and white list and the network address of the source server, the request and response processing of the client request are performed to obtain the resource content requested by the client and generate a data file, which is the target resource specified by the client request. Then, the target resource is sent to the client according to the client address.
[0083] In the embodiment of the present application, the global task script is run in the sandbox environment to perform the initialization task defined by the global task script when the server performs initialization, and the timing task defined by the global task script is performed according to a preset time, and the execution result of the global task script is obtained; the request and response processing script is run in the sandbox environment to send the target resource specified by the client request to the client according to the execution result in response to the client request. In this way, the task that does not need to be triggered by the client request can be conveniently performed by the global task script, and the execution result of the global task can assist the request and response processing script in processing the client request, and therefore the processing efficiency of the client request can be improved.
[0084] Optionally, the server comprises a shared memory, and the sandbox environment comprises a built-in interface; after step S2, the method further comprises:
[0085] Step S4, allocating the corresponding memory in the shared memory for the target script as the target memory.
[0086] In the embodiment of the present application, the server comprises a large-capacity memory, which can be shared by the server body and the sandbox environment as a shared memory. The memory area used by different users can be set in the shared memory in advance. When the memory corresponding to the target script of any user is allocated, the memory address of the memory area of a preset size in the shared memory can be returned to the sandbox environment to establish address mapping for the target script of the user as the target memory of the target script, so that the target script can access the target memory through the sandbox environment.
[0087] Optionally, step S312 can comprise the following steps:
[0088] Step S3121, in response to the client request, sending the target resource specified by the client request to the client based on the execution result, the built-in interface and the target memory.
[0089] In the embodiment of the present application, the server receives the client request, and responds to the client request by running the request and response processing script in the sandbox environment. The client request is processed and responded to according to the synchronization data in the execution result of the global task script, and the shared memory of the server is accessed through the built-in interface of the sandbox environment to obtain the resource content requested by the client and generate a data file, that is, the target resource specified by the client request, and then the target resource is sent to the client according to the address of the client.
[0090] In the embodiment of the present application, the target memory is allocated for the target script from the shared memory; and the target resource specified by the client request is sent to the client based on the execution result, the built-in interface and the target memory in response to the client request. In this way, the client request can be responded based on the execution result, and the target resource specified by the client request can be obtained through the built-in interface and the target memory and sent to the client.
[0091] Optionally, the execution result comprises an access rule of the server; and step S3121 can comprise the following steps.
[0092] Step S3121a, performing first security verification on the client request according to the access rule to obtain a first verification result.
[0093] In the embodiment of the present application, the access rule of the server is used to represent whether a certain client is authorized to access the server, for example, whether a password is assigned to a user, whether a digital signature of the user is authenticated, etc. The client request can be authenticated according to the access rule, that is, it is verified whether the client submitting the client request has the right to access the server, that is, it is verified whether the client request is a secure access request.
[0094] Specifically, the access rule of the server can be a blacklist or a whitelist pulled from a remote server of the server by a global task script at a regular time. The client request can be first security verified through the blacklist or the whitelist to avoid that an unsafe access request is used to steal or attack the server. For example, if the Internet Protocol (IP) address of the client included in the client request is in the blacklist, it is concluded that the client request is unsafe. If the IP address of the client is not in the blacklist but in the whitelist, it is concluded that the client request is safe, and the client is allowed to access the server. The first verification result can comprise a verification conclusion of whether the client request has the right to access the server or whether the client request is a secure access request.
[0095] Step S3121b, in a case where the first verification result represents that the client request complies with the access rule of the server, the target memory is accessed through the built-in interface, and the target resource is sent to the client based on the resource in the target memory.
[0096] In the embodiment of the present application, in the case that the first verification result represents that the client request conforms to the access rule of the server, i.e., the client request is a secure access request, the server can perform response processing on the client request by running the response processing part in the request and response processing script in the sandbox environment, access the target memory allocated for the target script in the shared memory of the server through the built-in interface of the sandbox environment, obtain the resource content requested by the client in the target memory and generate a data file, the data file being the target resource specified by the client request, and then send the target resource to the client according to the client address.
[0097] In the embodiment of the present application, the first security verification is performed on the client request according to the access rule to obtain a first verification result, and in the case that the first verification result represents that the client request conforms to the access rule of the server, the target memory is accessed through the built-in interface and the target resource in the target memory is sent to the client. In this way, the target resource specified by the client request can be sent to the client only in the case that the client request is secure, thereby improving the security of the server and reducing the risk of theft or attack on the server by an unsafe access request.
[0098] Optionally, the execution result includes a network address of an authentication server corresponding to the server; and step S3121 can include the following steps.
[0099] Step S3121c, according to the network address of the authentication server, sending a security verification instruction to the authentication server; the security verification instruction including the client request, for instructing the authentication server to perform second security verification on the client request and returning a generated second verification result to the server.
[0100] In the embodiment of the present application, the authentication server is a remote server specially used for performing security verification on the request accessing the server, and the server can obtain the network address of the authentication server by running the initialization task in the global task script in the sandbox environment. The server receives the client request, performs response processing on the client request by running the request processing part in the request and response processing script in the sandbox environment, and sends a security verification instruction to the authentication server according to the network address of the authentication server.
[0101] The security verification instruction includes the client request. After receiving the security verification instruction, the authentication server acquires the client request in the security verification instruction in response to the security verification instruction, performs second security verification on the client request according to a preset authentication mode in the authentication server, generates a second verification result, and returns the second verification result to the server. Specifically, the preset authentication mode in the authentication server can be to acquire and decrypt the username and password in the client request, and compare and verify the decrypted username and password with a user database of the authentication server. If the username and password are correct, it indicates that the client request is a secure access request. If the username and password are incorrect, it indicates that the client request is not a secure access request. The second verification result can include a verification conclusion given by the authentication server that whether the client request has the access right of the server or whether the client request is a secure access request.
[0102] In a case where the second verification result indicates that the client request complies with the access rule of the server, the target memory is accessed through the built-in interface, and the target resource in the target memory is sent to the client based on the resource in the target memory.
[0103] In the embodiment of the application, in a case where the second verification result indicates that the client request complies with the access rule of the server, i.e., the client request is a secure access request, the server can perform response processing on the client request by running the response processing part in the request and response processing script in the sandbox environment, access the target memory allocated for the target script in the shared memory of the server through the built-in interface of the sandbox environment, acquire the resource content requested by the client in the target memory and generate a data file, the data file being the target resource specified by the client request, and then send the target resource to the client according to the client address.
[0104] In the embodiment of the application, the security verification instruction is sent to the authentication server according to the network address of the authentication server, the security verification instruction includes the client request, and is used to instruct the authentication server to perform second security verification on the client request and return a generated second verification result to the server. In a case where the second verification result indicates that the client request complies with the access rule of the server, the target memory is accessed through the built-in interface, and the target resource in the target memory is sent to the client. In this way, the target resource specified by the client request can be sent to the client only in a case where the client request is secure, so as to improve the security of the server and reduce the risk of theft or attack on the server by an insecure access request.
[0105] Optionally, the execution result further comprises a network address of a source server corresponding to the server; and the sending of the target resource to the client based on the resource in the target memory comprises:
[0106] In step S5, if the target resource exists in the resource in the target memory, the target resource in the target memory is directly sent to the client.
[0107] In the embodiment, the source server is a source station specially storing network resources, and the network resources in the server are obtained from the cache of the source server. The server can obtain the network address of the source server by running a global task script in a sandbox environment.
[0108] In the embodiment, if the target resource exists in the resource in the target memory, the resource content requested by the client in the target memory can be directly obtained and a data file is generated, the data file is the target resource specified by the client, and then the target resource is sent to the client according to the client address.
[0109] In step S6, if the target resource does not exist in the resource in the target memory, a resource obtaining instruction is sent to the source server according to the network address of the source server; the resource obtaining instruction is used to instruct the source server to send the target resource to the server, so that the server stores the target resource in the target memory; and after the server stores the target resource in the target memory, the target resource in the target memory is sent to the client.
[0110] In the embodiment, the server receives the client request, responds to the client request by running a request and response processing script in a sandbox environment, and in the case that the target resource specified by the client request does not exist in the target memory, a resource obtaining instruction can be sent to the source server according to the network address of the source server.
[0111] The resource obtaining instruction comprises the resource content specified by the client request, the source server receives the resource obtaining instruction, responds to the resource obtaining instruction, obtains the resource content specified by the client request in the resource obtaining instruction, generates a data file from the resource content specified by the client request, the data file is the target resource specified by the client request, and then the target resource and the client request are packaged and sent to the server. The server receives the data packet, stores the target resource in the target memory according to the client request in the data packet. After the server stores the target resource in the target memory, the target resource specified by the client request in the target memory can be obtained through a built-in interface, and then the target resource is sent to the client according to the client address.
[0112] In the embodiment of the present application, the target resource in the target memory is directly sent to the client if the target resource exists in the resources in the target memory; if the target resource does not exist in the resources in the target memory, a resource acquisition instruction is sent to the source server according to the network address of the source server; the resource acquisition instruction is used to instruct the source server to send the target resource to the server, so that the server stores the target resource in the target memory; after the target resource is stored in the target memory by the server, the target resource in the target memory is sent to the client. In this way, if the target resource specified by the client request does not exist in the resources in the target memory of the server, the target resource can be conveniently acquired from the source server, so that the server can provide the network content service for the client in response to the client request. If the target resource exists in the resources in the target memory, the target resource in the target memory is directly sent to the client, which can improve the rationality and practicability of the script processing method of the embodiment of the present application.
[0113] Optionally, the step S4 can include the following steps:
[0114] In step S41, the shared memory of the server is accessed through the built-in interface of the sandbox environment, and a currently idle memory area is selected from the shared memory.
[0115] In the embodiment of the present application, when the target script corresponding to any user is allocated, the shared memory of the server can be accessed through the built-in interface of the sandbox environment, and the currently idle memory area in the shared memory is determined. It can be understood that the currently idle memory area in the shared memory can be one or more. One memory area can be selected from the idle memory area, and the memory address of the memory area is obtained, wherein the largest memory area can be selected, or the selection can be made according to a preset size, and the embodiment of the present application does not limit this.
[0116] In step S42, the target identifier corresponding to the selected memory area is obtained, and an address mapping is established between the target script and the memory area corresponding to the target identifier according to the target identifier, so that the memory area corresponding to the target identifier is allocated to the target script as the target memory.
[0117] In the embodiment of the present application, the target identifier can be a memory address of the selected memory region in the shared memory. The memory address corresponding to the selected memory region can be obtained through the built-in interface and returned to the target script, so that the target script can access the memory region corresponding to the memory address through the built-in interface, that is, the address mapping between the target script and the memory region corresponding to the target identifier is established. When the target script runs in the sandbox environment and needs to access the shared memory of the server through the built-in interface, the built-in interface can directly access the target memory corresponding to the memory address according to the address mapping relationship between the target script and the target memory, and will not access the memory region used by the script of the server or other users, that is, the hardware resources occupied by different users and the user and the server host are isolated.
[0118] In the embodiment of the present application, the shared memory of the server is accessed through the built-in interface, and a currently idle memory region is selected from the shared memory; a target identifier corresponding to the selected memory region is obtained, and an address mapping between the target script and the memory region corresponding to the target identifier is established according to the target identifier, so as to allocate the memory region corresponding to the target identifier to the target script as a target memory. In this way, the corresponding target memory can be conveniently allocated to the target script, so that the memory regions of the shared memory in the server accessed by the scripts of different users are isolated and do not affect each other, and the rationality and practicality of the script processing method of the present application are improved.
[0119] Optionally, after step S3121, the method further includes:
[0120] In step S7, the running abnormal result of the target script is captured through the sandbox environment, and a specified operation is performed based on the running abnormal result.
[0121] In the embodiment of the present application, if an abnormality occurs during the running of the target script in the sandbox environment, the sandbox environment can take over the abnormality and process the abnormality based on a preset abnormality processing mechanism. For example, the abnormality processing mechanism of the Lua language can be used, the script running abnormal result is captured through the sandbox environment when the script runs abnormally, so that the script running abnormality does not affect the normal service of the server host.
[0122] After the running abnormal result of the target script is captured through the sandbox environment, the abnormal running result can be analyzed, the error cause is obtained and the abnormality level is determined, and then a specified operation is performed according to the abnormality level. For example, if the abnormality level is low, the sandbox environment can not process the script, and the abnormality can be ignored or rethrown, and if the abnormality level is high or the error cause is that the script host has a serious problem, the sandbox environment can report the abnormality to feedback the user for processing.
[0123] Step S8, releasing the target memory corresponding to the target script for use by scripts of other users allocated by the server.
[0124] In the embodiments of the present application, the target script runs abnormally in the sandbox environment, and the sandbox environment takes over the abnormality and performs the specified processing, and then needs to perform the finishing work, i.e. releasing the hardware and software resources occupied by the target script during the running process for use by scripts of other users. Among them, the target memory allocated in the shared memory in the server for the target script can release the target memory by releasing the mapping relationship between the target script and the target memory through the built-in interface, so as to be used by the scripts of other users allocated by the server.
[0125] In the embodiments of the present application, the running abnormal result of the target script is captured through the sandbox environment, and the specified operation is performed based on the running abnormal result; the target memory corresponding to the target script is released for use by the scripts of other users allocated by the server. In this way, the running abnormality of the target script can be isolated in the sandbox environment, and the main environment of the server is protected from being affected, and by releasing the memory resources occupied by the target script, the scripts of other users allocated by the server can be facilitated.
[0126] Optionally, step S7 can include the following steps:
[0127] Step S71, analyzing the running abnormal result to determine whether the running abnormal result meets the preset reporting condition.
[0128] In the embodiments of the present application, the preset reporting condition can be that the abnormality represented by the running abnormal result reaches a level that needs to be reported to the user for processing, for example, the error cause in the running abnormal result is that the script main body has a serious problem, which indicates that the abnormality level is high and can only be processed by the user.
[0129] After the sandbox environment captures the running abnormal result of the target script, the abnormal running result can be analyzed to obtain the error cause and determine the abnormality level, and determine whether the running abnormal result needs to be processed by the user, i.e. whether the preset reporting condition is met.
[0130] Step S72, generating an error log according to the running abnormal result through the sandbox environment in the case of meeting the reporting condition.
[0131] In the embodiment of the present application, in the case that the sandbox environment determines that the running abnormal result meets the reporting condition, an error log can be generated according to the running abnormal result, wherein the error log can include information such as the time of the abnormal occurrence, the stage of the script execution, the running abnormal result, and the error cause. Optionally, in the case that the reporting condition is not met, for example, the abnormal level is low, the sandbox environment can not process the script, and the running abnormality is ignored, the client request is not responded to, and the client access error information is fed back.
[0132] In step S73, the error log is sent to a log processing component, so that the log processing component feeds back to the user.
[0133] In the embodiment of the present application, the error log can be sent to the log processing component of the server through the built-in interface of the sandbox environment. After receiving the error log, the log processing component adds an identifier to the error log, indicating that the error log is reported by the sandbox environment. Then, the log processing component feeds back the error log to the user, so that the user can view the running abnormal result of the target script and perform corresponding processing.
[0134] In the embodiment of the present application, the running abnormal result is analyzed to determine whether the running abnormal result meets a preset reporting condition; in the case that the reporting condition is met, an error log is generated according to the running abnormal result through the sandbox environment; and the error log is sent to a log processing component, so that the log processing component feeds back to the user. In this way, the running abnormality of the target script can be conveniently fed back to the user, so that the user can view the running abnormal result through the error log and process the running abnormality.
[0135] Optionally, the running abnormal result includes a code error and / or an interface calling error of the target script; and step S72 can include the following steps:
[0136] In step S721, an error log is generated according to a preset script rule and the code error and / or the interface calling error through the sandbox environment; the script rule includes a code syntax rule and an interface calling rule.
[0137] In the embodiment of the present application, the code error of the target script can represent an error code in the script programmed by the user, such as a code syntax error. The interface calling error of the target script can represent that an application programming interface (API) called by the target script does not exist, or the API called by the target script does not meet the specification of the sandbox environment, such as an API that can affect the server body or other users, or an API that is easily abused to cause network security problems.
[0138] In the embodiments of the present application, the user needs to follow the basic syntax rules of the used script language when writing the target script, and write the interface related code according to the interface calling specification of the sandbox environment. For example, the Lua language has a programming specification document, and the sandbox environment has a program design specification. Scripts that do not meet the specification will have a running exception when running in the sandbox environment, and the sandbox environment will generate an error log to report to the server, and the user needs to process the target script according to the running exception result. Among them, the sandbox environment can obtain the correct syntax specification and / or interface calling specification corresponding to the code error and / or interface calling error from the preset code syntax rules and interface calling rules according to the code error and / or interface calling error, and then generate an error log, which includes the code error and / or interface calling error, and the corresponding correct syntax specification and / or interface calling specification, to provide the user with the running exception result and the exception processing.
[0139] In the embodiments of the present application, the sandbox environment generates an error log according to the preset script rules and the code error and / or interface calling error; the script rules include code syntax rules and interface calling rules. In this way, the user can be conveniently informed of the code error and / or interface calling error existing in the target script through the error log, and the user can conveniently adjust the target script according to the code syntax rules and the interface calling rules.
[0140] Optionally, after step S312, the method further includes:
[0141] Step S9, obtaining the processing result of the request and response processing script for the client request.
[0142] In the embodiments of the present application, the sandbox environment can obtain the request processing result and the response processing result of the request and response processing script for the client request after responding to the client request. The request processing result can include whether the client request passes the security verification, and the response processing result can include whether the target resource specified by the client request is sent to the client.
[0143] Step S10, generating an access log of the client accessing the server this time according to the processing result, and storing the access log to a specified area.
[0144] In the embodiments of the present application, the access log is used to record the Internet Protocol (IP) address of the client sending the client request, access time, request mode, response state, geographical origin, jump origin, and terminal used, and the like. The access log of the current access of the client to the server can be generated according to the client request and the processing result of the request and response processing script on the client request, and then the access log is stored in the specified memory area of the server shared memory, so as to record the access behavior of the client accessing the server.
[0145] Optionally, the access log can be sent to the log processing component of the server, and the log processing component is used to count and sort the access log, and store the access log in the specified memory area of the server shared memory. When the user of the server calls the access log, the statistical data of the access log can be obtained through the log processing component, so as to provide the user of the server with data analysis on the access situation.
[0146] In the embodiments of the present application, the processing result of the request and response processing script on the client request is obtained, the access log of the current access of the client to the server is generated according to the processing result, and the access log is stored in the specified area. In this way, the server can record the access behavior of the client, and the user of the server can view the access situation of the client through the access log.
[0147] Figure 2 is an application scenario diagram of the script processing method provided by the embodiments of the present application, as shown in Figure 2 The sandbox environment is provided in the CDN server, the server enters the process initialization stage after starting, the global task script in the target script is run in the sandbox environment in the case of executing initialization of the CDN server. In the case that the CDN server receives the client request, the request processing stage is entered, the request processing part in the request and response processing script in the target script is run in the sandbox environment, so as to respond to the client request and perform authentication and other processing operations. In the case that there is no target resource specified by the client request in the shared memory of the CDN server, the back-to-source stage is entered, and the CDN server obtains the target resource from the source station of the resource, i.e., the source server. Further, the response processing stage is entered, the response processing part in the request and response processing script in the target script is run in the sandbox environment, the target resource specified by the client request is sent to the client, and the access log of the current access of the client to the CDN server is generated, so as to record the access behavior of the client.
[0148] Figure 3 is an architecture level diagram of the server provided by the embodiments of the present application, as shown in Figure 3As shown, the server includes a basic component layer, a business driving layer, i.e., a sandbox environment, and a business implementation layer, i.e., a user script. The user script, i.e., a target script generated by user programming according to an embodiment of the present application, includes a global task script and a request and response processing script. The basic component layer includes a server basic component and a programming language native component.
[0149] The sandbox environment is an intermediate layer of the user script and the basic component, and encapsulates the bottom layer to achieve the purpose of environmental protection and isolation. The sandbox environment can include a business processing function library, a built-in interface, and a programming language built-in function library. The business processing function library is based on the function functions of the server, and also contains commonly used program auxiliary functions. The sandbox environment can isolate and protect the business processing function library. For example, the request processing function, the response processing function, the remote access function, the asynchronous processing function, the encoding / decryption algorithm function, the auxiliary tool function, etc. The built-in interface is based on the native API of the server, and the sandbox environment can protect the built-in interface and isolate different users. The built-in interface can include a variable read-write API and a shared dictionary API. The variable read-write API can be used to read and write variables in the shared memory of the server, such as obtaining the uniform resource identifier (URI) of the client request. The shared dictionary API encapsulates functions for reading and writing processing operations of the shared dictionary, and can be used to read and write dictionary items in the shared memory of the server through the shared dictionary API. The programming language built-in function library includes native functions of the programming language corresponding to the user's script, such as the native functions provided by Luajit, which is a Lua interpreter written in C language. Through the sandbox environment, some dangerous functions can be shielded, such as some functions that may affect the entire Lua virtual machine, for example, the os.execute() function can directly execute Linux bash instructions, which is a high-risk behavior and can cause machine crashes.
[0150] Figure 4 is a flowchart of another script processing method provided by an embodiment of the present application, as shown in Figure 4As shown, after a user programs a target script, the target script is sent to the server, the server loads the target script and loads it into a sandbox environment to wait for script execution, the target script is run when the server starts or when the server receives a client request, and only built-in interfaces provided by the sandbox can be used, after the target script is run, if there is an abnormality, the sandbox environment will take over the abnormality and feed back the abnormality to the server. By using the sandbox environment, the business processing function library, built-in interface and programming language built-in function library can be isolated from the server body, so as to avoid the influence of dangerous operations that may be caused by the direct running of the user's script in the server on the server body. Moreover, the running of multiple scripts in the sandbox environment is independent of each other, the sandbox environment protects the running process of the script, and the code and machine resources used by scripts of different users are isolated from each other, so that the running of multiple scripts will not affect each other. If an abnormality occurs in a script, the sandbox environment can ensure that the single-script abnormality will not affect the normal running of scripts of other users, and will not affect the normal service of the server body.
[0151] Figure 5 is a structural diagram of a script processing device provided by an embodiment of the present application, which is applied to a server of a network service platform. The device 50 can include:
[0152] A storage module 501 is configured to store a target script to a specified path; the target script is a script programmed by a user of the server;
[0153] A loading module 502 is configured to load the target script from the specified path to a preset sandbox environment of the server; the sandbox environment is isolated from a main resource environment in the server;
[0154] A running module 503 is configured to run the target script in the sandbox environment to execute an operation defined by the target script.
[0155] Optionally, the running module 503 is specifically configured to:
[0156] run the target script in the sandbox environment to send a target resource specified by a client request to the client in response to the client request; the client request is a request submitted by the client to the server.
[0157] Optionally, the running module 503 is specifically further configured to:
[0158] in a case where the server performs initialization, run the global task script in the sandbox environment to execute an initialization task defined by the global task script, execute a timing task defined by the global task script according to a preset time, and obtain an execution result of the global task script;
[0159] run the request and response processing script in the sandbox environment to send the target resource specified by the client request to the client according to the execution result.
[0160] Optionally, the server comprises a shared memory, and the sandbox environment comprises a built-in interface; the apparatus 50 further comprises:
[0161] an allocation module configured to, after the loading module 502 loads the target script into the preset sandbox environment of the server from the specified path, allocate corresponding memory for the target script from the shared memory as target memory;
[0162] The running module 503 is specifically configured to:
[0163] in response to the client request, send the target resource specified by the client request to the client based on the execution result, the built-in interface and the target memory.
[0164] Optionally, the execution result comprises an access rule of the server; the running module 503 is specifically configured to:
[0165] perform first security verification on the client request according to the access rule to obtain a first verification result;
[0166] in a case where the first verification result indicates that the client request complies with the access rule of the server, access the target memory through the built-in interface and send the target resource to the client based on the resource in the target memory.
[0167] Optionally, the execution result comprises a network address of an authentication server corresponding to the server; the running module 503 is specifically configured to:
[0168] send a security verification instruction to the authentication server according to the network address of the authentication server; the security verification instruction comprises the client request, and is used to instruct the authentication server to perform second security verification on the client request and return a generated second verification result to the server;
[0169] in a case where the second verification result indicates that the client request complies with the access rule of the server, access the target memory through the built-in interface and send the target resource to the client based on the resource in the target memory.
[0170] Optionally, the execution result further comprises a network address of a source server corresponding to the server; the running module 503 is specifically configured to:
[0171] in the case that the target resource exists in the resources in the target memory, directly sending the target resource in the target memory to the client;
[0172] in the case that the target resource does not exist in the resources in the target memory, according to the network address of the source server, sending a resource acquisition instruction to the source server; the resource acquisition instruction is used to instruct the source server to send the target resource to the server, so that the server stores the target resource in the target memory; after the server stores the target resource in the target memory, the target resource in the target memory is sent to the client.
[0173] Optionally, the allocation module is specifically configured to:
[0174] access the shared memory of the server through the built-in interface, and select a currently idle memory area from the shared memory;
[0175] obtain a target identifier corresponding to the selected memory area, and establish an address mapping for the target script and the memory area corresponding to the target identifier according to the target identifier, so as to allocate the memory area corresponding to the target identifier to the target script as a target memory.
[0176] Optionally, the apparatus 50 further includes:
[0177] a capturing module configured to, after the running module 503 runs the target script in the sandbox environment, capture a running abnormal result of the target script through the sandbox environment, and perform a specified operation based on the running abnormal result;
[0178] a releasing module configured to release a target memory corresponding to the target script, so that the server allocates the target memory to scripts of other users.
[0179] Optionally, the capturing module is specifically configured to:
[0180] analyze the running abnormal result to determine whether the running abnormal result meets a preset reporting condition;
[0181] in the case that the reporting condition is met, generate an error log according to the running abnormal result through the sandbox environment;
[0182] send the error log to a log processing component, so that the log processing component feeds back to the user.
[0183] Optionally, the running abnormal result includes a code error and / or an interface calling error of the target script; and the capturing module is specifically further configured to:
[0184] The sandbox environment is used to generate an error log according to preset script rules and the code error and / or the interface calling error.
[0185] Optionally, after running the request and response processing script in the sandbox environment, the apparatus 50 further comprises:
[0186] An obtaining module is configured to, after the running module 503 runs the request and response processing script in the sandbox environment, obtain a processing result of the request and response processing script for the client request;
[0187] A generating module is configured to generate an access log of the client accessing the server this time according to the processing result, and store the access log to a specified area.
[0188] For the apparatus embodiment, it is basically similar to the method embodiment, so the description is relatively simple, and the relevant part can be referred to the part of the method embodiment.
[0189] The script processing apparatus has the same advantages as the script processing method described above, and will not be described here.
[0190] The embodiment of the present application further provides an electronic device, referring to Figure 6 , comprising a processor 601, a memory 602, and a computer program 6021 stored in the memory and executable on the processor, and the processor implements the script processing method of the foregoing embodiment when executing the program.
[0191] The embodiment of the present application further provides a readable storage medium, when the instructions in the storage medium are executed by the processor of the electronic device, the electronic device can execute the script processing method of the foregoing embodiment.
[0192] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other apparatus. Structural requirements of such systems to perform the operations described above are apparent to those skilled in the art from the description. In addition, the present application is not directed to any particular programming language. It will be appreciated that a variety of programming languages can be used to implement the present application described herein, and that the descriptions above are provided for the best mode for carrying out the present application.
[0193] In the specification provided herein, a large number of specific details are described. However, it can be understood that the embodiments of the present application can be practiced without these specific details. In some examples, well-known methods, structures and techniques are not described in detail in order not to obscure the understanding of the present specification.
[0194] Similarly, it is to be understood that the features of the present application that are of a proprietary nature are set forth in the appended claims. In this respect, before the application is disclosed and before the application is described in terms of a preferred embodiment or embodiments, it is to be understood that only the features of the application, or those preferred embodiments that are of a proprietary nature, are intended to be in the scope of a patent or patents issued upon this application. Statements or descriptions that can not be essential to the application or preferred embodiment are not intended to be required to be in the scope of the claimed application as defined by the appended claims.
[0195] Those skilled in the art will appreciate that the modules in the apparatus of the embodiments can be adapted and placed in one or more apparatuses other than the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and further can be split into more sub-modules or sub-units or sub-components. Any combination of all or some of the disclosed features in the specification (including accompanying claims, abstract and drawings) and any method or process or device of the application can be made, excepting such combinations of features in the specification (including accompanying claims, abstract and drawings) and any method or process or device of the application are not mutually exclusive of each other. Each feature disclosed in the specification (including accompanying claims, abstract and drawings) can be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
[0196] Embodiments of the various components of the application can be implemented in hardware, or as software modules running in one or more processors, or combinations thereof. Those skilled in the art will appreciate that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all of the functionality of some or all of the components in the sequencing apparatus according to the present application. The present application can also be implemented as a program for executing part or all of the methods described herein on a device or apparatus. Such a program(s) can be stored on a computer readable medium which can be a storage device or a memory, or a transmission medium such as a signal. The program(s) can be downloaded from an internet website, or provided on a carrier medium, or in any other form.
[0197] It should be noted that the above-mentioned embodiments illustrate rather than limit the application, and that one skilled in the art will be able to design many alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word 'comprising' does not exclude the presence of elements or steps other than those listed in a claim. The word 'a' or 'an' preceding an element does not exclude the presence of a plurality of such elements. The application can be implemented by means of both hardware and software, and any combination thereof. In a unit claim, several devices can be listed with a comma. The use of the term 'about' followed by a number means ± 10 % of the number. The use of the term 'first','second' and 'third' etc. does not limit the number for these objects; these designations are merely used as names.
[0198] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system, device and unit described above can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.
[0199] The above only represents the preferred embodiments of the present application, and is not intended to limit the present application, and any modification, equivalent replacement and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0200] The above only represents the preferred embodiments of the present application, and is not intended to limit the present application, and any modification, equivalent replacement and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0201] It should be noted that the above-mentioned embodiments illustrate rather than limit the application, and that one skilled in the art will be able to design many alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word 'comprising' does not exclude the presence of elements or steps other than those listed in a claim. The word 'a' or 'an' preceding an element does not exclude the presence of a plurality of such elements. The application can be implemented by means of both hardware and software, and any combination thereof. In a unit claim, several devices can be listed with a comma. The use of the term 'about' followed by a number means ± 10 % of the number. The use of the term 'first','second' and 'third' etc. does not limit the number for these objects; these designations are merely used as names.
Claims
1. A script processing method, characterized in that, The method, applied to a server of a network service platform, includes: The target script is stored in a specified path; the target script is a user-programmed script generated for the server; the target script includes a global task script and a request and response processing script. The target script is loaded from the specified path into a preset sandbox environment of the server; the sandbox environment is isolated from the main resource environment in the server; the server includes shared memory, and the sandbox environment includes built-in interfaces; Allocate corresponding memory for the target script from the shared memory, as the target memory; Run the target script in the sandbox environment to perform the operations defined in the target script, including: Running the target script in the sandbox environment to send the target resource specified in the client request to the client in response to a client request includes: When the server performs initialization, the global task script is run in the sandbox environment to execute the initialization task defined by the global task script, execute the timed task defined by the global task script according to a preset time, and obtain the execution result of the global task script; the execution result includes the access rules of the server, the network address of the authentication server corresponding to the server, and the network address of the source server corresponding to the server. Running the request and response processing script in the sandbox environment to respond to the client request, and sending the target resource specified in the client request to the client based on the execution result, includes: In response to the client request, based on the execution result, the built-in interface, and the target memory, the target resource specified in the client request is sent to the client, including: Based on the network address of the authentication server, a security verification instruction is sent to the authentication server; the security verification instruction includes the client request, which instructs the authentication server to perform a second security verification on the client request and return the generated second verification result to the server; if the second verification result indicates that the client request conforms to the server's access rules, the target memory is accessed through the built-in interface, and the target resource is sent to the client based on the resources in the target memory; the client request is a request submitted by the client to the server.
2. The method according to claim 1, characterized in that, The step of sending the target resource requested by the client to the client based on the execution result, the built-in interface, and the target memory includes: The client request is subjected to a first security verification according to the access rules to obtain a first verification result; If the first verification result indicates that the client request conforms to the server's access rules, the target memory is accessed through the built-in interface, and the target resource is sent to the client based on the resources in the target memory.
3. The method according to claim 1 or 2, characterized in that, The step of sending the target resource to the client based on the resource in the target memory includes: If the target resource exists in the resources in the target memory, the target resource in the target memory is sent directly to the client; If the target resource is not present in the target memory, a resource acquisition instruction is sent to the source server based on the source server's network address. The resource acquisition instruction instructs the source server to send the target resource to the server so that the server can store the target resource in the target memory. After the server stores the target resource in the target memory, the target resource in the target memory is sent to the client.
4. The method according to claim 1, characterized in that, The step of allocating corresponding memory from the shared memory for the target script, as the target memory, includes: Access the server's shared memory through the built-in interface, and select a currently free memory region from the shared memory; Obtain the target identifier corresponding to the selected memory region, and establish an address mapping between the target script and the memory region corresponding to the target identifier based on the target identifier, so as to allocate the memory region corresponding to the target identifier to the target script as target memory.
5. The method according to claim 1, characterized in that, After running the target script in the sandbox environment, the method further includes: The sandbox environment is used to capture the abnormal execution results of the target script, and the specified operation is performed based on the abnormal execution results. Release the target memory corresponding to the target script so that it can be used by scripts allocated by the server to other users.
6. The method according to claim 5, characterized in that, The execution of the specified operation based on the runtime exception result includes: The abnormal operation results are analyzed to determine whether they meet the preset reporting conditions. If the reporting conditions are met, an error log is generated in the sandbox environment based on the abnormal operation results; The error log is sent to the log processing component so that the log processing component can provide feedback to the user.
7. The method according to claim 6, characterized in that, The abnormal runtime results include code errors and / or interface call errors in the target script; The generation of error logs based on the runtime anomaly results within the sandbox environment includes: Error logs are generated in the sandbox environment based on preset script rules and the code errors and / or interface call errors. The script rules include code syntax rules and API call rules.
8. The method according to claim 1, characterized in that, After running the request and response processing script in the sandbox environment, the method further includes: Obtain the processing result of the request and response processing script for the client request; Based on the processing result, an access log for the client's current access to the server is generated, and the access log is stored in a designated area.
9. A script processing device, characterized in that, A server used in a network service platform, the device comprising: A storage module is used to store the target script to a specified path; the target script is a user-programmed script generated by the server; the target script includes a global task script and a request and response processing script. A loading module is used to load the target script from the specified path into a preset sandbox environment of the server; the sandbox environment is isolated from the main resource environment in the server; the server includes shared memory, and the sandbox environment includes built-in interfaces; An allocation module is used to allocate corresponding memory from the shared memory for the target script, as the target memory; The execution module is used to run the target script in the sandbox environment to perform the operations defined by the target script, including: Running the target script in the sandbox environment to send the target resource specified in the client request to the client in response to a client request includes: When the server performs initialization, the global task script is run in the sandbox environment to execute the initialization task defined by the global task script, execute the timed task defined by the global task script according to a preset time, and obtain the execution result of the global task script; the execution result includes the access rules of the server, the network address of the authentication server corresponding to the server, and the network address of the source server corresponding to the server. Running the request and response processing script in the sandbox environment to respond to the client request, and sending the target resource specified in the client request to the client based on the execution result, includes: In response to the client request, based on the execution result, the built-in interface, and the target memory, the target resource specified in the client request is sent to the client, including: Based on the network address of the authentication server, a security verification instruction is sent to the authentication server; the security verification instruction includes the client request, which instructs the authentication server to perform a second security verification on the client request and return the generated second verification result to the server; if the second verification result indicates that the client request conforms to the server's access rules, the target memory is accessed through the built-in interface, and the target resource is sent to the client based on the resources in the target memory; the client request is a request submitted by the client to the server.
10. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the program, implements the script processing method as described in any one of claims 1-8.
11. A readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the script processing method according to any one of claims 1-8.
Citation Information
Patent Citations
Web server and system resource access control method thereof
CN103618758A
Service processing method and device based on container technology, and computer equipment
CN110955492A