Dynamic desensitization method and device for enterprise database, equipment and storage medium

By deploying a pre-trained SQL semantic analysis model in the enterprise database, combined with a syntax parser to identify the query intent and risk level of SQL statements, the shortcomings of existing SQL syntax parsers are addressed, achieving precise protection of sensitive information and ensuring the security and stability of the database.

CN121413026APending Publication Date: 2026-01-27HANGZHOU DBAPPSECURITY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511587935.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-31
Publication Date
2026-01-27

AI Technical Summary

Technical Problem

The existing dynamic data masking technology for enterprise databases relies on the accuracy and completeness of the SQL syntax parser, which can lead to problems such as accidentally blocking normal business operations, missing sensitive data, and being unable to defend against new types of attacks.

Method used

Deploy a pre-trained target SQL semantic analysis model, combined with a target SQL syntax parser, to identify the query intent of SQL statements and determine the risk level, intercept high-risk SQL statements, and make up for the shortcomings of traditional parsers through AI semantic analysis.

Benefits of technology

It achieves accurate protection of sensitive information, reduces the risk of malicious access and leakage of sensitive information, and ensures the safe and stable operation of the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121413026A_ABST
    Figure CN121413026A_ABST
Patent Text Reader

Abstract

The invention discloses a dynamic desensitization method and device for an enterprise database, equipment and a storage medium, and relates to the technical field of database security, and the method comprises the following steps: deploying a pre-trained target SQL semantic analysis model, and intercepting a to-be-queried SQL statement sent by a client; parsing statement information corresponding to the to-be-queried SQL statement by using a target SQL grammar parser; if the analysis fails, identifying a target query intention corresponding to the to-be-queried SQL statement by using the target SQL semantic analysis model, and determining a target risk level corresponding to the to-be-queried SQL statement based on the target query intention; and if the target risk level corresponding to the to-be-queried SQL statement is a preset high risk level, intercepting query of the to-be-queried SQL statement on a target enterprise database, and returning corresponding interception information. According to the method and the device, the sensitive information can be accurately protected in the access process of the enterprise database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database security technology, and in particular to a dynamic desensitization method, apparatus, device, and storage medium for enterprise databases. Background Technology

[0002] Against the backdrop of big data and digital transformation, enterprises and institutions have accumulated massive amounts of sensitive data, such as personal identification information, financial accounts, and health records. The leakage of this data can lead to privacy violations, economic losses, and other consequences. Therefore, preventing the illegal leakage of sensitive data while ensuring normal business access has become a core challenge in the field of data security.

[0003] Database firewalls, as a critical protection measure, can dynamically replace sensitive plaintext data with desensitized data in real time through techniques such as masking, encryption, and hashing, preventing the exposure of sensitive information. Current mainstream dynamic desensitization technologies rely on SQL syntax parsing to identify sensitive field access behavior, mainly falling into two categories: SQL statement rewriting and return result rewriting. The former identifies the SQL query for sensitive information before execution and then rewrites the statement, while the latter desensitizes the returned data after execution based on the parsing results.

[0004] However, these solutions heavily rely on the accuracy and completeness of the SQL syntax parser. In practical applications, SQL statements suffer from syntactic differences, complex structures, field splitting bypasses, and syntax errors, making traditional solutions prone to accidentally blocking normal business operations, missing sensitive data, and failing to defend against new types of attacks.

[0005] In conclusion, how to accurately protect sensitive information during access to enterprise databases is a pressing technical problem that needs to be solved. Summary of the Invention

[0006] In view of this, the purpose of this invention is to provide a dynamic desensitization method, apparatus, device, and storage medium for enterprise databases, which can accurately protect sensitive information during access to the enterprise database. The specific solution is as follows:

[0007] Firstly, this application provides a dynamic de-identification method for enterprise databases, including:

[0008] Deploy a pre-trained target SQL semantic analysis model and intercept the SQL statements to be queried sent by the client;

[0009] The target SQL syntax parser is used to parse the statement information corresponding to the SQL statement to be queried.

[0010] If parsing fails, the target SQL semantic analysis model is used to identify the target query intent corresponding to the SQL statement to be queried, and the target risk level corresponding to the SQL statement to be queried is determined based on the target query intent.

[0011] If the target risk level corresponding to the SQL statement to be queried is a preset high risk level, then the query of the SQL statement to be queried into the target enterprise database is intercepted, and the corresponding interception information is returned.

[0012] Optionally, before deploying the pre-trained target SQL semantic analysis model, the method further includes:

[0013] Through the business system corresponding to the target enterprise database, collect several first SQL statements for querying non-sensitive information in the target enterprise database, and collect several second SQL statements for querying sensitive information in the target enterprise database;

