Method and device for identifying abnormal operations in a database
By parsing SQL statements to identify abnormal database operations, updating data relationship records and querying abnormal behaviors, it solves the problem of identifying abnormal operations in the database and achieves automated and highly accurate privacy data protection.
Patent Information
- Application Number
- CN202110910584.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-09
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-08-09
AI Technical Summary
Existing technology is difficult to effectively identify and prevent abnormal operations in the database, leading to privacy data leaks and system failures, and requires a lot of labor costs.
By parsing Structured Query Language (SQL) statements, it identifies data objects and relationships involved in target behavior operations, updates data relationship records, queries abnormal operations based on preset conditions, and issues alerts or interrupts operations.
It achieves highly automated identification of abnormal operations, reduces labor costs, maintains a high accuracy, and improves the privacy data security of the database.
Smart Images

Figure CN113672457B_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of computers, and more particularly, to a method and apparatus for identifying abnormal operations in a database. Background Art
[0002] Private data is secret data, which refers to information that one does not want to be known by others or irrelevant persons. From the perspective of the owner of the privacy, private data can be divided into personal privacy data and common privacy data. Personal privacy data includes information that can be used to locate or identify individuals (such as phone numbers, addresses, credit card numbers, etc.) and sensitive information (such as personal health conditions, financial information, important company documents, etc.). Common privacy data mainly focuses on family privacy, such as family annual income. The leakage and abuse of private data can easily lead to various personal and public safety issues. In order to protect private data, it is necessary to identify abnormal operations in the database. The above abnormal operations can easily lead to consequences such as private data leakage and system failure. Usually, the database includes a large number of data tables, and each data table has dozens of fields on average. Each field has a label corresponding to whether it belongs to private data. Summary of the invention
[0003] One or more embodiments of this specification describe a method and device for identifying abnormal operations in a database, which can be highly automated, reduce labor costs, and maintain a high accuracy rate.
[0004] In a first aspect, a method for identifying abnormal operations in a database is provided, wherein the database includes multiple data tables, each data table includes multiple fields, and each field corresponds to a label indicating whether it belongs to private data. The method includes:
[0005] Obtaining a target structured query language (SQL) statement for executing a target behavior operation on the database;
[0006] Parsing the target SQL statement to obtain a number of data objects involved in the target behavior operation and a target association relationship between the data objects, wherein a single data object is a field or a data table;
[0007] According to the plurality of data objects and the target association relationship, updating a pre-established data relationship record, wherein the data relationship record includes at least part of the data objects in the database and the existing association relationships therebetween;
[0008] From the updated data relationship record, query the target field that meets the preset condition, where the preset condition is related to the label of the field and whether the association relationship belongs to the preset relationship;
[0009] In a case where the target field belongs to the plurality of data objects, it is determined that the target behavior operation is an abnormal operation.
[0010] In a possible implementation, obtaining a target SQL statement for executing a target behavior operation on the database includes:
[0011] The historical SQL statements in the database are summarized regularly, and the summarized historical SQL statements are used as the target SQL statements.
[0012] In a possible implementation, obtaining a target SQL statement for executing a target behavior operation on the database includes:
[0013] The SQL statement submitted and executed by the user is captured as the target SQL statement.
[0014] In a possible implementation, the data relationship record is stored in the form of a graph, and the graph includes nodes and connection edges, the nodes correspond to the data objects, and the connection edges correspond to the association relationships.
[0015] Further, the updating of the pre-established data relationship record according to the plurality of data objects and the target association relationship includes:
[0016] According to a first field included in the plurality of data objects and not included in the data relationship record, a node corresponding to the first field is added to the pre-established graph; the first field belongs to a first data table already in the data relationship record;
[0017] According to a first association relationship between the first field included in the target association relationship and a second field already in the data relationship record, adding a connection edge corresponding to the first association relationship in the graph; the second field belongs to a second data table already in the data relationship record;
[0018] According to the second association relationship between the first field and the first data table included in the target association relationship, a connection edge corresponding to the second association relationship is added to the graph.
[0019] Further, the updating of the pre-established data relationship record according to the plurality of data objects and the target association relationship includes:
[0020] According to the third field included in the plurality of data objects and not included in the data relationship record and the third data table to which the third field belongs, adding a node corresponding to the third field in the pre-established graph and adding a node corresponding to the third data table;
[0021] According to a third association relationship between the third field included in the target association relationship and a fourth field already in the data relationship record, adding a connection edge corresponding to the third association relationship in the graph; the fourth field belongs to a fourth data table already in the data relationship record;
[0022] According to a fourth association relationship between the third field included in the target association relationship and the third data table, a connection edge corresponding to the fourth association relationship is added to the graph.
[0023] Furthermore, the step of searching the updated data relationship record for a target field that meets a preset condition includes:
[0024] According to the preset conditions, determine the graph query statement;
[0025] The graph query statement is used to query a corresponding node from the updated graph, where the node corresponds to the target field.
[0026] In a possible implementation manner, after determining that the target behavior operation is an abnormal operation, the method further includes:
[0027] issuing an alert for the target behavior operation; and / or,
[0028] interrupting the execution of the SQL statement corresponding to the target behavior operation; and / or,
[0029] Determine the executor corresponding to the target behavior operation.
[0030] In a possible implementation manner, the preset condition includes:
[0031] The label of the associated field having an association relationship with the target field indicates that the associated field belongs to the privacy data, and the association relationship includes truncation, where the truncation is extracting a substring of the string corresponding to the associated field.
[0032] In a second aspect, a device for identifying abnormal operations in a database is provided, wherein the database includes a plurality of data tables, each data table includes a plurality of fields, each field corresponds to a label indicating whether it belongs to private data, and the device includes:
[0033] An acquisition unit, used for acquiring a target structured query language SQL statement for executing a target behavior operation on the database;
[0034] A parsing unit, used to parse the target SQL statement obtained by the obtaining unit to obtain a plurality of data objects involved in the target behavior operation and a target association relationship between the plurality of data objects, wherein a single data object is a field or a data table;
[0035] An updating unit, configured to update a pre-established data relationship record according to the plurality of data objects and the target relationship obtained by the parsing unit, wherein the data relationship record includes at least part of the data objects in the database and the existing relationship therebetween;
[0036] A query unit, used to query a target field that meets a preset condition from the data relationship record updated by the update unit, wherein the preset condition is related to the label of the field and whether the association relationship belongs to a preset relationship;
[0037] The abnormality determination unit is used to determine that the target behavior operation is an abnormal operation when the target field obtained by the query unit belongs to the plurality of data objects obtained by the parsing unit.
[0038] According to a third aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the method of the first aspect.
[0039] According to a fourth aspect, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method of the first aspect is implemented.
[0040] Through the method and device provided in the embodiments of this specification, a target SQL statement for executing a target behavior operation on the database is first obtained; then the target SQL statement is parsed to obtain a number of data objects involved in the target behavior operation and a target association relationship between the data objects, wherein a single data object is a field or a data table; then, based on the data objects and the target association relationship, a pre-established data relationship record is updated, wherein the data relationship record contains at least part of the data objects in the database and the existing association relationships therebetween; then, from the updated data relationship record, a target field that meets a preset condition is queried, wherein the preset condition is related to the label of the field and whether the association relationship belongs to a preset relationship; finally, when the target field belongs to the data objects, it is determined that the target behavior operation is an abnormal operation. As can be seen from the above, the embodiments of the present specification, based on the parsing of SQL statements, can automatically parse out from SQL statements several data objects involved in the target behavior operation, as well as the target association relationship between the several data objects, and then update the pre-established data relationship record. Thereafter, by querying the target field that meets the preset conditions from the updated data relationship record, it is determined that the target behavior operation is an abnormal operation. This can be highly automated, reduce labor costs, and maintain a high accuracy rate. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0042] Figure 1 A schematic diagram of an implementation scenario of an embodiment disclosed in this specification;
[0043] Figure 2 A flow chart showing a method for identifying abnormal operations in a database according to one embodiment;
[0044] Figure 3 A system structure diagram showing abnormal operations in a database according to one embodiment is shown;
[0045] Figure 4 A flowchart of offline behavioral risk audit according to one embodiment is shown;
[0046] Figure 5 shows an online behavior risk audit flow chart according to one embodiment;
[0047] Figure 6 A schematic block diagram shows a device for identifying abnormal operations in a database according to an embodiment. DETAILED DESCRIPTION
[0048] The solution provided in this specification is described below in conjunction with the accompanying drawings.
[0049] Figure 1 The following is a schematic diagram of an implementation scenario of an embodiment disclosed in this specification. The implementation scenario involves identifying abnormal operations in a database, where the database includes multiple data tables, each data table includes multiple fields, each field corresponds to a label indicating whether it belongs to private data, and a field corresponds to a column. Abnormal operations are also called risky behaviors, which are prone to lead to consequences such as private data leakage and system failure, and usually include bypassing the platform desensitization mechanism to collect private data, illegal database collision, etc. Figure 1Table 1 is the original data table in the database. Field 1 included in Table 1 belongs to privacy data. The operation on the database is to create Table 2. Field 1 in Table 2 and Field 1 in Table 1 are in a truncated relationship, and Field 2 in Table 2 and Field 1 in Table 1 are also in a truncated relationship. That is to say, Field 1 and Field 2 in Table 2 are obtained by extracting the substring of the string corresponding to Field 1 in Table 1. For example, the string corresponding to Field 1 in Table 1 is abcd. Accordingly, Field 1 in Table 2 corresponds to the substring ab of the string, and Field 2 in Table 2 corresponds to the substring cd of the string. It can be understood that Field 1 in Table 1 can be easily restored through Field 1 and Field 2 in Table 2. This operation is a typical abnormal operation.
[0050] It should be noted that the above is only an example of abnormal operation. In practice, abnormal operation situations vary and are not limited to this example. Other abnormal operations may include illegal database collisions, privacy field inference, etc. The above privacy field inference is to infer another privacy data based on one privacy data, such as calculating gender based on ID card, predicting gender based on name, etc.
[0051] The embodiments of this specification can automatically parse out several data objects involved in the target behavior operation and the target association relationships between the several data objects based on the analysis of the operation statements of the database, and then determine whether the target behavior operation is an abnormal operation based on the above association relationships. This can be highly automated, reduce labor costs, and maintain a high accuracy rate.
[0052] The above-mentioned association relationship can be called a blood relationship. The blood relationship is used to characterize the upstream and downstream relationship between data. Taking the relationship between fields as an example, it usually includes copying, truncation, splicing, conversion, etc., which reflects that the data of one field is obtained through certain processing to obtain the data of another field.
[0053] Figure 2 A flowchart of a method for identifying abnormal operations in a database according to an embodiment is shown. The database includes multiple data tables, each data table includes multiple fields, and each field corresponds to a label of whether it belongs to private data. The method can be based on Figure 1 The implementation scenario shown in Figure 1 is as follows. Figure 2As shown, the method for identifying abnormal operations in a database in this embodiment includes the following steps: Step 21, obtaining a target structured query language (SQL) statement for executing a target behavior operation on the database; Step 22, parsing the target SQL statement to obtain a number of data objects involved in the target behavior operation, and a target association relationship between the data objects, wherein a single data object is a field or a data table; Step 23, updating a pre-established data relationship record according to the data objects and the target association relationship, wherein the data relationship record contains at least part of the data objects in the database, and the existing association relationship therebetween; Step 24, querying a target field that meets a preset condition from the updated data relationship record, wherein the preset condition is related to whether the label and association relationship of the field belong to a preset relationship; Step 25, determining that the target behavior operation belongs to an abnormal operation when the target field belongs to the data objects. The specific execution method of each of the above steps is described below.
[0054] First, in step 21, a target SQL statement for executing a target behavior operation on the database is obtained. It is understandable that various behavior operations on the database can be implemented by executing SQL statements, and the above behavior operations may include but are not limited to creating a data table, adding fields to an existing data table, etc.
[0055] In one example, obtaining a target SQL statement for executing a target behavior operation on the database includes:
[0056] The historical SQL statements in the database are summarized regularly, and the summarized historical SQL statements are used as the target SQL statements.
[0057] This example can be used for offline behavior risk auditing, that is, to identify whether there are abnormal operations in historical behavior operations on the database.
[0058] In another example, obtaining a target SQL statement for executing a target behavior operation on the database includes:
[0059] The SQL statement submitted and executed by the user is captured as the target SQL statement.
[0060] This example can be used for online behavior risk auditing, that is, to identify whether the current behavior operation on the database is an abnormal operation.
[0061] Then, in step 22, the target SQL statement is parsed to obtain a plurality of data objects involved in the target behavior operation and a target association relationship between the plurality of data objects, wherein a single data object is a field or a data table. It is understandable that the above association relationship may include a relationship between fields, a relationship between fields and data tables, and a relationship between data tables.
[0062] The above-mentioned parsed SQL statements can be called SQL parsing. SQL parsing is the cornerstone for building data lineage relationships. It mainly parses the inheritance relationship between fields and tables, fields and fields, and tables described in SQL. Usually, the relationship between fields can include copy, truncation, concatenation, etc.; the relationship between tables is dependency; the relationship between fields and tables is belong. The parsed lineage relationship can be represented by a triple (source_node, target_node, relation). Among them, source_node is the identifier of the source node; target_node is the identifier of the target node; relation is the relationship between nodes. For example, the following SQL:
[0063] Create Table1 as
[0064] Selectsubstr(identify_no,0,6)asidentify_no_first,substr(identify_no,6,12)as identify_no_rest
[0065] From Table2;
[0066] The blood relationships that can be obtained through SQL parsing are:
[0067] (Table2.identify_no,Table1.identify_no_first,substr), which means that the initial part of the ID number field in Table 1 is truncated with the ID number field in Table 2;
[0068] (Table2.identify_no,Table1.identify_no_rest,substr), which means the remaining part of the ID card number field in Table 1 is truncated with the ID card number field in Table 2;
[0069] (Table2, Table1, depend), which means that Table 1 and Table 2 are dependent on each other;
[0070] (Table1.identify_no_first,Table1,belong), which means the initial part of the ID card number in Table 1 belongs to Table 1;
[0071] (Table1.identify_no_rest,Table1,belong), which means the remaining fields of the ID card number in Table 1 belong to Table 1;
[0072] (Table2.identify_no,Table2,belong), which means the ID number field in Table 2 belongs to Table 2.
[0073] Currently, there are mature third-party libraries available for SQL parsing, and the principles will not be described here.
[0074] Then, in step 23, according to the plurality of data objects and the target association relationship, a pre-established data relationship record is updated, wherein the data relationship record includes at least some of the data objects in the database and the existing association relationships therebetween. It is understandable that the data relationship record is updated each time step 22 is executed, and as more SQL statements are parsed, the data objects and association relationships included in the data relationship record will also increase.
[0075] In one example, the data relationship record is stored in the form of a graph, and the graph includes nodes and connection edges, the nodes correspond to the data objects, and the connection edges correspond to the association relationships.
[0076] In the embodiments of this specification, the graph may exist in the form of a graph database. Graph database: also known as a graph database, is a non-relational database that uses graph theory to store relationship information between entities. Compared with relational databases, graph databases can be easily and quickly queried, as well as various calculations and reasoning.
[0077] It can be understood that the above-mentioned node has a node identifier, which can uniquely identify a field or a data table. For example, a globally unique identifier (GUID) is used as the above-mentioned node identifier, and its specific form is project_name.table_name.column_name, wherein project_name represents the database, table_name represents the data table, and column_name represents the field.
[0078] Further, the updating of the pre-established data relationship record according to the plurality of data objects and the target association relationship includes:
[0079] According to a first field included in the plurality of data objects and not included in the data relationship record, a node corresponding to the first field is added to the pre-established graph; the first field belongs to a first data table already in the data relationship record;
[0080] According to a first association relationship between the first field included in the target association relationship and a second field already in the data relationship record, adding a connection edge corresponding to the first association relationship in the graph; the second field belongs to a second data table already in the data relationship record;
[0081] According to the second association relationship between the first field and the first data table included in the target association relationship, a connection edge corresponding to the second association relationship is added to the graph.
[0082] It can be understood that the above update includes adding new nodes and connecting edges in the graph, and the new nodes represent new fields, which belong to the data table corresponding to the existing nodes in the graph.
[0083] Further, the updating of the pre-established data relationship record according to the plurality of data objects and the target association relationship includes:
[0084] According to the third field included in the plurality of data objects and not included in the data relationship record and the third data table to which the third field belongs, adding a node corresponding to the third field in the pre-established graph and adding a node corresponding to the third data table;
[0085] According to a third association relationship between the third field included in the target association relationship and a fourth field already in the data relationship record, adding a connection edge corresponding to the third association relationship in the graph; the fourth field belongs to a fourth data table already in the data relationship record;
[0086] According to a fourth association relationship between the third field included in the target association relationship and the third data table, a connection edge corresponding to the fourth association relationship is added to the graph.
[0087] It can be understood that the above update includes adding new nodes and connecting edges in the graph, and the new nodes include nodes representing new fields and nodes of new data tables, and the new fields belong to the new data tables.
[0088] Then in step 24, the target field that meets the preset condition is queried from the updated data relationship record, and the preset condition is related to whether the field label and the association relationship belong to the preset relationship. It can be understood that the above preset condition can be set manually, and multiple risk modes can be set, and each risk mode has its own corresponding preset condition.
[0089] In one example, querying the target field that meets the preset condition from the updated data relationship record includes:
[0090] According to the preset conditions, determine the graph query statement;
[0091] The graph query statement is used to query a corresponding node from the updated graph, where the node corresponds to the target field.
[0092] In this example, the above preset conditions are converted into graph query statements to find nodes that meet the preset conditions in the graph database. Currently, common graph query languages can conveniently and quickly perform calculations and reasoning on various graphs.
[0093] In one example, the preset conditions include:
[0094] The label of the associated field having an association relationship with the target field indicates that the associated field belongs to the privacy data, and the association relationship includes truncation, where the truncation is extracting a substring of the string corresponding to the associated field.
[0095] The preset conditions in this example can be converted into graph query statements. For example, the operation of truncating sensitive fields is described in Gremlin language as follows: gV().has("isSensitive",1).outE().has("dependType","substr"). According to the above graph query statement, all sensitive data on the data lineage graph (isSensitive attribute is 1) will be traversed to see if the dependency relationship on the outgoing edge of these nodes has substr (truncation), and if there are return nodes and related edges. Then the various attributes of the returned nodes can be parsed to obtain the executor of the SQL statement, execution time, etc. This is convenient for subsequent auditors to perform operations. Among them, the above sensitive data is privacy data.
[0096] Finally, in step 25, when the target field belongs to the plurality of data objects, it is determined that the target behavior operation is an abnormal operation. It is understandable that the updated data relationship record includes not only the plurality of data objects, but also the existing data objects before the update, and these existing data objects have usually been identified as to whether the corresponding operations are abnormal operations, so there is no need for repeated identification.
[0097] In one example, after determining that the target behavior operation is an abnormal operation, the method further includes:
[0098] issuing an alert for the target behavior operation; and / or,
[0099] interrupting the execution of the SQL statement corresponding to the target behavior operation; and / or,
[0100] Determine the executor corresponding to the target behavior operation.
[0101] In this example, issuing an alarm for the target behavior operation can be called a risk warning; interrupting the execution of the SQL statement corresponding to the target behavior operation can be called risk blocking, which can be applied to online behavior risk audits, can achieve real-time risk blocking, and further improve the security of the use of privacy data; determining the executor corresponding to the target behavior operation can be called risk disposal, and after the executor is determined, the executor can be processed.
[0102] Through the method provided in the embodiments of this specification, a target SQL statement for executing a target behavior operation on the database is first obtained; then the target SQL statement is parsed to obtain a number of data objects involved in the target behavior operation and a target association relationship between the data objects, wherein a single data object is a field or a data table; then, based on the data objects and the target association relationship, a pre-established data relationship record is updated, wherein the data relationship record contains at least part of the data objects in the database and the existing association relationships therebetween; then, from the updated data relationship record, a target field that meets a preset condition is queried, wherein the preset condition is related to the label of the field and whether the association relationship belongs to a preset relationship; finally, when the target field belongs to the data objects, it is determined that the target behavior operation is an abnormal operation. As can be seen from the above, the embodiments of the present specification, based on the parsing of SQL statements, can automatically parse out from SQL statements several data objects involved in the target behavior operation, as well as the target association relationship between the several data objects, and then update the pre-established data relationship record. Thereafter, by querying the target field that meets the preset conditions from the updated data relationship record, it is determined that the target behavior operation is an abnormal operation. This can be highly automated, reduce labor costs, and maintain a high accuracy rate.
[0103] Figure 3 FIG. 1 shows a system structure diagram for identifying abnormal operations in a database according to an embodiment. Figure 3, the system structure can be divided into data layer, lineage layer, function layer and application layer. The data layer collects logs, metadata, SQL statements and privacy data scanning results. Based on the SQL parser, data lineage can be generated regularly and synchronized incrementally to the graph database. The graph database can be called a data lineage graph. It can be understood that the privacy data scanning results show whether each field of each data table in the database belongs to privacy data. The lineage relationship includes the relationship between fields, the relationship between fields and tables, and the relationship between tables. The nodes in the lineage layer are tables and columns, and the edges are the relationships between nodes. The graph computing engine is used to complete the query and calculation of various risk patterns defined in the upper layer. The functional layer includes manually defined risk patterns, such as splitting sensitive data, sensitive data transformation, etc. Usually, the pattern will be converted into a graph query statement later, and the graph computing engine is used to realize the search of risk patterns on the data lineage graph. Offline scheduled auditing in the functional layer is mainly used to discover risks from SQL statements that have been executed, and online real-time auditing is mainly used to discover potential risks from SQL statements to be executed through ETL Hook. Three available application scenarios of behavioral risk auditing are defined in the application layer. Among them, risk warning is to issue an alarm to the data manager or audit center when risky behavior is discovered; risk blocking is mostly used in real-time scenarios. When it is discovered that an SQL statement may leak privacy data, the execution of the SQL statement will be interrupted to prevent data leakage; risk disposal means that when a risky behavior has occurred, the person who performed the risky behavior is traced back and the audit center will carry out subsequent processing.
[0104] Figure 4 FIG. 1 shows a flowchart of an offline behavior risk audit according to an embodiment. Figure 4 The system will use the timer to summarize the historical SQL statements executed by the database operator, and then use the SQL parsing module to parse the summarized SQL statements and organize them into nodes and edges of blood relationships, and then insert the nodes and edges into the previously constructed data blood relationship map. After that, the graph computing engine will be used to sequentially execute the risk pattern search algorithm on the updated data blood relationship map. When the risk pattern is matched, it will be fed back to the audit center. After receiving the relevant risk feedback, the audit center will check the risk behavior in turn. For the risk behavior that is indeed problematic, the data operator who executed the SQL statement will be asked for further follow-up treatment.
[0105] Figure 5 1 shows a flowchart of an online behavior risk audit according to one embodiment. Figure 5The system first uses ETLHook to capture the SQL statements submitted by the user, then uses the SQL parsing module to parse the SQL statements, and then inserts the parsed blood relationship into the data blood relationship map. Then, the graph computing engine is used to execute the risk pattern search algorithm on the updated data blood relationship map. When no risk pattern is matched, the SQL statement is executed; when a risk pattern is matched, it will first be fed back to the audit center, and the audit center will handle it uniformly after notifying the risk. Then, it will check whether it is necessary to block the execution of risky SQL statements based on user configuration. If blocking is required, it will return directly; if blocking is not required, the SQL statement will be executed.
[0106] According to another embodiment, there is also provided a device for identifying abnormal operations in a database, wherein the database includes a plurality of data tables, each data table includes a plurality of fields, each field corresponds to a label indicating whether it belongs to privacy data, and the device is used to execute the method provided in the embodiment of this specification. Figure 6 A schematic block diagram of an apparatus for identifying abnormal operations in a database according to an embodiment is shown. Figure 6 As shown, the device 600 includes:
[0107] An acquisition unit 61 is used to acquire a target structured query language SQL statement for executing a target behavior operation on the database;
[0108] The parsing unit 62 is used to parse the target SQL statement obtained by the obtaining unit 61 to obtain a plurality of data objects involved in the target behavior operation and a target association relationship between the plurality of data objects, wherein a single data object is a field or a data table;
[0109] An updating unit 63, configured to update a pre-established data relationship record according to the plurality of data objects and the target relationship obtained by the parsing unit 62, wherein the data relationship record includes at least part of the data objects in the database and the existing relationship therebetween;
[0110] A query unit 64 is used to query the target field that meets the preset condition from the data relationship record updated by the update unit 63, wherein the preset condition is related to the label of the field and whether the association relationship belongs to the preset relationship;
[0111] The abnormality determination unit 65 is used to determine that the target behavior operation is an abnormal operation when the target field obtained by the query unit 64 belongs to the plurality of data objects obtained by the parsing unit.
[0112] Optionally, as an embodiment, the acquisition unit 61 is specifically configured to periodically summarize historical SQL statements in the database, and use the summarized historical SQL statements as the target SQL statements.
[0113] Optionally, as an embodiment, the acquisition unit 61 is specifically used to capture the SQL statement submitted by the user for execution as the target SQL statement.
[0114] Optionally, as an embodiment, the data relationship record is stored in the form of a graph, and the graph includes nodes and connection edges, the nodes correspond to the data objects, and the connection edges correspond to the association relationships.
[0115] Further, the updating unit 63 includes:
[0116] A node adding subunit, configured to add a node corresponding to a first field not included in the data relationship record and included in the plurality of data objects in the pre-established graph; the first field belongs to a first data table already in the data relationship record;
[0117] a connection edge adding subunit, configured to add a connection edge corresponding to the first association relationship in the graph according to a first association relationship between the first field included in the target association relationship and a second field already in the data relationship record; the second field belongs to a second data table already in the data relationship record;
[0118] The connection edge adding subunit is further used to add a connection edge corresponding to the second association relationship between the first field and the first data table included in the target association relationship in the graph.
[0119] Further, the updating unit 63 includes:
[0120] A node adding subunit, configured to add a node corresponding to the third field and a node corresponding to the third data table in the pre-established graph according to the third field not included in the data relationship record and the third data table to which the third field belongs included in the plurality of data objects;
[0121] a connection edge adding subunit, configured to add a connection edge corresponding to the third association relationship in the graph according to a third association relationship between the third field included in the target association relationship and a fourth field already in the data relationship record; the fourth field belongs to a fourth data table already in the data relationship record;
[0122] The connection edge adding subunit is further used to add a connection edge corresponding to the fourth association relationship in the graph according to the fourth association relationship between the third field included in the target association relationship and the third data table.
[0123] Further, the query unit 64 includes:
[0124] A statement determination subunit, used to determine a graph query statement according to the preset conditions;
[0125] The query subunit is used to use the graph query statement determined by the statement determination subunit to query the corresponding node from the updated graph, where the node corresponds to the target field.
[0126] Optionally, as an embodiment, the device further includes:
[0127] an alarm unit, configured to issue an alarm for the target behavior operation after the abnormality determination unit determines that the target behavior operation is an abnormal operation; and / or,
[0128] an interruption unit, used to interrupt the execution of the SQL statement corresponding to the target behavior operation; and / or,
[0129] The executor determination unit is used to determine the executor corresponding to the target behavior operation.
[0130] Optionally, as an embodiment, the preset condition includes:
[0131] The label of the associated field having an association relationship with the target field indicates that the associated field belongs to the privacy data, and the association relationship includes truncation, where the truncation is extracting a substring of the string corresponding to the associated field.
[0132] Through the device provided by the embodiment of this specification, first, the acquisition unit 61 acquires the target SQL statement for executing the target behavior operation on the database; then the parsing unit 62 parses the target SQL statement to obtain a number of data objects involved in the target behavior operation, and a target association relationship between the data objects, wherein a single data object is a field or a data table; then the updating unit 63 updates a pre-established data relationship record according to the data objects and the target association relationship, wherein the data relationship record contains at least part of the data objects in the database, and the existing association relationship therebetween; then the query unit 64 queries the target field that meets the preset condition from the updated data relationship record, wherein the preset condition is related to whether the label and association relationship of the field belong to the preset relationship; finally, the abnormality determination unit 65 determines that the target behavior operation is an abnormal operation when the target field belongs to the data objects. As can be seen from the above, the embodiments of the present specification, based on the parsing of SQL statements, can automatically parse out from SQL statements several data objects involved in the target behavior operation, as well as the target association relationship between the several data objects, and then update the pre-established data relationship record. Thereafter, by querying the target field that meets the preset conditions from the updated data relationship record, it is determined that the target behavior operation is an abnormal operation. This can be highly automated, reduce labor costs, and maintain a high accuracy rate.
[0133] According to another embodiment, there is also provided a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute a combination of Figure 2 The method described.
[0134] According to another embodiment of the present invention, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the Figure 2 The method described.
[0135] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the present invention can be implemented by hardware, software, firmware or any combination thereof. When implemented by software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.
[0136] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for identifying abnormal operations in a database, wherein the database includes multiple data tables, each data table includes multiple fields, and each field corresponds to a label indicating whether it belongs to private data. The method comprises: Obtaining a target structured query language SQL statement for executing a target behavior operation on the database; Parsing the target SQL statement to obtain a number of data objects involved in the target behavior operation and a target association relationship between the data objects, wherein a single data object is a field or a data table; According to the plurality of data objects and the target association relationship, updating a pre-established data relationship record, wherein the data relationship record includes at least part of the data objects in the database and the existing association relationships therebetween; From the updated data relationship record, query the target field that meets the preset condition, where the preset condition is related to the label of the field and whether the association relationship belongs to the preset relationship; In a case where the target field belongs to the plurality of data objects, determining that the target behavior operation is an abnormal operation; The preset conditions include: The label of the associated field having an association relationship with the target field indicates that the associated field belongs to the privacy data, and the association relationship includes truncation, where the truncation is extracting a substring of the string corresponding to the associated field.
2. The method of claim 1, wherein: The obtaining of a target SQL statement for executing a target behavior operation on the database includes: The historical SQL statements in the database are summarized regularly, and the summarized historical SQL statements are used as the target SQL statements.
3. The method of claim 1, wherein: The obtaining of a target SQL statement for executing a target behavior operation on the database includes: The SQL statement submitted and executed by the user is captured as the target SQL statement.
4. The method of claim 1, wherein: The data relationship records are stored in the form of a graph, which includes nodes and connection edges. The nodes correspond to the data objects, and the connection edges correspond to the association relationships.
5. The method of claim 4, wherein: The updating of the pre-established data relationship record according to the plurality of data objects and the target association relationship comprises: According to a first field included in the plurality of data objects and not included in the data relationship record, a node corresponding to the first field is added to the pre-established graph; the first field belongs to a first data table already in the data relationship record; According to a first association relationship between the first field included in the target association relationship and a second field already in the data relationship record, adding a connection edge corresponding to the first association relationship in the graph; the second field belongs to a second data table already in the data relationship record; According to the second association relationship between the first field and the first data table included in the target association relationship, a connection edge corresponding to the second association relationship is added to the graph.
6. The method of claim 4, wherein: The updating of the pre-established data relationship record according to the plurality of data objects and the target association relationship comprises: According to the third field included in the plurality of data objects and not included in the data relationship record and the third data table to which the third field belongs, adding a node corresponding to the third field in the pre-established graph and adding a node corresponding to the third data table; According to a third association relationship between the third field included in the target association relationship and a fourth field already in the data relationship record, adding a connection edge corresponding to the third association relationship in the graph; the fourth field belongs to a fourth data table already in the data relationship record; According to a fourth association relationship between the third field included in the target association relationship and the third data table, a connection edge corresponding to the fourth association relationship is added to the graph.
7. The method of claim 4, wherein: The step of searching the updated data relationship record for a target field that meets a preset condition includes: According to the preset conditions, determine the graph query statement; The graph query statement is used to query a corresponding node from the updated graph, where the node corresponds to the target field.
8. The method of claim 1, wherein: After determining that the target behavior operation is an abnormal operation, the method further includes: issuing an alert for the target behavior operation; and / or, interrupting the execution of the SQL statement corresponding to the target behavior operation; and / or, Determine the executor corresponding to the target behavior operation.
9. A device for identifying abnormal operations in a database, wherein the database includes a plurality of data tables, each data table includes a plurality of fields, each field has a label indicating whether it is private data, and the device includes: An acquisition unit, used for acquiring a target structured query language SQL statement for executing a target behavior operation on the database; A parsing unit, used to parse the target SQL statement obtained by the obtaining unit to obtain a plurality of data objects involved in the target behavior operation and a target association relationship between the plurality of data objects, wherein a single data object is a field or a data table; An updating unit, configured to update a pre-established data relationship record according to the plurality of data objects and the target relationship obtained by the parsing unit, wherein the data relationship record includes at least part of the data objects in the database and the existing relationship therebetween; A query unit, used to query a target field that meets a preset condition from the data relationship record updated by the update unit, wherein the preset condition is related to the label of the field and whether the association relationship belongs to a preset relationship; an abnormality determination unit, configured to determine that the target behavior operation is an abnormal operation when the target field obtained by the query unit belongs to the plurality of data objects obtained by the parsing unit; The preset conditions include: The label of the associated field having an association relationship with the target field indicates that the associated field belongs to the privacy data, and the association relationship includes truncation, where the truncation is extracting a substring of the string corresponding to the associated field.
10. The device of claim 9, wherein: The acquisition unit is specifically used to periodically summarize the historical SQL statements in the database, and use the summarized historical SQL statements as the target SQL statements.
11. The device according to claim 9, wherein: The acquisition unit is specifically used to capture the SQL statement submitted by the user for execution as the target SQL statement.
12. The device of claim 9, wherein: The data relationship records are stored in the form of a graph, which includes nodes and connection edges. The nodes correspond to the data objects, and the connection edges correspond to the association relationships.
13. The device of claim 12, wherein: The updating unit comprises: A node adding subunit, configured to add a node corresponding to a first field not included in the data relationship record and included in the plurality of data objects in the pre-established graph; the first field belongs to a first data table already in the data relationship record; a connection edge adding subunit, configured to add a connection edge corresponding to the first association relationship in the graph according to a first association relationship between the first field included in the target association relationship and a second field already in the data relationship record; the second field belongs to a second data table already in the data relationship record; The connection edge adding subunit is further used to add a connection edge corresponding to the second association relationship between the first field and the first data table included in the target association relationship in the graph.
14. The device of claim 12, wherein: The updating unit comprises: A node adding subunit, configured to add a node corresponding to the third field and a node corresponding to the third data table in the pre-established graph according to the third field not included in the data relationship record and the third data table to which the third field belongs included in the plurality of data objects; a connection edge adding subunit, configured to add a connection edge corresponding to the third association relationship in the graph according to a third association relationship between the third field included in the target association relationship and a fourth field already in the data relationship record; the fourth field belongs to a fourth data table already in the data relationship record; The connection edge adding subunit is further used to add a connection edge corresponding to the fourth association relationship in the graph according to the fourth association relationship between the third field included in the target association relationship and the third data table.
15. The device of claim 12, wherein: The query unit comprises: A statement determination subunit, used to determine a graph query statement according to the preset conditions; The query subunit is used to use the graph query statement determined by the statement determination subunit to query the corresponding node from the updated graph, where the node corresponds to the target field.
16. The device of claim 9, wherein: The device also includes: an alarm unit, configured to issue an alarm for the target behavior operation after the abnormality determination unit determines that the target behavior operation is an abnormal operation; and / or, an interruption unit, used to interrupt the execution of the SQL statement corresponding to the target behavior operation; and / or, The executor determination unit is used to determine the executor corresponding to the target behavior operation.
17. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 8.
18. A computing device comprising a memory and a processor, wherein the memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 8 is implemented.
