A method, apparatus, device, and medium for interacting with a database.
By configuring protection rules for the database and application system, filtering and processing secure data requests, the problem of increased database pressure under high concurrency with multiple users is solved, achieving non-functional protection for the system and database, and improving security and reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-22
- Publication Date
- 2026-03-13
AI Technical Summary
Under the pressure of high concurrency and constantly changing data requests from multiple users, business intelligence tools submit complex and dense requests to the database, leading to a continuous increase in database pressure and a lack of effective non-functional protection measures.
By using pre-configured database protection rules and application system protection rules, secure data requests are filtered out and transmitted through a connection pool. Feedback data is received and processed to intercept data requests that do not conform to the rules, thereby improving the protection of the system and database.
It protects the application system's memory and threads, ensures the security and reliability of the database, provides non-functional protection, and reduces the pressure on the database.
Smart Images

Figure CN116340403B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically to a method, apparatus, device, and medium for interacting with a database. Background Technology
[0002] In the current era of big data, business intelligence analytics tools are constantly driving enterprises to find new ways to digitally transform. However, with the continuous growth of data volume, business intelligence analytics tools need to meet the ever-changing and iterative needs of users. Under the pressure of high concurrency and constantly changing data requests from multiple users, the data requests submitted by business intelligence tools to the database are complex and frequent, leading to increasing database pressure and growing protection issues during database interactions. Summary of the Invention
[0003] This application provides a method, apparatus, device, and medium for interacting with a database, which addresses the problem that under high concurrency and constantly changing data requests from multiple users, business intelligence tools submit complex and intensive data requests to the database, leading to increasing database pressure and growing protection issues during database interaction.
[0004] In a first aspect, this application provides a method for interacting with a database, the method comprising:
[0005] Based on the database protection rules pre-configured for the database, determine the first secure data request among the received data requests that conforms to the database protection rules;
[0006] The first secure data request is sent to the database through a pre-created connection pool with the database;
[0007] The system receives feedback data corresponding to the first security data request sent by the database through the connection pool, and determines the application system protection rule corresponding to the feedback data, wherein the application system protection rule is a protection rule pre-configured for different data requests.
[0008] Identify the first feedback data that conforms to the protection rules of the application system from the feedback data, and process the first feedback data.
[0009] This application implements unified resource management during data transmission between the application system and the database, through a layer of database protection rules and a layer of application system protection rules. It parses the syntax tree corresponding to the data request, intercepts data requests that do not conform to the rules, improves the protection of application system memory, threads, and the database, and achieves non-functional protection for interaction with the database.
[0010] In one possible embodiment, determining that the first secure data request among the received data requests conforms to the database protection rules includes some or all of the following:
[0011] If the database protection rule includes a Cartesian product, and the syntax tree obtained by parsing the data request does not contain a Cartesian product, the data request is determined to be a first secure data request.
[0012] If the database protection rule includes a first data table threshold, and the number of data tables in the syntax tree obtained by parsing the data request does not exceed the first data table threshold, then the data request is determined to be a first secure data request.
[0013] If the database protection rule includes a second data table threshold, and the number of target data tables in the syntax tree obtained by parsing the data request does not exceed the second data table threshold, then the data request is determined to be a first secure data request, wherein the target data table is a data table in the data request whose data volume exceeds a preset data volume threshold;
[0014] If the database protection rule includes an execution plan, and the first condition is met during the analysis of the execution plan of the data request, then the data request is determined to be a first secure data request.
[0015] If the database protection rules include performance consumption, and the performance consumption of the application system does not exceed a preset performance consumption threshold when the data request is executed, then the data request is determined to be a first secure data request.
[0016] In one possible embodiment, the first condition includes: analyzing the execution plan of the data request by referencing the key index of the data table corresponding to the data request, and the analysis does not require a full table scan of the data table corresponding to the data request.
[0017] In one possible embodiment, determining the application system protection rule corresponding to the feedback data includes:
[0018] When the first security data request corresponding to the feedback data is a pagination request, it is determined that the application system protection rules include a single-page item count threshold, a single-page column count threshold, and a time threshold.
[0019] The determination of the first feedback data that conforms to the application system protection rules in the feedback data includes:
[0020] If the feedback data does not exceed the single-page item count threshold and the single-page column count threshold, and the time for receiving the feedback data is within the time threshold, then the feedback data is determined to be the first feedback data.
[0021] In one possible embodiment, the method further includes:
[0022] When the time threshold is exceeded, the database is notified to stop sending the feedback data;
[0023] Disconnect the connection pool.
[0024] In one possible embodiment, determining the application system protection rule corresponding to the feedback data includes:
[0025] When the first security data request corresponding to the feedback data is not a pagination request, the application system protection rule corresponding to the feedback data is determined to include the calculation of the data threshold and the time threshold.
[0026] The determination of the first feedback data that conforms to the application system protection rules in the feedback data includes:
[0027] If the feedback data does not exceed the calculated data threshold, and the time for receiving the feedback data is within the time threshold, then the feedback data is determined to be the first feedback data.
[0028] In one possible embodiment, the method further includes:
[0029] The parameters for establishing the connection pool are updated in real time.
[0030] Disconnect the connection pool;
[0031] Reconfigure the connection pool based on the updated parameters;
[0032] The parameters include some or all of the following: the maximum number of connections occupied by the application system in the database connection pool, the minimum number of connections occupied by the application system in the database connection pool, the number of active connections in the connection pool, the timeout threshold of the connection pool, the idle test time of the connection pool, the connection pool undergoing an activity test, and the connection pool undergoing a connection test.
[0033] In one possible embodiment, processing the first feedback data includes:
[0034] The first feedback data can be displayed in charts or subjected to multidimensional analysis.
[0035] Secondly, this application provides an apparatus for interacting with a database, the apparatus comprising:
[0036] The first secure data request determination module is used to determine, based on the database protection rules pre-configured for the database, the first secure data request among the received data requests that conforms to the database protection rules;
[0037] The sending module is used to send the first secure data request to the database through a pre-created connection pool with the database;
[0038] The feedback data receiving module is used to receive feedback data corresponding to the first security data request sent by the database through the connection pool, and to determine the application system protection rule corresponding to the feedback data, wherein the application system protection rule is a protection rule pre-configured for different data requests;
[0039] The module for determining the first feedback data is used to determine the first feedback data that conforms to the protection rules of the application system in the feedback data, and to process the first feedback data.
[0040] Thirdly, this application provides an electronic device, comprising:
[0041] Memory, used to store program instructions;
[0042] A processor is configured to invoke program instructions stored in the memory and execute the steps of the method described in any one of the first aspects according to the obtained program instructions.
[0043] Fourthly, this application provides a computer-readable storage medium storing a computer program, the computer program including program instructions, which, when executed by a computer, cause the computer to perform the method described in any one of the first aspects.
[0044] Fifthly, this application provides a computer program product comprising: computer program code, which, when run on a computer, causes the computer to perform the method described in any one of the first aspects. Attached Figure Description
[0045] Figure 1 A flowchart illustrating a method for interacting with a database, as provided in this application embodiment;
[0046] Figure 2 A topology diagram of a method for interacting with a database provided in an embodiment of this application;
[0047] Figure 3 A structural diagram of an apparatus for interacting with a database, provided in an embodiment of this application;
[0048] Figure 4 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. Unless otherwise specified, the embodiments and features in the embodiments of this application can be arbitrarily combined with each other. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.
[0050] The terms "first" and "second" in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising" and any variations thereof are intended to cover non-exclusive protection. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices. The term "multiple" in this application can mean at least two, for example, two, three, or more, and the embodiments of this application do not impose limitations.
[0051] The data collection, dissemination, and use in this application all comply with relevant national laws and regulations.
[0052] Before introducing a method for interacting with a database provided in the embodiments of this application, the technical background of the embodiments of this application will be described in detail below for ease of understanding.
[0053] In today's information explosion era, business intelligence (BII) analytics tools are constantly driving enterprises to find new ways to digitally transform. BII refers to tools that utilize online analytics and data visualization technologies to analyze data and transform it into knowledge to help businesses make decisions. However, with the continuous growth of data volume, BII tools need to meet the ever-changing and iterative needs of users. Under the pressure of high concurrency and constantly changing data requests from multiple users, the data requests submitted to the database by BII tools are complex and intensive, leading to increasing database pressure. Currently, there are no specific non-functional protection measures for system security and reliability in BII scenarios. Non-functional protection refers to characteristics beyond functional requirements that are necessary to meet user business needs, including security, reliability, and robustness.
[0054] See below. Figure 1This application provides a method for interacting with a database, applied to an application system, the method comprising:
[0055] Step 101: Based on the database protection rules pre-configured for the database, determine the first secure data request among the received data requests that conforms to the database protection rules.
[0056] Specifically, database protection rules are database protection rules pre-configured for databases in the protection rule configuration center. After the application system receives a data request, it selects the first secure data request that conforms to the database protection rules from the received data requests.
[0057] The database protection rules include at least one rule. As an optional implementation, the first secure data request that conforms to the database protection rules among the received data requests includes some or all of the following. It should be noted that the database protection rules in this application are not limited to the following rules.
[0058] Rule 1: If the database protection rule includes a Cartesian product, and the syntax tree obtained by parsing the data request does not contain a Cartesian product, the data request is determined to be a first secure data request.
[0059] Specifically, when configuring database protection rules, if a rule is configured to block Cartesian products, then if there is no Cartesian product in the syntax tree obtained by parsing a data request, the data request is considered a first-level secure data request; if there is a Cartesian product in the syntax tree obtained by parsing a data request, the data request is not considered a first-level secure data request, and the application system needs to block the data request.
[0060] Rule 2: If the database protection rule includes a first data table threshold, and the number of data tables in the syntax tree obtained by parsing the data request does not exceed the first data table threshold, then the data request is determined to be a first secure data request.
[0061] Specifically, when configuring database protection rules, if a rule with a first data table threshold is configured, then when parsing the syntax tree obtained from a data request, if the number of data tables does not exceed the first data table threshold, the data request is determined to be a first-level secure data request; if the number of data tables exceeds the first data table threshold, the data request is determined to be a third-level secure data request, and the data request is blocked. The first data table threshold is a pre-set upper limit on the number of associated data tables in each data request.
[0062] Rule 3: If the database protection rule includes a second data table threshold, and the number of target data tables in the syntax tree obtained by parsing the data request does not exceed the second data table threshold, then the data request is determined to be a first secure data request, wherein the target data table is a data table in the data request whose data volume exceeds a preset data volume threshold.
[0063] Specifically, when configuring database protection rules, if a rule with a second data table threshold is configured, then when parsing the syntax tree obtained from a data request, if the number of target data tables does not exceed the second data table threshold, the data request is determined to be a first-level secure data request; if the number of target data tables exceeds the second data table threshold, the data request is determined not to be a first-level secure data request, and the data request is blocked. Here, the second data table threshold is a pre-set upper limit on the number of target data tables in each data request; the data volume threshold is a pre-set upper limit on the data volume of each data table.
[0064] Rule 4: If the database protection rule includes an execution plan, and the first condition is met during the analysis of the execution plan of the data request, then the data request is determined to be a first secure data request.
[0065] Specifically, when configuring database protection rules, if a rule is configured to determine whether to perform plan analysis, first determine whether to perform plan analysis. If plan analysis is required, analyze the execution plan of the data request.
[0066] As an optional implementation, the first condition includes: analyzing the execution plan of the data request by referencing the key index of the data table corresponding to the data request, and the analysis does not require a full table scan of the data table corresponding to the data request.
[0067] Specifically, when the application system analyzes the execution plan, if it references a key index of the data table corresponding to the data request, and the analysis does not require a full table scan of the data table corresponding to the data request, the data request is determined to be a first-level safe data request. If it does not reference a key index of the data table corresponding to the data request, or if the analysis requires a full table scan of the data table corresponding to the data request, the data request is determined not to be a first-level safe data request, and the data request is intercepted.
[0068] Rule 5: If the database protection rule includes performance consumption, and the performance consumption of the application system does not exceed the preset performance consumption threshold when the data request is executed, then the data request is determined to be a first secure data request.
[0069] Specifically, when configuring database protection rules, if a performance consumption cost rule is configured, that is, when executing a data request, the cost of the data request is obtained. If the performance consumption of the application system does not exceed the preset performance consumption threshold, the data request is determined to be a first-level safe data request. If the performance consumption of the application system exceeds the preset performance consumption threshold, the data request is determined not to be a first-level safe data request, and the data request is blocked. The performance consumption threshold is the preset upper limit of the cost.
[0070] Step 102: Send the first secure data request to the database through a pre-created connection pool with the database.
[0071] Specifically, when data is transmitted between the application system and the database, a connection pool is required. A connection pool is created in advance for the database and the application system. Once the connection pool is successfully created, the application system sends the first secure data request selected in step 101 to the database through the connection pool.
[0072] As an optional implementation, the method further includes: when the parameters for establishing the connection pool are updated in real time; disconnecting the connection pool; and reconfiguring the connection pool according to the updated parameters; wherein the parameters include some or all of the following: the maximum number of connections occupied by the application system in the database connection pool, the minimum number of connections occupied by the application system in the database connection pool, the number of active connections in the connection pool, the timeout threshold of the connection pool, the idle test time of the connection pool, the connection pool performing an activity test, and the connection pool performing a connection test.
[0073] That is, when the connection pool rules are updated, the physical connections of the entire connection pool need to be disconnected, and a new connection pool needs to be generated according to the updated connection pool rules.
[0074] Step 103: Receive feedback data corresponding to the first security data request sent by the database through the connection pool, and determine the application system protection rule corresponding to the feedback data, wherein the application system protection rule is a protection rule pre-configured for different data requests.
[0075] Specifically, application system protection rules are pre-configured protection rules for application systems in the protection rule configuration center. Different application system protection rules correspond to different data requests. After receiving feedback data from the database, the application system determines the application system protection rule for the first security data request based on the first security data request corresponding to the feedback data.
[0076] As an optional implementation method, application system protection rules include, but are not limited to:
[0077] Rule 1: When the first security data request corresponding to the feedback data is a pagination request, the application system protection rule is determined to include a single-page item count threshold, a single-page column count threshold, and a time threshold.
[0078] Specifically, the single-page item count threshold is a pre-set upper limit for the number of feedback data items returned per page; the single-page column count threshold is a pre-set upper limit for the number of columns of feedback data returned per page; and the time threshold is a pre-set upper limit for the time it takes for the application system to receive feedback data.
[0079] Rule 2: When the first security data request corresponding to the feedback data is not a pagination request, the application system protection rule corresponding to the feedback data is determined by calculating the data threshold and the time threshold.
[0080] Specifically, the data calculation threshold is the upper limit of the total amount of data that the application system calculates in the feedback data. As an optional implementation, the data calculation threshold includes a data entry threshold and a data column threshold. That is, the data entry threshold is the upper limit of the number of data entries that the application system can calculate when the first security data request corresponding to the feedback data is not a pagination request; the data column threshold is the upper limit of the number of data columns that the application system can calculate when the first security data request corresponding to the feedback data is not a pagination request.
[0081] Step 104: Determine the first feedback data that conforms to the application system protection rules in the feedback data, and process the first feedback data.
[0082] Specifically, when the application system protection rule is rule one in step 103 above, as an optional implementation, if the feedback data does not exceed the single-page number threshold and the single-page column threshold, and the time for receiving the feedback data is within the time threshold, then the feedback data is determined to be the first feedback data.
[0083] When the application system protection rule is rule two in step 103 above, as an optional implementation, if the feedback data does not exceed the calculated data threshold and the time for receiving the feedback data is within the time threshold, then the feedback data is determined to be the first feedback data.
[0084] Specifically, when the first security data request corresponding to the feedback data is a pagination request, the first feedback data is returned based on the single-page row count threshold and the single-page column count threshold. When the first security data request corresponding to the feedback data is not a pagination request, the first feedback data is returned based on the calculated data row count threshold and the calculated data column count threshold, thus protecting the application system's memory. Secondly, returning the first feedback data within the time threshold protects the corresponding thread of the application system while ensuring the security of the database.
[0085] As an optional implementation, the method further includes: when the time threshold is exceeded, notifying the database to stop sending the feedback data; and disconnecting the connection pool.
[0086] The application system synchronizes the time threshold to the database. If the time for receiving feedback data exceeds the time threshold, the connection pool is disconnected, the corresponding data request resources are closed, and the database stops sending feedback data.
[0087] As an optional implementation, the first feedback data is processed, including: displaying the first feedback data in charts or performing multidimensional analysis.
[0088] Specifically, the process of processing the first feedback data by the application system also includes data processing, which transforms the data into the data that the user needs.
[0089] See Figure 2 This application pre-configures database protection rules and application system protection rules in the protection rule configuration center. During the data transmission between the application system and the database, the data is protected by a layer of database protection rules and a layer of application system protection rules. This enables unified resource management, parsing of the syntax tree corresponding to the data request, and interception of data requests that do not conform to the rules. This improves the protection of application system memory, threads, and the database, and achieves non-functional protection for interaction with the database.
[0090] Based on the same inventive concept, embodiments of this application provide a device for interacting with a database. Please refer to... Figure 3 The device includes:
[0091] The first secure data request determination module 301 is used to determine, according to the database protection rules pre-configured for the database, the first secure data request among the received data requests that conforms to the database protection rules;
[0092] The sending module 302 is used to send the first secure data request to the database through a pre-created connection pool with the database;
[0093] The feedback data receiving module 303 is used to receive feedback data corresponding to the first security data request sent by the database through the connection pool, and determine the application system protection rule corresponding to the feedback data, wherein the application system protection rule is a protection rule pre-configured for different data requests;
[0094] The first feedback data determination module 304 is used to determine the first feedback data in the feedback data that conforms to the protection rules of the application system, and to process the first feedback data.
[0095] Optionally, the first secure data request determination module 301 is specifically used to: determine a first secure data request among the received data requests that conforms to the database protection rules, including some or all of the following:
[0096] If the database protection rule includes a Cartesian product, and the syntax tree obtained by parsing the data request does not contain a Cartesian product, the data request is determined to be a first secure data request.
[0097] If the database protection rule includes a first data table threshold, and the number of data tables in the syntax tree obtained by parsing the data request does not exceed the first data table threshold, then the data request is determined to be a first secure data request.
[0098] If the database protection rule includes a second data table threshold, and the number of target data tables in the syntax tree obtained by parsing the data request does not exceed the second data table threshold, then the data request is determined to be a first secure data request, wherein the target data table is a data table in the data request whose data volume exceeds a preset data volume threshold;
[0099] If the database protection rule includes an execution plan, and the first condition is met during the analysis of the execution plan of the data request, then the data request is determined to be a first secure data request.
[0100] If the database protection rules include performance consumption, and the performance consumption of the application system does not exceed a preset performance consumption threshold when the data request is executed, then the data request is determined to be a first secure data request.
[0101] Optionally, the first condition includes: analyzing the execution plan of the data request by referencing the key index of the data table corresponding to the data request, and the analysis does not require a full table scan of the data table corresponding to the data request.
[0102] Optionally, the feedback data receiving module 303 is specifically used for:
[0103] When the first security data request corresponding to the feedback data is a pagination request, it is determined that the application system protection rules include a single-page item count threshold, a single-page column count threshold, and a time threshold.
[0104] The determination of the first feedback data that conforms to the application system protection rules in the feedback data includes:
[0105] If the feedback data does not exceed the single-page item count threshold and the single-page column count threshold, and the time for receiving the feedback data is within the time threshold, then the feedback data is determined to be the first feedback data.
[0106] Optionally, the feedback data receiving module 303 is further configured to: notify the database to stop sending the feedback data when the time threshold is exceeded; and disconnect the connection pool.
[0107] Optionally, the feedback data receiving module 303 is specifically used to: when the first security data request corresponding to the feedback data is not a paging request, determine the application system protection rule corresponding to the feedback data, including calculating the data threshold and the time threshold.
[0108] Optionally, the first feedback data module 304 is specifically used to determine the feedback data as the first feedback data if the feedback data does not exceed the calculated data threshold and the time for receiving the feedback data is within the time threshold.
[0109] Optionally, the feedback data receiving module 303 is further configured to: when the parameters for establishing the connection pool are updated in real time; disconnect the connection pool; and reconfigure the connection pool according to the updated parameters;
[0110] The parameters include some or all of the following: the maximum number of connections occupied by the application system in the database connection pool, the minimum number of connections occupied by the application system in the database connection pool, the number of active connections in the connection pool, the timeout threshold of the connection pool, the idle test time of the connection pool, the connection pool undergoing an activity test, and the connection pool undergoing a connection test.
[0111] Optionally, the first feedback data module 304 is specifically used to display the first feedback data in charts or perform multidimensional analysis.
[0112] Based on the same inventive concept, this application provides an electronic device that can realize the functions of the device for interacting with a database as described above. Please refer to... Figure 4 The device includes a processor 401 and a memory 402.
[0113] Memory 402 is used to store instructions;
[0114] The processor 401 is used to execute instructions stored in the memory 402. When the processor 401 executes the instructions stored in the memory, it causes the device to perform the method of interacting with the database as described in any of the preceding claims.
[0115] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium. The computer program product includes computer program code, which, when executed on a computer, causes the computer to perform any of the methods for interacting with a database as described above. Since the principle of the problem solved by the above-described computer-readable storage medium is similar to the method for interacting with a database, the implementation of the above-described computer-readable storage medium can be referred to the implementation of the method, and repeated details will not be elaborated further.
[0116] Based on the same inventive concept, this application also provides a computer program product, which includes computer program code. When the computer program code is run on a computer, it causes the computer to execute any of the methods for interacting with a database as described above. Since the principle of solving the problem by the above-described computer program product is similar to the method of interacting with a database, the implementation of the above-described computer program product can be referred to the implementation of the method, and repeated details will not be repeated.
[0117] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0118] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0119] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0120] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of user-operated steps to be executed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0121] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method of interacting with a database, characterized by, The method comprises: According to the database protection rules configured in advance for the database, the first safe data request meeting the database protection rules in the received data request is determined, comprising: if the database protection rules include a Cartesian product, and the syntax tree obtained by parsing the data request does not include a Cartesian product, it is determined that the data request is a first safe data request; if the database protection rules include a first data table threshold, and the number of data tables in the syntax tree obtained by parsing the data request does not exceed the first data table threshold, it is determined that the data request is a first safe data request; if the database protection rules include a second data table threshold, and the number of target data tables in the syntax tree obtained by parsing the data request does not exceed the second data table threshold, it is determined that the data request is a first safe data request, wherein the target data table is a data table in the data request whose data volume exceeds a preset data volume threshold; if the database protection rules include an execution plan, and the execution plan of the data request meets the first condition during the analysis process, it is determined that the data request is a first safe data request; if the database protection rules include performance consumption, and the performance consumption of the application system during the execution of the data request does not exceed a preset performance consumption threshold, it is determined that the data request is a first safe data request; The first safe data request is sent to the database through the pre-created connection pool between the database; The feedback data corresponding to the first safe data request sent by the database through the connection pool is received, and the application system protection rules corresponding to the feedback data are determined, wherein the application system protection rules are protection rules configured in advance for different data requests; The first feedback data meeting the application system protection rules in the feedback data is determined, and the first feedback data is processed.
2. The method of claim 1, wherein, The first condition includes: analyzing the execution plan of the data request by referencing the key index of the data table corresponding to the data request, and not needing to perform full table scanning on the data table corresponding to the data request during the analysis.
3. The method of claim 1, wherein, The determination of the application system protection rules corresponding to the feedback data comprises: When the first safe data request corresponding to the feedback data is a paging request, it is determined that the application system protection rules include a single-page number threshold, a single-page column number threshold, and a time threshold; The determination of the first feedback data meeting the application system protection rules in the feedback data comprises: If the feedback data does not exceed the single-page number threshold and the single-page column number threshold, and the time of receiving the feedback data is within the time threshold, it is determined that the feedback data is the first feedback data.
4. The method of claim 3, wherein, The method further comprises: When the time threshold is exceeded, the database is notified to stop sending the feedback data; The connection pool is disconnected.
5. The method of claim 1, wherein, The determination of the application system protection rules corresponding to the feedback data comprises: When the first safe data request corresponding to the feedback data is not a paging request, it is determined that the application system protection rules corresponding to the feedback data include a calculation data threshold and a time threshold; The determining the first feedback data in the feedback data that meets the application system protection rule comprises: If the feedback data does not exceed the calculation data threshold, and the time of receiving the feedback data is within the time threshold, the feedback data is determined as the first feedback data.
6. The method of claim 1, wherein, The method further comprises: When the parameters of the connection pool are updated in real time; Disconnect the connection pool; Reconfigure the connection pool according to the updated parameters; The parameters include some or all of the following: the maximum number of connections occupied by the application system to the connection pool of the database, the minimum number of connections occupied by the application system to the connection pool of the database, the active connection number of the connection pool, the timeout time threshold of the connection pool, the idle test time of the connection pool, the active test of the connection pool, and the connection test of the connection pool.
7. The method according to any one of claims 1 to 6, wherein The processing of the first feedback data comprises: Chart display or multidimensional analysis is performed on the first feedback data.
8. An apparatus to interact with a database, the apparatus comprising: The device comprises: A first secure data request module is configured to determine a first secure data request in a received data request that meets a database protection rule pre-configured for a database, including: if the database protection rule includes a Cartesian product, and the syntax tree obtained by parsing the data request does not include a Cartesian product, the data request is determined as a first secure data request; if the database protection rule includes a first data table threshold, and the number of data tables in the syntax tree obtained by parsing the data request does not exceed the first data table threshold, the data request is determined as a first secure data request; if the database protection rule includes a second data table threshold, and the number of target data tables in the syntax tree obtained by parsing the data request does not exceed the second data table threshold, the data request is determined as a first secure data request, wherein the target data table is a data table in the data request whose data volume exceeds a preset data volume threshold; if the database protection rule includes an execution plan, and the execution plan of the data request satisfies a first condition during analysis, the data request is determined as a first secure data request; if the database protection rule includes performance consumption, and the performance consumption of the application system when executing the data request does not exceed a preset performance consumption threshold, the data request is determined as a first secure data request; A sending module is configured to send the first secure data request to the database through a connection pool pre-created between the database; A feedback data receiving module is configured to receive feedback data corresponding to the first secure data request sent by the database through the connection pool, and determine an application system protection rule corresponding to the feedback data, wherein the application system protection rule is a protection rule pre-configured for different data requests; A first feedback data determining module is configured to determine first feedback data in the feedback data that meets the application system protection rule, and process the first feedback data.
9. An electronic device, comprising: It comprises: A memory for storing program instructions; A processor configured to invoke program instructions stored in the memory to perform the steps of the method of any of claims 1-7 in accordance with the obtained program instructions.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program comprising program instructions that, when executed by a computer, cause the computer to perform the method of any of claims 1-7.
11. A computer program product, characterised in that, The computer program product comprises computer program code which, when run on a computer, causes the computer to perform the method of any of claims 1-7.
Citation Information
Patent Citations
Web safety-oriented database security protection method and system
CN103473353A
Paging query method and device
CN107451227A