[0014] Data augmentation is performed on each of the second SQL statements, and several third SQL statements are determined based on the data augmentation results, so as to construct the target dataset using each of the first SQL statements and each of the third SQL statements.

[0015] Optionally, constructing the target dataset using each of the first SQL statements and each of the third SQL statements includes:

[0016] Mark the query intent corresponding to each of the first SQL statements as a normal query, and mark the query intent corresponding to each of the third SQL statements as an abnormal query;

[0017] The target dataset is constructed based on each first SQL statement, the query intent corresponding to each first SQL statement, each third SQL statement, and the query intent corresponding to each third SQL statement, so as to use the target dataset to train a pre-trained language model to obtain the target SQL semantic analysis model; the pre-trained language model is a model built based on Transformer.

[0018] Optionally, training the pre-trained language model using the target dataset to obtain the target SQL semantic analysis model includes:

[0019] Each first SQL statement and each third SQL statement in the target dataset is input into the pre-trained language model, and the query intent recognition result corresponding to each first SQL statement and each third SQL statement is output using the pre-trained language model.

[0020] Based on the cross-entropy loss function, a first loss is determined between the query intent recognition result corresponding to each first SQL statement and the query intent corresponding to each first SQL statement, and a second loss is determined between the query intent recognition result corresponding to each third SQL statement and the query intent corresponding to each third SQL statement.

[0021] The parameters of the pre-trained language model are optimized based on the first loss and the second loss to obtain the target SQL semantic analysis model based on the optimized pre-trained language model.

[0022] Optionally, after parsing the statement information corresponding to the SQL statement to be queried using the target SQL syntax parser, the method further includes:

[0023] If the parsing is successful, then based on the statement information corresponding to the SQL statement to be queried, it is determined whether the SQL statement to be queried accesses sensitive information in the target enterprise database;

[0024] If it is determined that the SQL statement to be queried accesses sensitive information in the target enterprise database, then the SQL statement to be queried is rewritten based on the de-identification function, and the target enterprise database is queried based on the rewritten SQL statement to be queried.

[0025] Alternatively, if it is determined that the SQL statement to be queried accesses sensitive information in the target enterprise database, then the target enterprise database is queried based on the SQL statement to be queried, and the query results are anonymized.

[0026] Optionally, the step of using the target SQL semantic analysis model to identify the target query intent corresponding to the SQL statement to be queried, and determining the target risk level corresponding to the SQL statement to be queried based on the target query intent, includes:

[0027] The target SQL semantic analysis model is used to perform semantic encoding on the SQL statement to be queried, and the target query intent corresponding to the SQL statement to be queried is identified based on the semantic encoding result;

[0028] If the target query intent is an abnormal query, then the target risk level corresponding to the SQL statement to be queried is determined to be a preset high-risk level;

[0029] If the target query intent is a normal query, then the target risk level corresponding to the SQL statement to be queried is determined to be a preset low risk level, and the target enterprise database is queried based on the SQL statement to be queried.

[0030] Optionally, the dynamic desensitization method for the enterprise database further includes:

[0031] Obtain several target SQL statements that were successfully identified by the target SQL semantic analysis model, and determine the results of manual annotation of the query intent of the target SQL statements;

[0032] Based on the target SQL statement and the query intent annotation results of the target SQL statement, the target SQL syntax parser and the target SQL semantic analysis model are optimized so that the optimized target SQL syntax parser can be used to parse the statement information corresponding to the new query SQL statement, and if the parsing fails, the optimized target SQL semantic analysis model can be used to identify the query intent corresponding to the new query SQL statement.

[0033] Secondly, this application provides a dynamic de-identification device for an enterprise database, comprising:

[0034] The SQL statement interception module is used to deploy a pre-trained target SQL semantic analysis model and intercept the SQL statements to be queried sent by the client.

[0035] The statement information parsing module is used to parse the statement information corresponding to the SQL statement to be queried using the target SQL syntax parser;

[0036] The risk level determination module is used to identify the target query intent corresponding to the SQL statement to be queried by using the target SQL semantic analysis model if the parsing fails, and to determine the target risk level corresponding to the SQL statement to be queried based on the target query intent.

[0037] The query interception module is used to intercept the query of the target enterprise database by the SQL statement to be queried if the target risk level corresponding to the SQL statement to be queried is a preset high risk level, and return the corresponding interception information.

[0038] Thirdly, this application provides an electronic device, comprising:

[0039] Memory, used to store computer programs;

[0040] A processor is used to execute the computer program to implement the aforementioned dynamic de-identification method for enterprise databases.

[0041] Fourthly, this application provides a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned dynamic desensitization method for an enterprise database.

