A result set generation method, device, equipment and storage medium
By reusing the header information in the preset cache area, the problem of missing headers in the database security audit system when parsing the DB2 database protocol is solved, the accuracy of the audit log and the matching effect of the security policy are improved, and the database security audit system is improved. performance.
Patent Information
- Application Number
- CN202111564469.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-12-20
AI Technical Summary
When the existing database security audit system parses the DB2 database protocol, the response messages to non-first-time queries may lack headers, resulting in reduced accuracy of the generated audit logs, thereby reducing the matching accuracy of security policies.
By reusing the header information stored in the preset cache area, the target table data is merged to generate a complete result set, thereby improving the accuracy of the audit log.
This ensures the integrity of the result set, improves the accuracy of matching security policies based on audit logs, and enhances the performance of the database security audit system.
Smart Images

Figure CN114238244B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of network security technology, and in particular to a result set generation method, device, equipment and storage medium. Background Art
[0002] With the continuous development of database technology, the application of database systems is becoming increasingly large, and more and more databases are being used in various industries. As a result, the safe and stable operation of databases has become increasingly important. Factors that threaten database security include unauthorized access operations by business personnel, abuse of authority, insufficient audit clues, etc. The database security audit system can help users plan and prevent by recording, analyzing and reporting the business personnel's access to the database, providing a strong guarantee for the safe operation of the database system.
[0003] At present, in the related technology, the principle of the database security audit system is to restore the network message in the network environment according to the database protocol structure, parse a series of data as the audit log, match the security policy based on the audit log, and then prompt abnormal behavior and other operations. In the prior art, for some special database protocols, such as the database protocol of the DB2 database, when restoring the network message according to the database protocol structure of the DB2 database, when parsing the response message of the non-first query, the result set may lack the header, resulting in a reduction in the accuracy of the generated audit log, thereby reducing the accuracy of matching the security policy based on the audit log.
[0004] Therefore, how to generate a complete result set so that the audit log generated based on the result set is more accurate, thereby improving the accuracy of matching security policies, is a technical problem that urgently needs to be solved. Summary of the invention
[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a result set generation method, apparatus, device and storage medium, which can reuse the header information stored in a preset cache area, ensure the integrity of the generated result set, and improve the accuracy of the audit log generated based on the complete result set, thereby improving the accuracy of matching security policies based on the audit log.
[0006] In a first aspect, the present disclosure provides a result set generation method, the method comprising:
[0007] Obtaining a first query request message, and parsing the first query request message to obtain a target query field of a database query statement corresponding to the first query request message; wherein the target query field has a corresponding relationship with at least one header information in a target data table;
[0008] Determine whether the preset cache area corresponding to the target data table stores the same header information as the target query field; wherein the preset cache area is used to store the header information obtained by parsing the query response message corresponding to the target data table;
[0009] If it is determined that the header information is stored in the preset cache area, acquiring the header information from the preset cache area;
[0010] The header information is combined with the target table data to obtain a target result set; wherein the target table data includes table data parsed from a query response message corresponding to the first query request message, and the target result set is used to generate an audit log.
[0011] In an optional implementation manner, the method further includes:
[0012] If it is determined that the preset cache area corresponding to the target data table does not contain the same header information as the target query field, then obtaining the target header information; wherein the target header information includes the header information parsed from the query response message corresponding to the first query request message;
[0013] The target table header information is stored in a preset cache area corresponding to the target data table.
[0014] In an optional implementation manner, the obtaining the first query request message and parsing the first query request message further includes:
[0015] Obtaining first information corresponding to the first query request message; wherein the first information includes a database query statement corresponding to the first query request message and an instance name of a database where the target data table is located, the database query statement includes the target query field and a table name field, and the table name field is a data table identifier corresponding to the first query request message;
[0016] The first information is stored in a local cache; wherein the local cache is used to store information obtained by parsing the query request message and the query response message.
[0017] In an optional implementation manner, after merging the header information with the target table data to obtain the target result set, the step includes:
[0018] Generate an audit log based on the target result set and the first information and second information parsed from a query response message corresponding to the first query request message; wherein the second information includes response status information corresponding to the query response message;
[0019] The first information and the second information in the local cache and the target table data in the target result set are deleted.
[0020] In an optional implementation manner, after generating the audit log based on the first information and the second information parsed from the query response message corresponding to the first query request message, the method includes:
[0021] Sending the audit log to an audit module of a database audit system;
[0022] Based on the audit log, a security policy is matched; wherein the security policy is used to operate on abnormal behavior of the database.
[0023] In a second aspect, the present disclosure provides a result set generating device, the device comprising:
[0024] A parsing module, configured to obtain a first query request message, and parse the first query request message to obtain a target query field of a database query statement corresponding to the first query request message; wherein the target query field has a corresponding relationship with at least one header information in a target data table;
[0025] A determination module, used to determine whether the preset cache area corresponding to the target data table stores the same header information as the target query field; wherein the preset cache area is used to store the header information obtained by parsing the query response message corresponding to the target data table;
[0026] A first acquisition module, configured to acquire the header information from the preset cache area if it is determined that the header information is stored in the preset cache area;
[0027] A merging module is used to merge the table header information with the target table data to obtain a target result set; wherein the target table data includes table data parsed from the query response message corresponding to the first query request message, and the target result set is used to generate an audit log.
[0028] In a third aspect, the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements any of the methods described above.
[0029] In a fourth aspect, the present disclosure provides a device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, any of the methods described above is implemented.
[0030] In a fifth aspect, the present disclosure provides a computer program product, wherein the computer program product comprises a computer program / instructions, and when the computer program / instructions are executed by a processor, any of the methods described above is implemented.
[0031] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has at least the following advantages:
[0032] The embodiment of the present disclosure provides a result set generation method, first, obtain a first query request message, and parse the first query request message to obtain a target query field of a database query statement corresponding to the first query request message, wherein the target query field has a corresponding relationship with at least one header information in a target data table, then determine whether a preset cache area corresponding to the target data table stores header information identical to the target query field, wherein the preset cache area is used to store header information obtained by parsing a query response message corresponding to the target data table, if it is determined that the header information is stored in the preset cache area, then obtain the header information from the preset cache area, and then merge the header information with the target table data to obtain a target result set, wherein the target table data includes the table data parsed from the query response message corresponding to the first query request message, and the target result set is used to generate an audit log. It can be seen that the embodiment of the present disclosure can reuse the header information stored in the preset cache area, ensure the integrity of the generated result set, improve the accuracy of the audit log generated based on the complete result set, and thus improve the accuracy of matching security policies based on the audit log. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0034] 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 will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0035] Figure 1 A flowchart of a result set generation method provided in an embodiment of the present disclosure;
[0036] Figure 2 A flowchart of another result set generation method provided by an embodiment of the present disclosure;
[0037] Figure 3 A schematic diagram of the structure of a result set generating device provided in an embodiment of the present disclosure;
[0038] Figure 4A schematic diagram of the structure of a result set generating device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0039] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0040] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0041] In order to ensure the integrity of the generated result set, make the audit log generated based on the result set more accurate, and thus improve the accuracy of matching security policies based on the audit log, the embodiment of the present disclosure provides a result set generation method, first, obtain a first query request message, and parse the first query request message to obtain a target query field of a database query statement corresponding to the first query request message, wherein the target query field has a corresponding relationship with at least one header information in a target data table, and then determine whether a preset cache area corresponding to the target data table stores header information identical to the target query field, wherein the preset cache area is used to store header information obtained by parsing a query response message corresponding to the target data table, if it is determined that the header information is stored in the preset cache area, obtain the header information from the preset cache area, and then merge the header information with the target table data to obtain a target result set, wherein the target table data includes table data parsed from the query response message corresponding to the first query request message, and the target result set is used to generate the audit log.
[0042] It can be seen that the embodiment of the present disclosure can reuse the header information stored in the preset cache area, ensure the integrity of the generated result set, improve the accuracy of the audit log generated based on the complete result set, and thus improve the accuracy of matching security policies based on the audit log.
[0043] Based on this, the present disclosure provides a result set generation method, referring to Figure 1 , is a flowchart of a result set generation method provided by an embodiment of the present disclosure, the method comprising:
[0044] S101, obtaining a first query request message, and parsing the first query request message to obtain a target query field of a database query statement corresponding to the first query request message.
[0045] The target query field has a corresponding relationship with at least one header information in the target data table.
[0046] The result set generation method provided by the embodiment of the present disclosure can be applied to a database security audit system, wherein the database security audit system is used to ensure the safe and stable operation of the database system. The database security audit system can realize online monitoring and protection of multiple types of database systems, such as Oracle database, DB2 database, etc. For database protocols corresponding to different databases, the database security audit system has different specific audit methods and audit performances for the database. The database security audit system may include a system setting module, a message parsing module, a log generation module, an audit module, etc.
[0047] In actual applications, when a database is running, a large number of network messages are generated between the request end and the response end of the database, wherein the network messages may include request messages and response messages having a corresponding relationship, and one request message corresponds to one or more response messages.
[0048] In an embodiment of the present disclosure, a method for obtaining a first query request message may include obtaining any one query request message as the first request message from a large number of query messages generated when a database executes a database query statement, wherein the query message may include a query request message and a query response message having a corresponding relationship, and one query request message corresponds to one or more query response messages.
[0049] In the disclosed embodiment, based on the parsing message module of the database security audit system, the first query request message can be parsed to obtain the database query statement corresponding to the first query request message, wherein the database query statement is a string of characters, which can represent the table identifier (such as the table name) of the data table to be queried based on the database query statement, the column title of the data table to be queried, the query conditions and other information. For example, if the character string corresponding to the database query statement is select ID from users where age>15, then the character string corresponding to the database query statement can represent the data with the column title ID that matches age>15 for the query of the data table users.
[0050] In the embodiment of the present disclosure, the target query field of the database query statement corresponding to the first query request message has a corresponding relationship with at least one header information in the target data table, and the target query field is used to characterize the header information of the target data table, wherein the header information of the target data table may include the column titles of the target data table, for example, may include ID, age, gender, etc.
[0051] For example, assuming that the target data table is table a, the header information in table a includes ID, age, and gender. After parsing the first query request message, the corresponding database query statement string is select ID, age from a. The target query fields of the obtained database query statement are ID and age.
[0052] In an optional implementation, a first query request message is obtained and parsed, and first information corresponding to the first query request message is obtained. Then, the first information is stored in a local cache, and the local cache is used to store information obtained by parsing the query request message and the query response message.
[0053] The first information includes a database query statement corresponding to the first query request message and an instance name of a database where a target data table is located. The database query statement includes a target query field and a table name field. The table name field is a data table identifier corresponding to the first query request message.
[0054] In the disclosed embodiment, after parsing the first query request message, the character string corresponding to the database query statement obtained also includes a table name field, wherein the table name field is used to represent the data table identifier (such as table a, table b, etc.) queried based on the database query statement. After parsing the first query request message, the instance name of the database where the target data table is located can also be obtained, wherein a database can include multiple database instances, a data table corresponds to a database instance, and a database instance can correspond to multiple data tables.
[0055] In the disclosed embodiment, the first query request message is parsed to obtain a database query statement corresponding to the first query request message and an instance name of the database where the target data table is located. It may also include information such as a database user name and a database password. Various types of information obtained by parsing the first query request message are stored as first information in a local cache, wherein the local cache is also used to store information obtained by parsing the query response message.
[0056] S102: Determine whether the preset cache area corresponding to the target data table stores header information identical to the target query field.
[0057] The preset cache area is used to store the header information obtained by parsing the query response message corresponding to the target data table.
[0058] In the disclosed embodiment, a preset cache area is set in the local cache of the database security audit system. For example, the preset cache area can be set in the local cache for storing information obtained by parsing the query request message and the query response message, etc. Among them, one data table can correspond to one preset cache area, and multiple data tables in the same session can correspond to one preset cache area, and the data tables are distinguished by their table names; etc.
[0059] In the disclosed embodiment, when executing a database query statement for a data table, multiple pairs of query request response messages will be generated, and one query request message corresponds to one or more query response messages. Based on the parsing message module of the database security audit system, when parsing the query response message corresponding to the target data table, when parsing the query response message that meets the preset conditions, the header information of the target data table can be obtained, and the obtained header information of the target data table is stored in the preset cache area corresponding to the target data table. Among them, the query response message that meets the preset conditions may include a query response message corresponding to the first query of the target query field of the target data table; a query response message corresponding to the Nth query of the target query field of the target data table that is preset; and so on.
[0060] For example, assuming that query response message A is generated for the first query of the target query fields ID and age of data table a, when query response message A is parsed, the header information (ID, age) of data table a can be obtained, and the header information is stored in the preset cache area corresponding to data table a. When the target query fields ID and age of data table a are queried again, the corresponding query response message B is generated. When query response message B is parsed, the header information (such as ID, age) of data table a may not be obtained.
[0061] In the disclosed embodiment, based on the target query field of the database query statement corresponding to the first query request message obtained in S101 above, the header information of the target data table corresponding to the target query field is determined, and a query is made in the preset cache area corresponding to the target data table whether the header information identical to the target query field is stored.
[0062] For example, based on the example in S101 above, the target query fields of the database query statement corresponding to the first query request message are ID and age, and the header information of the target data table corresponding to the target query fields ID and age is determined to be ID and age. It is queried in the preset cache area corresponding to the target data table whether header information identical to ID and age is stored.
[0063] S103: If it is determined that the header information is stored in the preset cache area, obtain the header information from the preset cache area.
[0064] In an embodiment of the present disclosure, if it is determined that the header information is stored in the preset cache area, it means that the query response message corresponding to the target data table does not meet the preset conditions. When parsing the query response message, the header information of the target data table may not be obtained. In this case, the header information can be directly obtained from the preset cache area.
[0065] For example, based on the above example, it is assumed that the preset cache area stores the data table a header information (ID, age) obtained by parsing the query response message A corresponding to the data table a, obtains the query request message B, and parses the query request message B to obtain the target query fields of the database query statement corresponding to the query request message B, which are ID and age. Since the preset cache area stores the header information (ID, age), it can be determined that the preset cache area stores the same header information as the target query fields ID and age, and the target header information (ID, age) can be directly obtained from the preset cache area.
[0066] In an optional implementation, if it is determined that there is no header information identical to the target query field in the preset cache area corresponding to the target data table, the target header information is obtained, and then the target header information is stored in the preset cache area corresponding to the target data table.
[0067] The target header information includes header information parsed from the query response message corresponding to the first query request message.
[0068] In an embodiment of the present disclosure, if it is determined that there is no header information identical to the target query field in the preset cache area corresponding to the target data table, it means that the query response message corresponding to the target data table is a query response message that meets the preset conditions. Based on the parsing of the query response message, the header information of the target data table can be obtained, the target header information is obtained, and the target header information is stored in the preset cache area corresponding to the target data table.
[0069] For example, based on the above example, query request message A is obtained, and query request message A is parsed to obtain the target query fields of the database query statement corresponding to query request message A, which are ID and age. Assuming that it is determined that there is no header information identical to the target query fields ID and age in the preset cache area corresponding to data table a, then based on parsing the query response message A corresponding to query request message A, the target header information (ID, age) can be obtained, and the target header information (ID, age) is stored in the preset cache area corresponding to data table a.
[0070] S104, merging the header information with the target table data to obtain a target result set.
[0071] The target table data includes table data parsed from the query response message corresponding to the first query request message, and the target result set is used to generate an audit log.
[0072] In the embodiment of the present disclosure, the query response message corresponding to the first query request message is parsed to obtain a result set, and the result set can be used to generate an audit log. If the query response message is a query response message that meets the preset conditions, the header information of the data table can be obtained when the query response message is parsed, and the query response message is parsed, and the result set obtained includes the table data of the data table and the header information of the data table; if the query response message is a query response message that does not meet the preset conditions, the header information of the data table may not be obtained when the query response message is parsed, and the query response message is parsed, and the result set obtained only includes the table data of the data table.
[0073] In the disclosed embodiment, for a query response message that does not meet the preset conditions and from which the header information of the target data table cannot be parsed, the header information of the target data table obtained based on the above S103 and the table data of the target data table parsed from the query response message are merged to obtain a complete target result set, wherein the target result set is used to generate an audit log.
[0074] In an optional implementation, after obtaining the target result set, an audit log is generated based on the target result set and the first information and the second information parsed from the query response message corresponding to the first query request message, and then the first information and the second information in the local cache and the target table data in the target result set are deleted.
[0075] The second information includes response status information corresponding to the query response message.
[0076] In the disclosed embodiment, the query response message corresponding to the first query request message is parsed, and the response status information corresponding to the query response message can also be obtained as the second information parsed from the query response message, wherein the response status information includes response success status information and response failure status information. The second information is also stored in a local cache, wherein the local cache is used to store various types of information parsed from the query request message and the query response message. Furthermore, based on the obtained target result set and the first information and the second information obtained in S101 above, an audit log can be generated. Since the target result set is a complete result set including the target header information and the target table data, the audit log generated based on the complete result set has a higher accuracy.
[0077] In the disclosed embodiment, after generating an audit log corresponding to a pair of query request response messages, the second query request message obtained continues to be parsed, and based on the above S101 to S104, for the query response message from which the header information cannot be parsed, the corresponding target header information is obtained in a preset cache area and reused, so that each result set obtained is a complete result set including the header information and the table data, thereby improving the accuracy of each audit log generated based on each complete result set.
[0078] In the embodiment of the present disclosure, after each audit log corresponding to a target result set is generated, in order to avoid confusion with various information obtained by parsing a pair of query request response messages again, it is necessary to
[0079] Delete the first information and the second information in the local cache and the target table data in the target result set, wherein the first information is the information obtained from parsing the first query request message, and the second information is the information obtained from parsing the query response message corresponding to the first query request message.
[0080] In the embodiment of the present disclosure, after each audit log corresponding to a target result set is generated, only the first information and the second information in the local cache and the target table data in the target result set are deleted, and the header information in the preset cache area is retained until the query operation for the target data table is completed, or the session corresponding to the target data table is ended, at which time the header information in the preset cache area corresponding to the target data table can be cleared.
[0081] In an optional implementation, after the audit log is generated, the audit log is sent to an audit module of a database audit system, and a security policy is set based on the audit log.
[0082] Among them, the security policy is used to operate on abnormal behavior of the database.
[0083] In the disclosed embodiment, after the audit log is generated, the audit log is sent to the audit module of the database security audit system. Based on the audit log, a corresponding security policy is set to perform operations such as alarming and blocking on abnormal behaviors of the database, thereby ensuring the safe operation of the database system.
[0084] In the disclosed embodiment, since the audit log is generated based on a complete result set, the accuracy of the generated audit log can be guaranteed to be higher, so that based on the audit log, the corresponding security policy can be matched more accurately, thereby improving the performance of the database security audit system.
[0085] The embodiment of the present disclosure provides a result set generation method, first, obtain a first query request message, and parse the first query request message to obtain a target query field of a database query statement corresponding to the first query request message, wherein the target query field has a corresponding relationship with at least one header information in a target data table, then determine whether a preset cache area corresponding to the target data table stores header information identical to the target query field, wherein the preset cache area is used to store header information obtained by parsing a query response message corresponding to the target data table, if it is determined that the header information is stored in the preset cache area, then obtain the header information from the preset cache area, and then merge the header information with the target table data to obtain a target result set, wherein the target table data includes the table data parsed from the query response message corresponding to the first query request message, and the target result set is used to generate an audit log. It can be seen that the embodiment of the present disclosure can reuse the header information stored in the preset cache area, ensure the integrity of the generated result set, improve the accuracy of the audit log generated based on the complete result set, and thus improve the accuracy of matching security policies based on the audit log.
[0086] Based on the above embodiments, the present disclosure provides a specific application scenario of a result set generation method. Figure 2 FIG. 1 is a flowchart of another method for generating a result set provided by an embodiment of the present disclosure, comprising the following steps:
[0087] S201: Obtain a first query request message, and parse the first query request message to obtain first information corresponding to the first query request message.
[0088] The first information includes a database query statement corresponding to the first query request message and an instance name of a database where a target data table is located. The database query statement includes a target query field and a table name field. The table name field is a data table identifier corresponding to the first query request message.
[0089] In the disclosed embodiment, a first query request message (such as query request message A) is obtained, and query request message A is parsed to obtain first information corresponding to query request message A, including a character string corresponding to a database query statement (such as select ID, age from a where age>14), where the target query fields included in the character string corresponding to the database query statement are ID and age, and the table name field is table a. The first information also includes the instance name of the database where the target data table is located (such as the database instance where table a is located is test, etc.).
[0090] In the disclosed embodiment, the first information corresponding to the obtained query request message A is stored in a local cache, and the local cache is used to store information obtained by parsing the query request message and the query response message.
[0091] S202: Extract the target query field corresponding to the database query statement in the first information.
[0092] The target query field has a corresponding relationship with at least one header information in the target data table.
[0093] In the disclosed embodiment, based on the character string corresponding to the database query statement included in the first information obtained in the above S201 (such as select ID, age from a where age>14), the target query fields (such as ID and age) corresponding to the database query statement are extracted, and the target query fields are used to represent the header information of the target data table, wherein the header information of the target data table may include the column titles of the target data table, for example, the header information of table a may include ID, age, gender, etc.
[0094] S203, determining whether the preset cache area corresponding to the target data table stores the same header information as the target query field, if yes, executing S204; if not, executing S208.
[0095] The preset cache area is used to store the header information obtained by parsing the query response message corresponding to the target data table.
[0096] In an embodiment of the present disclosure, the preset cache area corresponding to the target data table can be set in the local cache. For example, the preset cache area corresponding to table a is set in the local cache of the database security audit system to store the header information obtained by parsing the query response message corresponding to table a.
[0097] In the embodiment of the present disclosure, based on the above example, the header information stored in the preset cache area corresponding to table a may include (ID), (ID, age), (ID, age, gender), (age), (age, gender), etc. Based on the target query fields (such as ID and age) obtained in S202 above, it is determined whether the preset cache area corresponding to table a stores the same header information as the ID and age fields. If yes, S204 is executed; if not, S208 is executed.
[0098] For example, if the preset cache area corresponding to table a stores two header information, namely header information 1: (ID) and header information 2: (ID, age), it is determined that the preset cache area corresponding to table a stores header information identical to the ID and age fields (such as header information 2), and then S204 is executed; if the preset cache area corresponding to table a is empty, it is determined that the preset cache area corresponding to table a does not store header information identical to the ID and age fields, and then S208 is executed.
[0099] S204: Acquire the table header information from a preset cache area corresponding to the target data table.
[0100] In the embodiment of the present disclosure, based on the above S203, if it is determined that the preset cache area corresponding to the target data table stores header information identical to the target query field, for example, the preset cache area corresponding to table a stores header information identical to the ID and age fields (such as header information 2), then the header information 2 is obtained from the preset cache area corresponding to table a.
[0101] S205: Parse the query response message corresponding to the first query request message to obtain corresponding target table data and response status information.
[0102] In an embodiment of the present disclosure, based on the above S203, if it is determined that the preset cache area corresponding to the target data table stores the same header information as the target query field, it means that the query response message (such as query response message A) corresponding to the first query request message (such as query request message A) is a query response message that does not meet the preset conditions, wherein the query response message that meets the preset conditions may include a query response message corresponding to the first query of the target query field of the target data table, etc.
[0103] In the disclosed embodiment, query response message A is parsed to obtain corresponding target table data (such as table data A) and response status information (response status A), and table data A and response status A are stored as second information in a local cache, which is used to store information obtained by parsing query request messages and query response messages.
[0104] S206: Merge the table header information with the target table data to obtain a target result set.
[0105] In the disclosed embodiment, the target table data (such as table data A) obtained in S205 and the header information (header information 2) obtained in S204 are merged to obtain a target result set.
[0106] S207, based on the first information, the target result set and the response status information, generate an audit log, and continue to execute S201.
[0107] In the disclosed embodiment, a corresponding audit log (such as audit log A) is generated based on the first information corresponding to the query request message A obtained in S201, the target result set obtained in S206, and the response status information (such as response status A).
[0108] In the disclosed embodiment, an audit log is generated based on a complete target result set, which can improve the accuracy of the audit log. The audit log is sent to the audit module of the database security audit system. Based on the audit log, the corresponding security policy can be matched more accurately to perform operations such as alarming and blocking on abnormal behaviors of the database, thereby improving the performance of the database security audit system in ensuring the safe operation of the database system.
[0109] In the disclosed embodiment, after the audit log is generated, the first information and the second information in the local cache are deleted, but the header information in the preset cache area corresponding to the target data table is retained until the query operation for the target data table is completed, at which time the header information in the preset cache area corresponding to the target data table can be cleared.
[0110] In the disclosed embodiment, after the audit log is generated, S201 is executed again to obtain the second query request message, and the second query request message and the query response message corresponding to the second query request message are parsed respectively, and a complete result set is generated based on the header information in the preset cache area corresponding to the reused target data table. Then, based on the result set, an audit log is generated for matching the corresponding security policy to provide protection for the safe operation of the database system.
[0111] S208, parsing the query response message corresponding to the first query request message to obtain a corresponding target result set and response status information.
[0112] The target result set includes target table header information and target table data.
[0113] In the embodiment of the present disclosure, based on the above S203, if it is determined that the preset cache area corresponding to the target data table does not store the same header information as the target query field, for example, if the preset cache area corresponding to table a stores two header information, namely header information 1: (ID) and header information 2: (ID, age), assuming that after parsing the first query request message (such as query request message B) based on the above S201, the character string corresponding to the obtained database query statement (such as select age, gender from a where age>15) includes the target query fields age and gender, then it is determined that the preset cache area corresponding to table a does not store the same header information as the age and gender fields.
[0114] In an embodiment of the present disclosure, if it is determined that the preset cache area corresponding to the target data table does not store header information identical to the target query field, it means that the query response message (such as query response message B) corresponding to the first query request message (such as query request message B) is a query response message that meets the preset conditions. For example, query response message B is a query response message corresponding to the first query of the target query field of the target data table, etc.
[0115] In the disclosed embodiment, query response message B is parsed to obtain a corresponding target result set and response status information (response status B), wherein the target result set includes target table header information and target table data (such as table data B), and is a complete result set.
[0116] In the disclosed embodiment, a corresponding audit log (such as audit log B) is generated based on the first information obtained by parsing the query request message B, and the complete target result set and response status information (response status B) obtained by parsing the query response message B. Furthermore, based on the audit log, the corresponding security policy can be more accurately matched to perform operations such as warning and blocking on abnormal behaviors of the database.
[0117] In the embodiment of the present disclosure, after the audit log is generated, the specific implementation of deleting the corresponding information in the local cache and continuing to return to execute S201 has been described in detail in the above S207 and will not be repeated here.
[0118] S209, extracting target table header information from the target result set and storing it in a preset cache area corresponding to the target data table.
[0119] In the disclosed embodiment, based on the target result set obtained in S208 above, target header information in the target result set is extracted and stored in a preset cache area corresponding to the target data table, thereby achieving reuse of header information in the preset cache area.
[0120] The embodiment of the present disclosure provides a result set generation method, first, obtain a first query request message, and parse the first query request message to obtain a target query field of a database query statement corresponding to the first query request message, wherein the target query field has a corresponding relationship with at least one header information in a target data table, then determine whether a preset cache area corresponding to the target data table stores header information identical to the target query field, wherein the preset cache area is used to store header information obtained by parsing a query response message corresponding to the target data table, if it is determined that the header information is stored in the preset cache area, then obtain the header information from the preset cache area, and then merge the header information with the target table data to obtain a target result set, wherein the target table data includes the table data parsed from the query response message corresponding to the first query request message, and the target result set is used to generate an audit log. It can be seen that the embodiment of the present disclosure can reuse the header information stored in the preset cache area, ensure the integrity of the generated result set, improve the accuracy of the audit log generated based on the complete result set, and thus improve the accuracy of matching security policies based on the audit log.
[0121] Based on the same inventive concept as the above embodiment, the present disclosure embodiment also provides a result set generating device, referring to Figure 3 , is a schematic diagram of the structure of a result set generating device provided in an embodiment of the present disclosure, wherein the result set generating device 300 comprises:
[0122] The parsing module 301 is used to obtain a first query request message, and parse the first query request message to obtain a target query field of a database query statement corresponding to the first query request message; wherein the target query field has a corresponding relationship with at least one header information in a target data table;
[0123] The determination module 302 is used to determine whether the preset cache area corresponding to the target data table stores the same header information as the target query field; wherein the preset cache area is used to store the header information obtained by parsing the query response message corresponding to the target data table;
[0124] A first acquisition module 303 is configured to acquire the header information from the preset cache area if it is determined that the header information is stored in the preset cache area;
[0125] The merging module 304 is used to merge the header information with the target table data to obtain a target result set; wherein the target table data includes the table data parsed from the query response message corresponding to the first query request message, and the target result set is used to generate an audit log.
[0126] In an optional implementation, the device further includes:
[0127] A second acquisition module is used to acquire target header information if it is determined that there is no header information identical to the target query field in the preset cache area corresponding to the target data table; wherein the target header information includes header information parsed from the query response message corresponding to the first query request message;
[0128] The storage module is used to store the target table header information in a preset cache area corresponding to the target data table.
[0129] In an optional implementation manner, the parsing module 301 further includes:
[0130] A parsing submodule, configured to obtain first information corresponding to the first query request message; wherein the first information includes a database query statement corresponding to the first query request message and an instance name of a database where the target data table is located, the database query statement includes the target query field and a table name field, and the table name field is a data table identifier corresponding to the first query request message;
[0131] A storage submodule is used to store the first information in a local cache; wherein the local cache is used to store information obtained by parsing the query request message and the query response message.
[0132] In an optional implementation, the device further includes:
[0133] A generation module, configured to generate an audit log based on the target result set and the first information and second information parsed from a query response message corresponding to the first query request message; wherein the second information includes response status information corresponding to the query response message;
[0134] A deletion module is used to delete the first information and the second information in the local cache and the target table data in the target result set.
[0135] In an optional implementation, the device further includes:
[0136] A sending module, used for sending the audit log to an audit module of a database audit system;
[0137] A matching module is used to match security policies based on the audit log; wherein the security policies are used to operate on abnormal behaviors of the database.
[0138] The embodiment of the present disclosure provides a result set generation device, first, obtains a first query request message, and parses the first query request message to obtain a target query field of a database query statement corresponding to the first query request message, wherein the target query field has a corresponding relationship with at least one header information in a target data table, then determines whether a preset cache area corresponding to the target data table stores header information identical to the target query field, wherein the preset cache area is used to store header information obtained by parsing a query response message corresponding to the target data table, if it is determined that the header information is stored in the preset cache area, then obtains the header information from the preset cache area, and then merges the header information with the target table data to obtain a target result set, wherein the target table data includes the table data parsed from the query response message corresponding to the first query request message, and the target result set is used to generate an audit log. It can be seen that the embodiment of the present disclosure can reuse the header information stored in the preset cache area, ensure the integrity of the generated result set, improve the accuracy of the audit log generated based on the complete result set, and thus improve the accuracy of matching security policies based on the audit log.
[0139] In addition to the above-mentioned method and apparatus, the embodiments of the present disclosure further provide a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device implements the result set generation method described in the embodiments of the present disclosure.
[0140] The embodiment of the present disclosure further provides a computer program product, which includes a computer program / instructions. When the computer program / instructions are executed by a processor, the result set generation method described in the embodiment of the present disclosure is implemented.
[0141] In addition, the present disclosure also provides a result set generation device, see Figure 4 As shown, this may include:
[0142] Processor 401, memory 402, input device 403 and output device 404. The number of processors 401 in the result set generating device can be one or more. Figure 4 In some embodiments of the present invention, the processor 401, the memory 402, the input device 403 and the output device 404 may be connected via a bus or other means, wherein: Figure 4 The example of connecting through bus is taken in the following.
[0143] The memory 402 can be used to store software programs and modules, and the processor 401 executes various functional applications and data processing of the result set generation device by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. The input device 403 can be used to receive input digital or character information, and to generate signal input related to user settings and function control of the result set generation device.
[0144] Specifically in this embodiment, the processor 401 will load the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 will run the applications stored in the memory 402, thereby realizing the various functions of the above-mentioned result set generation device.
[0145] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0146] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for generating a result set, It is characterized in that The method comprises: Obtaining a first query request message, and parsing the first query request message to obtain a target query field of a database query statement corresponding to the first query request message; wherein the target query field has a corresponding relationship with at least one header information in a target data table; Determine whether the preset cache area corresponding to the target data table stores the same header information as the target query field; wherein the preset cache area is used to store the header information obtained by parsing the query response message corresponding to the target data table; If it is determined that the header information is stored in the preset cache area, acquiring the header information from the preset cache area; The header information is combined with the target table data to obtain a target result set; wherein the target table data includes table data parsed from a query response message corresponding to the first query request message, and the target result set is used to generate an audit log.
2. The method according to claim 1, It is characterized in that The method further comprises: If it is determined that the preset cache area corresponding to the target data table does not contain the same header information as the target query field, then obtaining the target header information; wherein the target header information includes the header information parsed from the query response message corresponding to the first query request message; The target table header information is stored in a preset cache area corresponding to the target data table.
3. The method according to claim 1, It is characterized in that The obtaining the first query request message and parsing the first query request message further includes: Obtaining first information corresponding to the first query request message; wherein the first information includes a database query statement corresponding to the first query request message and an instance name of a database where the target data table is located, the database query statement includes the target query field and a table name field, and the table name field is a data table identifier corresponding to the first query request message; The first information is stored in a local cache; wherein the local cache is used to store information obtained by parsing the query request message and the query response message.
4. The method according to claim 3, It is characterized in that After merging the table header information with the target table data to obtain the target result set, the method includes: Generate an audit log based on the target result set and the first information and second information parsed from a query response message corresponding to the first query request message; wherein the second information includes response status information corresponding to the query response message; The first information and the second information in the local cache and the target table data in the target result set are deleted.
5. The method according to claim 4, It is characterized in that After the audit log is generated based on the first information and the second information parsed from the query response message corresponding to the first query request message, the method includes: Sending the audit log to an audit module of a database audit system; Based on the audit log, a security policy is matched; wherein the security policy is used to operate on abnormal behavior of the database.
6. A result set generating device, It is characterized in that The device comprises: A parsing module, configured to obtain a first query request message, and parse the first query request message to obtain a target query field of a database query statement corresponding to the first query request message; wherein the target query field has a corresponding relationship with at least one header information in a target data table; A determination module, used to determine whether the preset cache area corresponding to the target data table stores the same header information as the target query field; wherein the preset cache area is used to store the header information obtained by parsing the query response message corresponding to the target data table; A first acquisition module, configured to acquire the header information from the preset cache area if it is determined that the header information is stored in the preset cache area; A merging module is used to merge the table header information with the target table data to obtain a target result set; wherein the target table data includes table data parsed from the query response message corresponding to the first query request message, and the target result set is used to generate an audit log.
7. The device according to claim 6, It is characterized in that The device also includes: a second acquisition module, configured to acquire target header information if it is determined that the preset cache area corresponding to the target data table does not contain header information identical to the target query field; wherein the target header information includes header information parsed from the query response message corresponding to the first query request message; The storage module is used to store the target table header information in a preset cache area corresponding to the target data table.
8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the method according to any one of claims 1 to 5.
9. An electronic device, It is characterized in that include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
10. A computer program product, It is characterized in that The computer program product comprises a computer program / instruction, and when the computer program / instruction is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
HBase-based big data storage and retrieval method and system
CN104915450A
Composite database retrieval system, composite database retrieval method, and program therefor
JP2006092409A
Method, system, and computer program product for caching dynamically generated queries
US20060294088A1
