Novel script development method based on JVM
By setting allow and prohibit lists in the system configuration file, using responsive programming and observer mode to process external input data, building an abstract syntax tree for security checks, the security and flexibility of script development tools in the existing technology are solved. The shortcomings of the scripts have been implemented online development and real-time adjustment, improving security and development efficiency.
Patent Information
- Application Number
- CN202411350379.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-02-11
AI Technical Summary
The existing JVM-based script development tools have shortcomings in terms of security and flexibility, and cannot accurately limit developers' operations, and there are potential security risks. They do not support online development and real-time adjustments, which affect business continuity and development efficiency.
By setting the script's allow and prohibited list in the system configuration file, using the observer mode to monitor configuration file changes, using the responsive programming library to process external input data, building an abstract syntax tree for syntax analysis and security checking, realizing online script development and real-time adjustments.
Improve script flexibility, responsiveness and security, and automatically reload configurations by updating configuration files in real time, reducing potential security risks, supporting online development and real-time adjustments, improving development efficiency and business continuity.
Smart Images

Figure CN119415098A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of electronic digital data processing, in particular to the technical field of software design, and specifically to a novel script development method based on JVM. Background Art
[0002] At present, JVM is a Java virtual machine, a specification for computing devices, which is implemented by simulating various computer functions on actual computers. JVM is the core component of the Java platform, which enables Java programs to "compile once and run everywhere". This feature greatly enhances the cross-platform capabilities of Java programs. JVM-based script development refers to the process of writing and executing programs using scripting languages that can run on JVM. JVM is the operating environment of Java programs, which shields the differences between Java bytecode and the underlying operating system and provides a consistent operating environment.
[0003] Although existing script development tools perform well in terms of performance, support and scalability and meet certain development needs, they are insufficient in terms of security and flexibility. The defects of existing technologies include: 1. It is impossible to accurately limit the operations of developers, and there are potential security risks. When misoperated, it will lead to data leakage or resource abuse. The lack of effective access control and operation audit mechanisms makes it difficult to detect and prevent potential security risks in a timely manner; 2. Scripts need to be compiled before they can be used, and do not support online development and real-time adjustment. The modification and update of scripts often require restarting the service or redeploying, which affects the continuity and availability of the business, and affects the development efficiency and response speed. Therefore, the company is seeking a safer and more flexible script development method to improve development security and avoid potential risks.
[0004] Therefore, it is necessary to improve the novel script development method based on JVM in the prior art to solve the above problems. Summary of the invention
[0005] The present invention overcomes the shortcomings of the prior art and provides a novel script development method based on JVM, aiming to solve the problem of accurately limiting the developer's operation in the prior art and realize the functions of online script development and real-time adjustment.
[0006] To achieve the above object, the technical solution adopted by the present invention is: a new script development method based on JVM, comprising:
[0007] S1. Set the script permission and prohibition lists in the system configuration file, set the initial variables and configuration information of the script, and use the observer mode to monitor the changes of the configuration file;
[0008] S2. Use the responsive programming library to collect external input data, convert the external input data as an event, and add the external input data to the script execution context;
[0009] S3, parse the script content into tags and nodes, and build an abstract syntax tree;
[0010] S4, check whether the variables of the abstract syntax tree conform to the allowed and prohibited lists in the configuration file;
[0011] S5, traverse the abstract syntax tree and execute the node logic of the abstract syntax tree;
[0012] S6. Collect the execution results of all nodes and return them to the caller.
[0013] In a preferred embodiment of the present invention, in step S1, the observer mode is used to monitor the changes of the configuration file;
[0014] S11. Create an observer interface, including an update method;
[0015] S12. Create a configuration manager as a subject. The configuration manager holds the current state of the configuration file and provides methods for registering and unregistering observers. When the configuration file is updated, all registered observers are notified.
[0016] S13. Implement the observer interface, use file monitoring technology to monitor changes in configuration files, and trigger the reload method of the configuration manager.
[0017] In a preferred embodiment of the present invention, in step S2, a responsive programming library is used to monitor and collect external input data from different sources including: script interfaces, scheduled tasks, and message queues;
[0018] S21. Create a responsive stream to push changes in external input data as events to the script;
[0019] S22. Use functional programming to transform and process data, and convert external input data into the format and structure required by the script through mapping, filtering, and reduction;
[0020] S23. For the external input data in the scheduled task and message queue, define the event type and event handler. When the scheduled task is triggered or the message in the message queue arrives, a corresponding event is generated. The event handler adds the external input data processed by S22 to the script execution context.
[0021] S24. For the external input data of the script interface, the dynamic proxy technology is used to monitor and intercept, and the external input data processed by S22 is added to the script execution context.
[0022] In a preferred embodiment of the present invention, in step S3, the step of constructing an abstract syntax tree includes:
[0023] S31, decomposing the script content into different tags according to the grammatical rules of the script language;
[0024] S32, converting the token into a node tree with a hierarchical structure, each node represents a grammatical structure in the script, recursively constructing an abstract syntax tree, and each token is converted into a corresponding node according to its type and grammatical rule;
[0025] S33. Classify the nodes according to their functions and grammatical roles, including variable nodes, member nodes, plus nodes, and asynchronous nodes.
[0026] In a preferred embodiment of the present invention, in step S31,
[0027] S311, set a left brace count and a right brace count; create a script content object to store the script content, create a start tag and an end tag; create a tag list to store tags, the tags record the type, start tag and end tag of a script;
[0028] S312, when the start tag is not less than the end tag, the end tag is defined;
[0029] S313. When the start mark is smaller than the end mark, check if the string at the start mark position is empty or a newline, add 1 to the start mark, and return the start mark detection; check if the string at the start mark position is not empty or a newline, set a marked start mark, the value of the mark is equal to the start mark, and determine whether it is a special type of mark. If it is a special type, move the position of the start mark, set the mark, and add it to the mark list according to the method rules for determining the script content type; if it is not a special type of mark, traverse all non-special mark types, move the start mark and end mark positions to the matched characters, and add the mark to the mark list.
[0030] In a preferred embodiment of the present invention, in step S33, the plus sign node obtains the nodes on the left and right sides of the plus sign for calculation. When one of the left and right sides is a string, the logic of string concatenation is performed; when one of the left and right values is a null value, an error is reported; otherwise, an addition operation is performed between numbers.
[0031] In a preferred embodiment of the present invention, in step S33, when the member node obtains the member variable, the prohibited member variable name and the allowed member variable name of the current class are obtained from the context;
[0032] When a member variable name is in the prohibited member variable name list, it will not be accessed;
[0033] When the member variable name exists in the prohibited member variable name list, and the allowed member variable name list does not exist or the current member variable name is not in the allowed member variable name list, a null value is returned;
[0034] When a custom annotation is used on a member variable, a null value is returned regardless of the configuration.
[0035] In a preferred embodiment of the present invention, in step S33, the asynchronous node determines the tag type following the asynchronous symbol, and when the tag type is a Lambda expression, prepares the input parameters required for the Lambda expression and creates a new context; establishes an asynchronous task whose task content is a node that needs to be run for calculation, determines whether the current thread is in the thread pool, and if so, runs directly; otherwise, puts it into the thread pool for execution.
[0036] In a preferred embodiment of the present invention, in step S4,
[0037] S41, traverse all nodes of the abstract syntax tree, and extract the class, method, and member variable information corresponding to each node;
[0038] S42. For each extracted class, method, and member variable, check whether they are in the allowed list of the configuration file; if they are in the allowed list and the configuration file only uses the allowed list, the node passes the security check; if they are not in the allowed list, but the configuration file only uses the prohibited list and the node is not in the prohibited list, the node passes the security check;
[0039] S43. For nodes that fail the security check in S42, process them according to the rules of the configuration file;
[0040] S44. Generate a security check report to record all nodes that failed the security check and their detailed information so that developers can review and adjust them.
[0041] In a preferred embodiment of the present invention, in step S5,
[0042] S51. Starting from the root node of the abstract syntax tree, recursively traverse each node;
[0043] S52: For each node, execute corresponding logic processing according to the node type;
[0044] Variable node: calculates the value of the variable and stores it in the context of the script execution;
[0045] Member node: calculates the value of member variables and performs access control checks;
[0046] Plus node: performs addition operations or string concatenation;
[0047] Asynchronous node: submits asynchronous tasks to the thread pool for execution and manages the life cycle of asynchronous tasks;
[0048] S53. For asynchronous nodes, their execution logic is specially processed to ensure that the asynchronous task can be submitted correctly and its result can be obtained when needed; when the asynchronous task is submitted, the context and related information of the task are recorded, and when the asynchronous task is completed, the result is stored back in the context of the script execution;
[0049] S54. Collect the execution results of all nodes, including intermediate results and final results, and return them to the caller.
[0050] In a preferred embodiment of the present invention,
[0051] The present invention solves the defects existing in the background technology and has the following beneficial effects:
[0052] (1) The present invention proposes a novel script development method based on JVM, which sets the allowed and prohibited lists of scripts through configuration files, uses the observer mode to monitor configuration changes, utilizes responsive programming and dynamic proxy technology to process external input, constructs an abstract syntax tree for syntax parsing and security checks, and finally traverses the abstract syntax tree node logic and returns the results, thereby improving the flexibility, responsiveness and security of the script.
[0053] (2) The present invention reads the allowed and prohibited lists in the configuration file to clearly specify which classes, methods, and member variables can be used in the script. Combined with the observer mode, when the configuration file changes, the system can automatically reload the configuration without restarting the script, effectively limiting the developer's operating scope, reducing potential security risks, and preventing data leakage or resource abuse. At the same time, real-time configuration updates enhance the security and flexibility of the system.
[0054] (3) The present invention uses a responsive programming library to monitor and process external input data from script interfaces, scheduled tasks, and message queues in real time. Combined with dynamic proxy technology, it can flexibly intercept and convert data to ensure that they are added to the script execution context in the correct format and structure, making script development more flexible and supporting online development and real-time adjustment without restarting the service or redeploying, thereby improving development efficiency and response speed.
[0055] (4) The present invention parses the script content into tags and nodes and constructs an abstract syntax tree, which can accurately control the execution logic of the script. By traversing and classifying different types of nodes, such as variable nodes, member nodes, plus nodes, and asynchronous nodes, the script logic can be efficiently executed, while optimizing resource usage and improving execution efficiency. After the abstract syntax tree is constructed, the security review of the script content is implemented by checking whether the node class, method, and member variable comply with the allowed and prohibited lists in the configuration file. Nodes that fail the security check will be recorded and a detailed security check report will be generated, which is convenient for developers to review and adjust, which not only improves the security of the code, but also enhances the maintainability and review efficiency of the code.
[0056] (5) The present invention provides richer and more flexible script execution logic by classifying and processing different types of nodes, including asynchronous task processing of asynchronous nodes, arithmetic operations or string concatenation of plus sign nodes, making script development more intuitive and easy to use, and improving the developer's development experience and script usability. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work.
[0058] Figure 1 is a flow chart of a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0061] like Figure 1 As shown, a new script development method based on JVM includes the following steps:
[0062] S1. Set the script permission and prohibition lists in the system configuration file, set the initial variables and configuration information of the script, and use the observer mode to monitor the changes of the configuration file;
[0063] S2. Use the responsive programming library to collect external input data, convert the external input data as an event, and add the external input data to the script execution context;
[0064] S3, parse the script content into tags and nodes, and build an abstract syntax tree;
[0065] S4, check whether the variables of the abstract syntax tree conform to the allowed and prohibited lists in the configuration file;
[0066] S5, traverse the abstract syntax tree and execute the node logic of the abstract syntax tree;
[0067] S6. Collect the execution results of all nodes and return them to the caller;
[0068] In step S1, the configuration file is an external file in the format of JSON, XML and Properties; the present invention uses Config File Validator to verify the structure and data type of the configuration file to ensure that the configuration file conforms to the expected format and rules;
[0069] The allowed and prohibited lists specify which classes, methods, and member variables can be used in the script;
[0070] Allow list: that is, whitelist mode, only the classes, methods, and member variables explicitly listed in the configuration file are allowed to be accessed;
[0071] Prohibited list: that is, blacklist mode, which prohibits the classes, methods, and member variables listed in the configuration file from being accessed, while all other unlisted ones are allowed;
[0072] The allow and deny lists are used to perform security checks during script execution to ensure that the script does not perform unsafe operations.
[0073] In step S1, before the script starts executing, the initial variables set include: environment variables, system parameters; in addition to the allowed and prohibited lists, other configuration information is also set, including: log level, thread pool size; these initial variables and configuration information are stored in the context of the script for use during the script execution process.
[0074] In step S1, the observer pattern is used to monitor changes in the configuration file. When the configuration file is updated, the system can automatically reload the configuration without restarting the script.
[0075] The observer pattern is a software design pattern that defines a one-to-many dependency relationship between objects, so that when the state of an object changes, all objects that depend on it are notified and automatically updated.
[0076] S11. Create an observer interface, including an update method; used to notify observers when the configuration file changes. The observers of this application are script developers and users;
[0077] Specifically, the update method is: onConfigUpdated();
[0078] S12. Create a configuration manager as a subject. The configuration manager holds the current state of the configuration file and provides methods for registering and unregistering observers. When the configuration file is updated, all registered observers are notified.
[0079] Register an observer through registerObserver to receive notifications when the configuration file is updated; unregisterObserver unregisters the observer so that it no longer receives update notifications; when the configuration file is updated, call notifyObservers to notify all registered observers; loadConfig loads data from the configuration file to the configuration manager;
[0080] S13. Implement the observer interface, use file monitoring technology to monitor changes in configuration files, and trigger the reload method of the configuration manager;
[0081] Use startWatchin to monitor changes in the configuration file. When changes are detected, call checkAndReloadConfig. Use checkAndReloadConfig to check whether the configuration file has been updated. If so, call loadConfig to reload the data and notify the observer.
[0082] The script development method of the present invention can ensure that any changes in the configuration file can be captured in real time and applied to the script execution environment, thereby improving the flexibility and responsiveness of the script.
[0083] In step S2, the responsive programming library RxJava is used to monitor and collect external input data from different sources including: script interfaces, scheduled tasks, and message queues.
[0084] S21. Create a responsive stream to push changes in external input data as events to the script;
[0085] S22. Use functional programming to transform and process data, and convert external input data into the format and structure required by the script through mapping, filtering, and reduction;
[0086] S23. For the external input data in the scheduled task and message queue, define the event type and event handler. When the scheduled task is triggered or the message in the message queue arrives, a corresponding event is generated. The event handler adds the external input data processed by S22 to the script execution context.
[0087] S24, for the external input data of the script interface, use the dynamic proxy technology to monitor and intercept, and add the external input data processed by S22 to the script running context;
[0088] In step S2, an event-driven approach is used to process external input data in scheduled tasks and message queues, making data processing more efficient while reducing the coupling between system components. For external input data of the script interface, the system uses dynamic proxy technology to monitor and intercept, allowing the system to add additional functions without modifying the original code, thereby improving the scalability and maintainability of the system.
[0089] In step S3, the step of constructing an abstract syntax tree includes:
[0090] S31. according to the grammatical rules of the scripting language, decompose the script content into different tags, including comments, numbers, strings, regular expressions, variable definitions, and anonymous methods;
[0091] Specifically, the method for determining the script content type is:
[0092] Note: The format is / *content* / ;
[0093] Number: Use the Java built-in Character.isDigit method to determine whether it is a number; the Character.isDigit method checks whether the given character is a number 0-9;
[0094] String: judged by whether it is wrapped in quotation marks;
[0095] Variable definition: Specify that variables can only be modified with var;
[0096] Anonymous method: the format is "=" or "->";
[0097] S32, converting the token into a node tree with a hierarchical structure, each node represents a grammatical structure in the script, recursively constructing an abstract syntax tree, and each token is converted into a corresponding node according to its type and grammatical rule;
[0098] S33, classifying the nodes according to their functions and grammatical roles, including: variable nodes, member nodes, plus nodes, and asynchronous nodes;
[0099] In step S31,
[0100] S311, set a left brace count and a right brace count; create a script content object to store the script content, create a start tag and an end tag; create a tag list to store tags, the tags record the type, start tag and end tag of a script;
[0101] S312, when the start tag is not less than the end tag, the end tag is defined;
[0102] S313. When the start mark is smaller than the end mark, check if the string at the start mark position is empty or a newline, add 1 to the start mark, and return the start mark detection; check if the string at the start mark position is not empty or a newline, set a marked start mark, the value of the mark is equal to the start mark, and determine whether it is a special type of mark. If it is a special type, move the position of the start mark, set the mark, and add it to the mark list according to the method rules for determining the script content type; if it is not a special type of mark, traverse all non-special mark types, move the start mark and end mark positions to the matched characters, and add the mark to the mark list.
[0103] In step S33, the variable node is used to calculate whether the variable is legal and perform necessary verification on the class of the variable. If the reference is legal and passes the verification, the type of the variable is returned;
[0104] When getting a variable, get the currently prohibited package paths and allowed package paths from the context;
[0105] When there is a prohibited package path in the context, and the package path where the current class is located is in the prohibited list, access to the class's variables is not allowed and returns empty;
[0106] When there is an allowed package path in the context, but the package path where the current class is located is not in the allowed list and there is no such path in the prohibited list, access is also not allowed and a null value is returned;
[0107] To increase flexibility, it is possible to dynamically add allowed packet paths via input nodes. This feature is disabled by default and needs to be explicitly enabled in the configuration.
[0108] In step S33, the member node is used to calculate the value of the member variable of the variable. In this class, the member variable will be verified through the member node. If it passes, the member variable will be referenced and the value of the variable will be returned.
[0109] When obtaining member variables at a member node, the prohibited member variable names and allowed member variable names of the current class are obtained from the context;
[0110] Prohibited member variable names: a list containing the member variable names that are not allowed to be accessed in the current class;
[0111] Allowed member variable names: a list containing the member variable names that are allowed to be accessed in the current class;
[0112] When the member variable name in the method signature is in the list of prohibited member variable names, it will not be accessed;
[0113] When the member variable name exists in the prohibited member variable name list, and the allowed member variable name list does not exist or the current member variable name is not in the allowed member variable name list, a null value is returned;
[0114] When the custom annotation UnableCall is used on a member variable, a null value is returned regardless of the configuration.
[0115] In addition, you can use .length to get the length of the List and use .key name to get the value of the corresponding key in the Map, which can simplify the code and improve the user experience.
[0116] In step S33, the plus node performs plus logic processing and returns the processing result;
[0117] Get the nodes on the left and right sides of the plus sign for calculation. When one of the left and right nodes is a string, perform the string concatenation logic; when one of the left and right values is empty, an error is reported; otherwise, perform addition operations between numbers.
[0118] In step S33, the asynchronous node puts the content after the asynchronous symbol into the thread pool for execution and returns the asynchronous task;
[0119] The thread pool is a mechanism for managing and scheduling multiple threads, which can improve the concurrent performance and resource utilization of the program; Lambda expressions are used to define anonymous functions.
[0120] Determine the tag type following the asynchronous symbol. When the tag type is a Lambda expression, prepare the input parameters required by the Lambda expression and create a new context. Create an asynchronous task whose content is the node that the operation needs to run. Determine whether the current thread is in the thread pool. If so, run it directly; otherwise, put it into the thread pool for running.
[0121] In step S4,
[0122] S41, traverse all nodes of the abstract syntax tree, and extract the class, method, and member variable information corresponding to each node;
[0123] S42. For each extracted class, method, and member variable, check whether they are in the allowed list of the configuration file; if they are in the allowed list and the configuration file only uses the allowed list, the node passes the security check; if they are not in the allowed list, but the configuration file only uses the prohibited list and the node is not in the prohibited list, the node passes the security check;
[0124] S43. For nodes that fail the security check in S42, process them according to the rules of the configuration file;
[0125] S44. Generate a security check report to record all nodes that failed the security check and their detailed information so that developers can review and adjust them;
[0126] In step S5,
[0127] S51. Starting from the root node of the abstract syntax tree, recursively traverse each node;
[0128] S52: For each node, execute corresponding logic processing according to the node type;
[0129] Variable node: calculates the value of the variable and stores it in the context of the script execution;
[0130] Member node: calculates the value of member variables and performs access control checks;
[0131] Plus node: performs addition operations or string concatenation;
[0132] Asynchronous node: submits asynchronous tasks to the thread pool for execution and manages the life cycle of asynchronous tasks;
[0133] S53. For asynchronous nodes, their execution logic is specially processed to ensure that the asynchronous task can be submitted correctly and its result can be obtained when needed; when the asynchronous task is submitted, the context and related information of the task are recorded, and when the asynchronous task is completed, the result is stored back in the context of the script execution;
[0134] S54. Collect the execution results of all nodes, including intermediate results and final results, and return them to the caller.
[0135] The above is based on the ideal embodiment of the present invention. Through the above description, relevant personnel can make various changes and modifications without departing from the technical concept of the present invention. The technical scope of the present invention is not limited to the content in the specification, and the technical scope must be determined according to the scope of the claims.
Claims
1. A new script development method based on JVM, characterized in that: Includes steps: S1. Set the script permission and prohibition lists in the system configuration file, set the initial variables and configuration information of the script, and use the observer mode to monitor the changes of the configuration file; S2. Use the responsive programming library to collect external input data, convert the external input data as an event, and add the external input data to the script execution context; S3, parse the script content into tags and nodes, and build an abstract syntax tree; S4, check whether the variables of the abstract syntax tree conform to the allowed and prohibited lists in the configuration file; S5, traverse the abstract syntax tree and execute the node logic of the abstract syntax tree; S6. Collect the execution results of all nodes and return them to the caller.
2. A novel script development method based on JVM according to claim 1, characterized in that: In step S1, the observer pattern is used to monitor changes in the configuration file; S11. Create an observer interface, including an update method; S12. Create a configuration manager as a subject. The configuration manager holds the current state of the configuration file and provides methods for registering and unregistering observers. When the configuration file is updated, all registered observers are notified. S13. Implement the observer interface, use file monitoring technology to monitor changes in configuration files, and trigger the reload method of the configuration manager.
3. The novel script development method based on JVM according to claim 1, characterized in that: In step S2, the responsive programming library is used to monitor and collect external input data from different sources including: script interface, scheduled tasks, and message queues; S21. Create a responsive stream to push changes in external input data as events to the script; S22. Use functional programming to transform and process data, and convert external input data into the format and structure required by the script through mapping, filtering, and reduction; S23. For the external input data in the scheduled task and message queue, define the event type and event handler. When the scheduled task is triggered or the message in the message queue arrives, a corresponding event is generated. The event handler adds the external input data processed by S22 to the script execution context. S24. For the external input data of the script interface, the dynamic proxy technology is used to monitor and intercept, and the external input data processed by S22 is added to the script execution context.
4. The novel script development method based on JVM according to claim 1, characterized in that: In step S3, the step of constructing an abstract syntax tree includes: S31, decomposing the script content into different tags according to the grammatical rules of the script language; S32, converting the token into a hierarchical node tree, each node represents a grammatical structure in the script, recursively constructing an abstract syntax tree, each token is converted into a corresponding node according to its type and grammatical rule; S33. Classify the nodes according to their functions and grammatical roles, including variable nodes, member nodes, plus nodes, and asynchronous nodes.
5. A novel script development method based on JVM according to claim 4, characterized in that: In step S31, S311, set a left brace count and a right brace count; create a script content object to store the script content, and create a start tag and an end tag; Create a tag list to store tags, which record the type, start tag and end tag of a script; S312, when the start tag is not less than the end tag, the end tag is defined; S313, when the start mark is smaller than the end mark, the character string at the start mark position is detected to be empty or a line break, the start mark is increased by 1, and the start mark is detected and returned; if the character string at the start mark position is detected to be not empty or a line break, a marked start mark is set, the value of the mark is equal to the start mark, and it is determined whether it is a special type of mark, if it is a special type, the position of the start mark is moved, the mark is set, and the mark list is added according to the method and rules for determining the script content type; It is not a special type of tag. Iterate through all non-special tag types, move the start tag and end tag positions to after the matched characters, and add the tag to the tag list.
6. The novel script development method based on JVM according to claim 4, characterized in that: In step S33, the plus sign node obtains the nodes on the left and right sides of the plus sign for calculation. When one of the left and right sides is a string, the logic of string concatenation is performed; when one of the left and right values is a null value, an error is reported; otherwise, an addition operation is performed between numbers.
7. The novel script development method based on JVM according to claim 4, characterized in that: In step S33, when the member node obtains the member variable, the prohibited member variable name and the allowed member variable name of the current class are obtained from the context; When a member variable name is in the prohibited member variable name list, it will not be accessed; When the member variable name exists in the prohibited member variable name list, and the allowed member variable name list does not exist or the current member variable name is not in the allowed member variable name list, a null value is returned; When a custom annotation is used on a member variable, a null value is returned regardless of the configuration.
8. The novel script development method based on JVM according to claim 4, characterized in that: In step S33, the asynchronous node determines the tag type following the asynchronous symbol. When the tag type is a Lambda expression, the input parameters required by the Lambda expression are prepared and a new context is created. An asynchronous task is established, and the task content is a node that needs to be run for the operation. It is determined whether the current thread is in the thread pool. If so, it is run directly; otherwise, it is put into the thread pool for execution.
9. The novel script development method based on JVM according to claim 1, characterized in that: In step S4, S41, traverse all nodes of the abstract syntax tree, and extract the class, method, and member variable information corresponding to each node; S42. For each extracted class, method, and member variable, check whether they are in the allowed list of the configuration file; if they are in the allowed list and the configuration file only uses the allowed list, the node passes the security check; if they are not in the allowed list, but the configuration file only uses the prohibited list and the node is not in the prohibited list, the node passes the security check; S43. For nodes that fail the security check in S42, process them according to the rules of the configuration file; S44. Generate a security check report to record all nodes that failed the security check and their detailed information so that developers can review and adjust them.
10. The novel script development method based on JVM according to claim 1, characterized in that: In step S5, S51. Starting from the root node of the abstract syntax tree, recursively traverse each node; S52: For each node, execute corresponding logic processing according to the node type; Variable node: calculates the value of the variable and stores it in the context of the script execution; Member node: calculates the value of member variables and performs access control checks; Plus node: performs addition operations or string concatenation; Asynchronous node: submits asynchronous tasks to the thread pool for execution and manages the life cycle of asynchronous tasks; S53. For asynchronous nodes, their execution logic is specially processed to ensure that the asynchronous task can be submitted correctly and its result can be obtained when needed; when the asynchronous task is submitted, the context and related information of the task are recorded, and when the asynchronous task is completed, the result is stored back in the context of the script execution; S54. Collect the execution results of all nodes, including intermediate results and final results, and return them to the caller.
Citation Information
Cited By
Script access object white list verification method and device, medium and program product
CN121501635A
A script access object whitelist checking method, device, medium and program product
CN121501635B
Executive script full-path verification method and device based on executor rewriting, medium and program product
CN121524030A
Interpreter script full path verification method, device, medium and program product based on executor rewriting
CN121524030B