[0042] In this application, a pre-trained target SQL semantic analysis model is first deployed to intercept the SQL statement to be queried sent by the client. Then, a target SQL syntax parser is used to parse the statement information corresponding to the SQL statement to be queried. If parsing fails, the target SQL semantic analysis model is used to identify the target query intent corresponding to the SQL statement to be queried, and the target risk level corresponding to the SQL statement to be queried is determined based on the target query intent. If the target risk level corresponding to the SQL statement to be queried is a preset high-risk level, the query of the SQL statement to the target enterprise database is intercepted, and corresponding interception information is returned. As can be seen above, this application first deploys a pre-trained target SQL semantic analysis model, then intercepts the SQL statement to be queried sent by the client. Next, the target SQL syntax parser is used to parse the relevant information of the SQL statement to be queried. If parsing fails, the deployed target SQL semantic analysis model is used to identify the target query intent of the statement, and the corresponding target risk level is determined based on the target query intent. When the SQL statement to be queried is determined to be a preset high-risk level, the query of the SQL statement to the target enterprise database is intercepted, and corresponding interception information is returned. In this way, by first parsing the SQL statement to be queried and then combining it with AI semantic analysis, this application can effectively address the situation where the SQL statement parsing fails, accurately identify and promptly intercept pre-set high-risk SQL queries, thereby reducing the risk of malicious access to the enterprise database or leakage of sensitive information, providing targeted protection for the enterprise database, and ensuring the secure and stable operation of the database. Attached Figure Description

[0043] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0044] Figure 1 A flowchart of a dynamic de-identification method for an enterprise database provided in this application;

[0045] Figure 2 A schematic diagram of a dynamic desensitization device for an enterprise database provided in this application;

[0046] Figure 3 This application provides a structural diagram of an electronic device. Detailed Implementation

[0047] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0048] Against the backdrop of big data and digital transformation, enterprises and institutions have accumulated massive amounts of sensitive data, such as personal identity information, financial accounts, and health records. The leakage of this data can lead to privacy violations, economic losses, and other consequences. Therefore, preventing the illegal leakage of sensitive data while ensuring normal business access has become a core challenge in the field of data security. Database firewalls, as a key protective measure, can dynamically de-identify sensitive plaintext data in real time, replacing it with de-identified data to prevent the exposure of sensitive information. Current mainstream dynamic de-identification technologies rely on SQL syntax parsing to identify sensitive field access behavior, mainly falling into two categories: SQL statement rewriting and return result rewriting. The former identifies the SQL query for sensitive information before execution and then rewrites the statement; the latter de-identifies the returned data after execution based on the parsing results. However, these solutions heavily rely on the accuracy and completeness of the SQL syntax parser. In practical applications, SQL statements often suffer from syntactic differences, complex structures, field splitting bypasses, and syntax errors, leading to situations where traditional solutions may mistakenly block normal business operations, miss sensitive data, or fail to defend against new types of attacks. Therefore, this application provides a dynamic desensitization scheme for enterprise databases, which can accurately protect sensitive information during the access process of enterprise databases.

[0049] See Figure 1 As shown in the figure, this invention discloses a dynamic de-identification method for enterprise databases, which may include:

[0050] Step S11: Deploy a pre-trained target SQL semantic analysis model and intercept the SQL statement to be queried sent by the client.

[0051] It should be noted that the core of this embodiment lies in introducing an AI (Artificial Intelligence) semantic analysis model to identify the access intent of SQL statements, thereby compensating for the shortcomings of traditional SQL syntax parsers in complex, erroneous, or variant SQL scenarios.

[0052] Therefore, in this embodiment, the target SQL semantic analysis model needs to be trained first. The specific process may include: firstly, collecting several first SQL statements for querying non-sensitive information in the target enterprise database through the business system corresponding to the target enterprise database, and collecting several second SQL statements for querying sensitive information in the target enterprise database; then, performing data augmentation on each second SQL statement, and determining several third SQL statements based on the data augmentation results; subsequently, labeling the query intent corresponding to each first SQL statement as a normal query, and labeling the query intent corresponding to each third SQL statement as an abnormal query; finally, constructing a target dataset based on each first SQL statement, the query intent corresponding to each first SQL statement, each third SQL statement, and the query intent corresponding to each third SQL statement, so as to use the target dataset to train the pre-trained language model to obtain the target SQL semantic analysis model; the pre-trained language model is a model built based on Transformer.

[0053] Specifically, in this embodiment, a pre-trained language model based on Transformer, such as BERT, RoFormer, or SQL-BERT, is used as the initial model to train the initial model and obtain the target SQL semantic analysis model. The input of the target SQL semantic analysis model is an SQL statement, and the output is the query intent classification result, including normal queries and abnormal queries. Abnormal queries include, but are not limited to, "sensitive data access," "SQL injection attack," "permission probe," "field splitting bypass attempt," and "syntax error (non-attack)." In order to determine the target SQL semantic analysis model based on the pre-trained language model, the first SQL statement used to query non-sensitive information in the target enterprise database can be collected from the real business system corresponding to the target enterprise database as a positive sample, and the query intent corresponding to the first SQL statement is labeled as a normal query. Next, a second SQL statement can be collected to query sensitive information in the target company's database, including (1) SQL statements with known attack patterns, such as 'OR 1=1--', UNION SELECT, DROP TABLE, etc.; (2) SQL statements split from sensitive fields, such as SELECTsubstr(id_card,1,6), substr(id_card,7) FROM user; (3) SQL statements used for privilege escalation, such as GRANT DBA TO attacker. Subsequently, in order to improve the robustness of the model, data augmentation operations such as syntax transformation, annotation insertion, and encoding obfuscation can be performed on the second SQL statement to obtain a third SQL statement, and the third SQL statement can be used as a negative sample to label the query intent corresponding to the third SQL statement as an abnormal query. Finally, a target dataset including the first SQL statement and the third SQL statement can be constructed so as to use the target dataset to train a pre-trained language model to obtain a target SQL semantic analysis model.

[0054] In this embodiment, the above-mentioned method of training a pre-trained language model using the target dataset to obtain a target SQL semantic analysis model can be specifically described as follows: First, input each first SQL statement and each third SQL statement from the target dataset into the pre-trained language model, and use the pre-trained language model to output the query intent recognition results corresponding to each first SQL statement and each third SQL statement; then, based on the cross-entropy loss function, determine the first loss between the query intent recognition results corresponding to each first SQL statement and the corresponding query intent, and the second loss between the query intent recognition results corresponding to each third SQL statement and the corresponding query intent; finally, optimize the parameters of the pre-trained language model based on the first and second losses to obtain the target SQL semantic analysis model based on the optimized pre-trained language model. Specifically, the pre-trained language model is trained under supervision using the first SQL statements and third SQL statements from the target dataset. The first SQL statements and third SQL statements are input into the pre-trained language model to obtain the query intent recognition results output by the model. Then, the loss between the query intent recognition results and the actual query intent corresponding to the SQL statements is determined based on the cross-entropy loss function, and the parameters of the pre-trained language model are optimized based on the loss. After training, the target SQL semantic analysis model is obtained. The target SQL semantic analysis model can output the corresponding query intent and confidence level for any SQL statement.

[0055] It should be noted that after training the target SQL semantic analysis model, it can be deployed to a database firewall or database proxy middleware to run as a "semantic analysis engine." Furthermore, the target SQL semantic analysis model supports hot updates, allowing for periodic loading of new versions to improve recognition capabilities. In this embodiment, the target SQL semantic analysis model is deployed in the database firewall or database proxy middleware within the enterprise database access path. All SQL statements sent by clients will be intercepted and further processed.

[0056] Step S12: Use the target SQL syntax parser to parse the statement information corresponding to the SQL statement to be queried.

[0057] In this embodiment, after intercepting the SQL statement to be queried sent by the client, the target SQL syntax parser is first called to perform structured parsing of the SQL statement to be queried in order to extract the corresponding statement information, including but not limited to (1) operation type, such as SELECT, INSERT, UPDATE, DELETE, etc.; (2) database, table, field involved; (3) function call, such as substr, concat, cast; (4) alias mapping relationship.

[0058] It should be noted that if the target SQL syntax parser successfully parses the SQL statement to be queried and identifies sensitive information accessed by the SQL statement to the target enterprise database, the SQL statement can be rewritten using a desensitization function to achieve desensitization; or, the query results can be desensitized. Specifically, if the target SQL syntax parser successfully parses the statement information corresponding to the SQL statement to be queried, it is then determined whether the SQL statement to be queried accesses sensitive information in the target enterprise database based on the statement information. In this embodiment, when determining whether the SQL statement to be queried accesses sensitive information in the target enterprise database, an association graph can be established between the SQL statement to be queried and the returned column data, i.e., a field tracing graph, as shown in Part 1. The `substr(id_card,1,6)` function is used to determine whether the returned column data of the SQL query is a sensitive field in the target company's database.

[0059] In one specific implementation, if it is determined that the SQL statement to be queried accesses sensitive information in the target company's database, the SQL statement to be queried can be rewritten based on a de-identification function, and the target company's database can be queried based on the rewritten SQL statement. For example, the de-identification function mask() can be used to change SELECT id_card FROM user to SELECT mask(id_card) FROM user.

[0060] In another specific implementation, if it is determined that the SQL statement to be queried accesses sensitive information in the target company's database, then the database is queried based on the SQL statement, and the query results are then anonymized. Specifically, after the SQL statement to be queried is executed, the result packet returned by the target company's database is intercepted. Combined with the syntax parsing results of the SQL statement, the sensitive fields corresponding to the returned columns are identified, and the result data is anonymized before being returned to the client.

[0061] Step S13: If parsing fails, the target SQL semantic analysis model is used to identify the target query intent corresponding to the SQL statement to be queried, and the target risk level corresponding to the SQL statement to be queried is determined based on the target query intent.

[0062] It's understandable that different databases have different SQL syntaxes. For example, double quotes in Oracle represent identifiers, while in MySQL they represent strings, making it difficult for parsers to adapt uniformly. Furthermore, SQL statements can be extremely complex, containing nested subqueries, Common Table Expressions (CTEs), window functions, dynamic concatenation, and other structures that existing parsers struggle to fully support. Additionally, attackers or administrators might bypass detection by splitting fields, for example, splitting the ID card field into two fields using `substr(id_card, 1, 6)` and `substr(id_card, 7)`. If the parser cannot establish a semantic association between the "segmented field and the original sensitive field," it cannot identify it as sensitive access, leading to the failure of desensitization. For SQL statements with grammatical errors, such as spelling mistakes or formatting errors, parsing will fail, making it impossible to determine whether it's a normal misoperation or a malicious attack attempt, such as SQL injection probing, thus failing to effectively block potential attacks. Therefore, when the SQL statement to be queried is too complex or has grammatical errors that cause the target SQL parser to fail, the query will be automatically handed over to the target SQL semantic analysis model for query intent identification. That is, the triggering conditions of the target SQL semantic analysis model can be: (1) SQL statement parsing fails, such as the parser throwing an exception; (2) SQL statement contains unsupported syntax structures, such as new window functions, recursive CTEs, etc.; (3) SQL statement length exceeds the limit or format is abnormal.

[0063] It should be noted that the process of using the target SQL semantic analysis model to identify the target query intent of the SQL statement to be queried, and determining the target risk level of the SQL statement to be queried based on the target query intent, can be as follows: First, the target SQL semantic analysis model is used to semantically encode the SQL statement to be queried, and the target query intent corresponding to the SQL statement to be queried is identified based on the semantic encoding result; then, if the target query intent is an abnormal query, the target risk level of the SQL statement to be queried is determined to be a preset high-risk level; finally, if the target query intent is a normal query, the target risk level of the SQL statement to be queried is determined to be a preset low-risk level, and the target enterprise database is queried based on the SQL statement to be queried.

[0064] Specifically, the SQL statement to be queried is input into the target SQL semantic analysis model. The target SQL semantic analysis model performs semantic encoding on the SQL statement and can identify the target query intent corresponding to the SQL statement based on the semantic encoding results. Then, it labels the target risk level of the SQL statement according to the target query intent: low risk for normal queries and high risk for abnormal queries. That is, when the target SQL semantic analysis model identifies the SQL statement as an abnormal query such as "sensitive data access," "SQL injection attack," "privilege probing," or "field splitting bypass attempt," it outputs a high-risk level; when it identifies the SQL statement as a "normal query," it outputs a low-risk level. For low-risk SQL statements, they can be directly forwarded to the target enterprise database for querying, and the query results can be conservatively anonymized, such as by masking all string fields.

[0065] In this embodiment, the target SQL semantic analysis model outputs not only the target query intent but also the target confidence level corresponding to the target query intent, as shown below:

[0066] (1) SQL: SELECT a,b FROM user WHERE 'x'='x' OR 1=1--→ The model identifies it as an "SQL injection attack", the target query intent is an abnormal query, and the confidence level is 98%;

[0067] (2) SQL: SELECT substr(id,1,5), reverse(id) FROM user → The model identifies it as "sensitive field splitting access", the target query intent is abnormal query, and the confidence level is 95%;

[0068] (2) SQL: SELCT * FROM user (SELECT spelling error) → The model identifies it as "syntax error (non-attack)", the target query intent is abnormal query, and the confidence level is 85%.

[0069] Furthermore, if the target confidence level corresponding to the target query intent output by the target SQL semantic analysis model is high, such as above 95%, the target query intent can be directly determined to be accurate and further processing can be carried out; if the target confidence level corresponding to the target query intent output by the target SQL semantic analysis model is low, such as below 70%, manual review can be performed to avoid misjudgment affecting business.

[0070] Step S14: If the target risk level corresponding to the SQL statement to be queried is a preset high risk level, then the query of the SQL statement to be queried on the target enterprise database is intercepted, and the corresponding interception information is returned.

[0071] In this embodiment, if the target risk level corresponding to the SQL statement to be queried is high-risk, the execution of the SQL statement to be queried needs to be blocked immediately and not forwarded to the target enterprise database. At the same time, the corresponding interception information, such as "access denied", can be returned, and a security alarm can be generated and an audit log can be recorded for subsequent analysis. It can be seen that this embodiment can achieve the following through a syntax parser and a target SQL semantic analysis model: (1) intelligent desensitization of complex SQL statements to avoid false blocking; (2) effective identification of bypassing methods such as field splitting and expression transformation; and (3) early blocking of the attack intent of SQL statements with grammatical errors.

[0072] It should be noted that for SQL statements that fail to be parsed by the target SQL syntax parser but are successfully identified by the target SQL semantic analysis model, these can be used to optimize the parser and model. The specific process may include: first, acquiring several target SQL statements successfully identified by the target SQL semantic analysis model and determining the manually labeled query intent of these statements; then, based on the target SQL statements and their labeled query intents, optimizing the target SQL syntax parser and the target SQL semantic analysis model. This allows the optimized parser to parse the statement information corresponding to new query SQL statements, and, if parsing fails, to use the optimized target SQL semantic analysis model to identify the query intent of new query SQL statements. Specifically, first, several target SQL statements successfully identified by the target SQL semantic analysis model are automatically collected, and security experts periodically manually label the query intent of these statements to confirm their true intent. Then, the target SQL statements and their labeled query intents can be used to optimize the target SQL syntax parser to supplement new syntax support; and the target SQL semantic analysis model can be optimized to improve the model's generalization ability. The optimized target SQL syntax parser and the optimized target SQL semantic analysis model are then applied to the desensitization processing of new SQL statements to be queried, so as to achieve adaptive evolution. Through continuous learning and rule self-optimization capabilities, manual maintenance costs can be reduced.

[0073] As can be seen from the above, in this embodiment, a pre-trained target SQL semantic analysis model is first deployed to intercept the SQL statement to be queried sent by the client. Then, a target SQL syntax parser is used to parse the statement information corresponding to the SQL statement to be queried. If parsing fails, the target SQL semantic analysis model is used to identify the target query intent corresponding to the SQL statement to be queried, and the target risk level corresponding to the SQL statement to be queried is determined based on the target query intent. If the target risk level corresponding to the SQL statement to be queried is a preset high-risk level, the query of the SQL statement to the target enterprise database is intercepted, and the corresponding interception information is returned. As can be seen from the above, in this application, a pre-trained target SQL semantic analysis model is first deployed, and then the SQL statement to be queried sent by the client is intercepted. Next, the target SQL syntax parser is used to parse the relevant information of the SQL statement to be queried. If parsing fails, the target query intent of the statement is identified by the deployed target SQL semantic analysis model, and the corresponding target risk level is determined based on the target query intent. When the SQL statement to be queried is determined to be a preset high-risk level, the query of the SQL statement to the target enterprise database is intercepted, and the corresponding interception information is returned. In this way, by first parsing the SQL statement to be queried and then combining it with the semantic analysis of the AI ​​model, this embodiment can effectively address the situation where the SQL statement parsing fails, accurately identify and promptly intercept pre-set high-risk SQL queries, thereby reducing the risk of malicious access to the enterprise database or leakage of sensitive information, providing targeted protection for the enterprise database, and ensuring the secure and stable operation of the database.

[0074] Accordingly, see Figure 2 As shown in the illustration, this application also provides a dynamic de-identification device for an enterprise database, which may include:

[0075] SQL statement interception module 11 is used to deploy a pre-trained target SQL semantic analysis model and intercept the SQL statement to be queried sent by the client.

[0076] Statement information parsing module 12 is used to parse the statement information corresponding to the SQL statement to be queried using the target SQL syntax parser;

[0077] The risk level determination module 13 is used to identify the target query intent corresponding to the SQL statement to be queried by using the target SQL semantic analysis model if the parsing fails, and to determine the target risk level corresponding to the SQL statement to be queried based on the target query intent.

[0078] The query interception module 14 is used to intercept the query of the target enterprise database by the SQL statement to be queried if the target risk level corresponding to the SQL statement to be queried is a preset high risk level, and return the corresponding interception information.

[0079] In some specific embodiments, the dynamic desensitization device for the enterprise database may further include:

[0080] The SQL statement acquisition module is used to acquire several first SQL statements for querying non-sensitive information in the target enterprise database through the business system corresponding to the target enterprise database, and to acquire several second SQL statements for querying sensitive information in the target enterprise database.

[0081] A dataset construction module is used to perform data augmentation on each of the second SQL statements and determine several third SQL statements based on the data augmentation results, so as to construct a target dataset using each of the first SQL statements and each of the third SQL statements.

[0082] In some specific implementations, the dataset construction module may include:

[0083] The query intent labeling submodule is used to label the query intent corresponding to each of the first SQL statements as a normal query and to label the query intent corresponding to each of the third SQL statements as an abnormal query.

[0084] The model training submodule is used to construct the target dataset based on each first SQL statement, the query intent corresponding to each first SQL statement, each third SQL statement, and the query intent corresponding to each third SQL statement, so as to use the target dataset to train the pre-trained language model to obtain the target SQL semantic analysis model; the pre-trained language model is a model built based on Transformer.

[0085] In some specific implementations, the model training submodule may include:

[0086] The recognition result output unit is used to input each of the first SQL statements and each of the third SQL statements in the target dataset into the pre-trained language model, and use the pre-trained language model to output the query intent recognition result corresponding to each of the first SQL statements and the query intent recognition result corresponding to each of the third SQL statements;

[0087] The loss determination unit is used to determine, based on the cross-entropy loss function, a first loss between the query intent recognition result corresponding to each of the first SQL statements and the query intent corresponding to each of the first SQL statements, and a second loss between the query intent recognition result corresponding to each of the third SQL statements and the query intent corresponding to each of the third SQL statements;

[0088] The parameter optimization unit is used to optimize the parameters of the pre-trained language model based on the first loss and the second loss, so as to obtain the target SQL semantic analysis model based on the optimized pre-trained language model.

[0089] In some specific embodiments, the dynamic desensitization device for the enterprise database may further include:

[0090] The condition judgment unit is used to determine whether the SQL statement to be queried accesses sensitive information in the target enterprise database based on the statement information corresponding to the SQL statement to be queried if the statement information corresponding to the SQL statement to be queried is successfully parsed using the target SQL syntax parser.

[0091] The SQL statement rewriting unit is used to rewrite the SQL statement to be queried based on the desensitization function if it is determined that the SQL statement to be queried accesses sensitive information in the target enterprise database, and then query the target enterprise database based on the rewritten SQL statement to be queried.

[0092] The query result desensitization unit is used to query the target enterprise database based on the query SQL statement if it is determined that the SQL statement to be queried accesses sensitive information in the target enterprise database, and to desensitize the query results.

[0093] In some specific embodiments, the risk level determination module 13 may include:

[0094] The query intent recognition unit is used to perform semantic encoding on the SQL statement to be queried using the target SQL semantic analysis model, and to identify the target query intent corresponding to the SQL statement to be queried based on the semantic encoding result;

[0095] A preset high-risk level determination unit is used to determine the target risk level corresponding to the SQL statement to be queried as a preset high-risk level if the target query intent is an abnormal query.

[0096] A preset low-risk level determination unit is used to determine the target risk level corresponding to the SQL statement to be queried as a preset low-risk level if the target query intent is a normal query, and to query the target enterprise database based on the SQL statement to be queried.

[0097] In some specific embodiments, the dynamic desensitization device for the enterprise database may further include:

[0098] The annotation result determination unit is used to obtain several target SQL statements that have been successfully identified by the target SQL semantic analysis model, and to determine the annotation results of the query intent of the target SQL statements by the human.

[0099] The model optimization unit is used to optimize the target SQL syntax parser and the target SQL semantic analysis model based on the target SQL statement and the query intent annotation result of the target SQL statement, so as to use the optimized target SQL syntax parser to parse the statement information corresponding to the new query SQL statement, and to use the optimized target SQL semantic analysis model to identify the query intent corresponding to the new query SQL statement after the parsing fails.

[0100] Furthermore, embodiments of this application also disclose an electronic device, Figure 3 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the dynamic de-identification method for enterprise databases disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0101] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0102] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0103] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the dynamic de-identification method for the enterprise database executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.

[0104] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned dynamic de-identification method for an enterprise database. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0105] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0106] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0107] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0108] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0109] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A dynamic desensitization method for enterprise databases, characterized in that, include: Deploy a pre-trained target SQL semantic analysis model and intercept the SQL statements to be queried sent by the client; The target SQL syntax parser is used to parse the statement information corresponding to the SQL statement to be queried. If parsing fails, the target SQL semantic analysis model is used to identify the target query intent corresponding to the SQL statement to be queried, and the target risk level corresponding to the SQL statement to be queried is determined based on the target query intent. If the target risk level corresponding to the SQL statement to be queried is a preset high risk level, then the query of the SQL statement to be queried into the target enterprise database is intercepted, and the corresponding interception information is returned.

2. The dynamic desensitization method for enterprise databases according to claim 1, characterized in that, Before deploying the pre-trained target SQL semantic analysis model, the following is also included: Through the business system corresponding to the target enterprise database, collect several first SQL statements for querying non-sensitive information in the target enterprise database, and collect several second SQL statements for querying sensitive information in the target enterprise database; Data augmentation is performed on each of the second SQL statements, and several third SQL statements are determined based on the data augmentation results, so as to construct the target dataset using each of the first SQL statements and each of the third SQL statements.

3. The dynamic desensitization method for enterprise databases according to claim 2, characterized in that, The construction of the target dataset using each of the first SQL statements and each of the third SQL statements includes: Mark the query intent corresponding to each of the first SQL statements as a normal query, and mark the query intent corresponding to each of the third SQL statements as an abnormal query; The target dataset is constructed based on each first SQL statement, the query intent corresponding to each first SQL statement, each third SQL statement, and the query intent corresponding to each third SQL statement, so as to use the target dataset to train a pre-trained language model to obtain the target SQL semantic analysis model; the pre-trained language model is a model built based on Transformer.

4. The dynamic desensitization method for enterprise databases according to claim 3, characterized in that, The step of training the pre-trained language model using the target dataset to obtain the target SQL semantic analysis model includes: Each first SQL statement and each third SQL statement in the target dataset is input into the pre-trained language model, and the query intent recognition result corresponding to each first SQL statement and each third SQL statement is output using the pre-trained language model. Based on the cross-entropy loss function, a first loss is determined between the query intent recognition result corresponding to each first SQL statement and the query intent corresponding to each first SQL statement, and a second loss is determined between the query intent recognition result corresponding to each third SQL statement and the query intent corresponding to each third SQL statement. The parameters of the pre-trained language model are optimized based on the first loss and the second loss to obtain the target SQL semantic analysis model based on the optimized pre-trained language model.

5. The dynamic desensitization method for enterprise databases according to claim 1, characterized in that, After parsing the statement information corresponding to the SQL statement to be queried using the target SQL syntax parser, the process further includes: If the parsing is successful, then based on the statement information corresponding to the SQL statement to be queried, it is determined whether the SQL statement to be queried accesses sensitive information in the target enterprise database; If it is determined that the SQL statement to be queried accesses sensitive information in the target enterprise database, then the SQL statement to be queried is rewritten based on the de-identification function, and the target enterprise database is queried based on the rewritten SQL statement to be queried. Alternatively, if it is determined that the SQL statement to be queried accesses sensitive information in the target enterprise database, then the target enterprise database is queried based on the SQL statement to be queried, and the query results are anonymized.

6. The dynamic desensitization method for enterprise databases according to claim 1, characterized in that, The step of using the target SQL semantic analysis model to identify the target query intent corresponding to the SQL statement to be queried, and determining the target risk level corresponding to the SQL statement to be queried based on the target query intent, includes: The target SQL semantic analysis model is used to perform semantic encoding on the SQL statement to be queried, and the target query intent corresponding to the SQL statement to be queried is identified based on the semantic encoding result; If the target query intent is an abnormal query, then the target risk level corresponding to the SQL statement to be queried is determined to be a preset high-risk level; If the target query intent is a normal query, then the target risk level corresponding to the SQL statement to be queried is determined to be a preset low risk level, and the target enterprise database is queried based on the SQL statement to be queried.

7. The dynamic desensitization method for enterprise databases according to any one of claims 1 to 6, characterized in that, Also includes: Obtain several target SQL statements that were successfully identified by the target SQL semantic analysis model, and determine the results of manual annotation of the query intent of the target SQL statements; Based on the target SQL statement and the query intent annotation results of the target SQL statement, the target SQL syntax parser and the target SQL semantic analysis model are optimized so that the optimized target SQL syntax parser can be used to parse the statement information corresponding to the new query SQL statement, and if the parsing fails, the optimized target SQL semantic analysis model can be used to identify the query intent corresponding to the new query SQL statement.

8. A dynamic desensitization device for an enterprise database, characterized in that, include: The SQL statement interception module is used to deploy a pre-trained target SQL semantic analysis model and intercept the SQL statements to be queried sent by the client. The statement information parsing module is used to parse the statement information corresponding to the SQL statement to be queried using the target SQL syntax parser; The risk level determination module is used to identify the target query intent corresponding to the SQL statement to be queried by using the target SQL semantic analysis model if the parsing fails, and to determine the target risk level corresponding to the SQL statement to be queried based on the target query intent. The query interception module is used to intercept the query of the target enterprise database by the SQL statement to be queried if the target risk level corresponding to the SQL statement to be queried is a preset high risk level, and return the corresponding interception information.

9. An electronic device, characterized in that, The electronic device includes a processor and a memory; wherein the memory is used to store a computer program, which is loaded and executed by the processor to implement the dynamic de-identification method for an enterprise database as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store computer programs, which, when executed by a processor, implement the dynamic desensitization method for an enterprise database as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Database operation log risk early warning method and system

    CN121722650A