A database query statement detection method, device, medium and program product

By establishing a sensitive keyword database and a dual-channel verification mechanism, the problems of low efficiency and poor accuracy in database query statement detection in existing technologies have been solved, enabling efficient identification and accurate location of non-standard named sensitive fields.

CN122489731APending Publication Date: 2026-07-31INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
INDUSTRIAL AND COMMERCIAL BANK OF CHINA
Filing Date
2025-08-29
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing technologies are inefficient and inaccurate in detecting database query statements in big data environments, especially when dealing with sensitive fields with non-standard naming conventions, which are prone to missed detections and misjudgments.

Method used

By establishing a sensitive keyword database and utilizing multi-level filtering and multi-dimensional verification mechanisms, combined with grammatical analysis and dual-channel verification, sensitive words in database query statements can be identified and the source table name and source column name can be located.

Benefits of technology

It improves the efficiency and accuracy of detecting large batches of database query statements, can identify sensitive fields with non-standard naming, dynamically adapts to complex scenarios, and reduces the rate of missed and false positives.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122489731A_ABST
    Figure CN122489731A_ABST
Patent Text Reader

Abstract

This invention discloses a method, device, medium, and program product for detecting database query statements. Applicable to the fields of big data and artificial intelligence, specifically information security and fintech, the method includes: establishing a sensitive keyword library based on a sample set of sensitive and non-sensitive query statements; parsing the target database query statement and calculating the sensitivity of each business term; when sensitive terms are identified in the target database query statement based on their sensitivity, determining the source table name and source column name queried by the target database query statement; and identifying the sensitive attributes of the source table name and source column name using a dual-channel verification mechanism, and determining the sensitivity detection result of the target database query statement. This technical solution supports rapid detection of large batches of database query statements and can identify sensitive fields with non-standard naming, improving detection timeliness and accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of big data and artificial intelligence, and can be specifically applied to the fields of information security and financial technology. In particular, it relates to a method, device, medium, and program product for detecting database query statements. Background Technology

[0002] Databases are widely used in various business scenarios, and in some scenarios, databases store a large amount of private information. If this private information is accessed without authorization through database query statements, it may lead to risks such as privacy leaks. Therefore, it is necessary to detect database statements in a timely manner to identify unnecessary access to sensitive information and thus prevent the risk of data leakage.

[0003] In existing technologies, security experts typically manually parse database query statements, manually identify sensitive fields involved, and determine whether there is any unnecessary access to sensitive data. Alternatively, static rule matching can be used to match field names and table names in database query statements based on simple string matching or regular expressions. If keywords are matched, the query is considered sensitive.

[0004] When faced with massive query logs in a big data environment, manual review is extremely inefficient and prone to delays. Static rule matching relies on a fixed keyword library, which cannot handle scenarios such as non-standard field naming and synonyms, and is prone to missed judgments. Furthermore, rule updates lag behind business changes, resulting in poor detection timeliness. Summary of the Invention

[0005] This invention provides a method, device, medium, and program product for detecting database query statements, which can support rapid detection of a large number of database query statements and can identify sensitive fields with non-standard naming, adapting to business changes and improving detection timeliness and accuracy.

[0006] According to one aspect of the present invention, a method for detecting database query statements is provided, comprising:

[0007] A sensitive keyword database was established based on a sample set of sensitive query statements and a sample set of non-sensitive query statements.

[0008] The query statements in the target database are parsed, and the sensitivity of each business term is calculated based on the sensitive keyword database and the parsing results.

[0009] When sensitive words are identified in the target database query statement based on the sensitivity of each business term, the source table name and source column name queried by the target database query statement are determined.

[0010] Based on the dual-channel verification mechanism, the sensitive attributes of the source table name and source column name are identified, and the sensitivity detection results of the target database query statement are determined according to the identified sensitive attributes.

[0011] Optionally, a sensitive keyword database can be established based on a sample set of sensitive query statements and a sample set of non-sensitive query statements, including:

[0012] Standardize and split historical database query statements from both sensitive and non-sensitive data sample sets to obtain a basic vocabulary set.

[0013] For each basic word in the basic vocabulary set, calculate multiple reference values;

[0014] Based on the reference values ​​of each basic vocabulary word, the basic vocabulary words are filtered at multiple levels, and the basic vocabulary words retained after multiple levels of filtering are used to form a sensitive keyword library.

[0015] The advantages of this setup are as follows: by using lowercase, removing comments, and standardizing formatting, misjudgments of words caused by differences in capitalization, redundant comments, or non-standard formatting can be avoided. Based on the feature extraction of sample differences, compared with the method of relying on manual subjective definition of sensitive keyword library, the keyword library can be made to better fit the expression habits of sensitive information in actual business. Through multiple rounds of screening, the words that are finally retained can have clear sensitive orientation, reduce interference from irrelevant words, and improve the construction efficiency of sensitive keyword library.

[0016] Optionally, for each basic word in the basic vocabulary set, calculate multiple reference values, including:

[0017] Obtain the sample counts from the sensitive query statement sample set and the non-sensitive query statement sample set respectively, and count the frequency of each basic word in the sensitive query statement sample set and the non-sensitive query statement sample set.

[0018] Based on the sample size of each sample set and the frequency statistics of each basic word, the word frequency-inverse document frequency weight, sensitive tag chi-square statistic, and information gain of each basic word are calculated respectively.

[0019] The advantage of this setting is that, based on calculations using multiple parameters, the sensitivity characteristics of words can be verified from multiple dimensions, avoiding problems such as misjudging high-frequency non-sensitive words or missing low-frequency but key sensitive words due to a single indicator.

[0020] Optionally, based on the reference values ​​of each basic vocabulary word, multi-level filtering is performed on each basic vocabulary word, and the basic vocabulary words retained after multi-level filtering are compiled into a sensitive keyword library, including:

[0021] Based on the frequency statistics of each basic word, the frequency ratio of each basic word is calculated, and a first-level filter is performed based on the frequency ratio of each basic word to determine the first-level words.

[0022] Based on the chi-square statistics of the sensitive tags of each primary word, the probability that the current association strength of each primary word is caused by random factors is calculated, and secondary filtering is performed based on the probability calculation results to determine the secondary words.

[0023] Based on the information gain of each secondary vocabulary, a tertiary filtering process is performed to determine the tertiary vocabulary.

[0024] Based on the word frequency-inverse document frequency weight, sensitive tag chi-square statistic, and information gain of each level 3 vocabulary, a comprehensive score is calculated for each level 3 vocabulary. The comprehensive scores are then sorted in descending order. Level 4 vocabulary is determined based on the sorting results, and each level 4 vocabulary is used to form a sensitive keyword library.

[0025] The advantage of this setup is that multi-level filtering can balance the influence of multiple dimensions of indicators, ultimately selecting the core words with the highest scores, ensuring the core nature of the sensitive keyword library, guaranteeing that the sensitive keyword library contains the most representative sensitive words, and avoiding redundancy.

[0026] Optionally, the query statement in the target database is parsed, and the sensitivity of each business term is calculated based on the sensitive keyword database and the parsing results, including:

[0027] Multiple business terms are identified in the query statement of the target database, and each business term is matched with the sensitive keyword database. The basic confidence level of each business term is determined based on the matching results.

[0028] Perform syntactic analysis on the query statement of the target database, and determine the positional risk coefficient of each business term based on the syntactic context of each business term in the query statement of the target database.

[0029] When the grammatical analysis results of business terms trigger the preset dynamic environment correction mechanism, the environment correction factor of the business terms is determined.

[0030] The sensitivity of each business term is calculated based on its basic confidence level, location risk coefficient, and environmental correction factor.

[0031] The advantage of this setup is that traditional methods judge sensitivity solely through keyword matching, ignoring the actual role and environmental impact of words in database query statements, which can easily lead to misjudgments. In contrast, this application cross-validates from three dimensions, significantly reducing the false negative and false positive rates of single-dimensional detection, and can dynamically adapt to complex scenarios, thereby enhancing the robustness of sensitive word detection.

[0032] Optionally, when sensitive words are identified in the target database query statement based on the sensitivity of each business term, the source table name and source column name queried by the target database query statement are determined, including:

[0033] When it is determined that there are business terms in the target database query statement with a sensitivity greater than the sensitivity threshold, it is determined that there are sensitive terms in the target database query statement.

[0034] Extract structured quadruples from the query statement in the target database, check the validity of the source tracing based on the structured quadruples, and when the source tracing is determined to be valid, determine the source table name and source column name queried by the query statement in the target database based on the structured quadruples.

[0035] The advantage of this setup is that it can accurately locate the original storage location of sensitive information through structured quadruples, ensuring the authenticity and reliability of traceability results, avoiding erroneous associations caused by syntactic ambiguity, and thus improving detection efficiency and interpretability.

[0036] Optionally, based on a dual-channel verification mechanism, identify sensitive attributes of the source table name and source column name, including:

[0037] The first verification channel calls the application programming interface of the data query platform to identify the sensitive attributes of the source table name and the source column name;

[0038] If the sensitive attributes cannot be identified through the first verification channel, then the target database query statement, source table name, and source column name are input into the semantic analysis model through the second verification channel. Based on the type determination result and confidence score output by the semantic analysis model, the sensitive attributes of the source table name and source column name are determined.

[0039] The advantages of this setup are that the dual-channel verification mechanism can complement each other. For organizations with a data query platform, the first verification channel can directly reuse existing sensitive tags without additional development, thus improving efficiency. The second verification channel provides sensitive attribute identification for small organizations without a separate data query platform. It does not rely on external systems, has good compatibility, and can effectively improve the accuracy of sensitive query statement identification in various scenarios. It is adaptable to multiple scenarios and enhances the robustness of identification.

[0040] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0041] At least one processor; and

[0042] A memory communicatively connected to the at least one processor; wherein,

[0043] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to execute the database query statement detection method according to any embodiment of the present invention.

[0044] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions, the computer instructions being configured to cause a processor to execute and implement the database query statement detection method according to any embodiment of the present invention.

[0045] According to another aspect of the present invention, a computer program product is provided, the computer program product comprising a computer program that, when executed by a processor, implements the database query statement detection method according to any embodiment of the present invention.

[0046] The technical solution of this invention establishes a sensitive keyword library based on a sample set of sensitive and non-sensitive query statements. It then parses the target database query statements and calculates the sensitivity of each business term based on the sensitive keyword library and the parsing results. When sensitive terms are identified in the target database query statement based on their sensitivity, the source table name and source column name are determined. A dual-channel verification mechanism identifies the sensitive attributes of the source table name and source column name, and the sensitivity detection result of the target database query statement is determined based on these identified attributes. This approach makes the sensitive keyword library more aligned with the expression habits of sensitive information in actual business operations, ensuring that the selected sensitive keywords have clear sensitivity targeting, reducing interference from irrelevant words, and improving the efficiency of building the sensitive keyword library. Furthermore, based on the sensitive keyword library, it enables rapid detection of large batches of database query statements and can identify non-standard named sensitive fields, improving detection timeliness and accuracy.

[0047] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0048] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used 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 those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0049] Figure 1This is a flowchart of a database query statement detection method provided according to Embodiment 1 of the present invention;

[0050] Figure 2 This is a flowchart of another database query statement detection method provided according to Embodiment 2 of the present invention;

[0051] Figure 3 This is a schematic diagram of the structure of a database query statement detection device according to Embodiment 3 of the present invention;

[0052] Figure 4 This is a schematic diagram of the structure of an electronic device that implements the database query statement detection method of this invention. Detailed Implementation

[0053] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. 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 should fall within the scope of protection of the present invention.

[0054] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0055] Example 1

[0056] Figure 1 This is a flowchart of a database query statement detection method provided in Embodiment 1 of the present invention. This embodiment is applicable to detecting whether a database query statement involves unnecessary sensitive information. The method can be executed by a database query statement detection device, which can be implemented in hardware and / or software, and is generally configured in a computer or processor with data processing capabilities. Figure 1 As shown, the method includes:

[0057] S110. Based on the sample sets of sensitive query statements and the sample sets of non-sensitive query statements, establish a sensitive keyword database.

[0058] Optionally, the sensitive query statement sample set can refer to the set of database query statements that contain sensitive information access behavior, and the non-sensitive query statement sample set can refer to the set of database query statements that do not involve sensitive information access. As a comparison sample, it is used to distinguish the distribution differences between sensitive and non-sensitive words. The sensitive query statement sample set and the non-sensitive query statement sample set can be determined by tagging and classifying the historical query statements of the target database.

[0059] The sensitive keyword database, established based on a sample set of sensitive and non-sensitive query statements, may include:

[0060] Standardize and split historical database query statements from both sensitive and non-sensitive data sample sets to obtain a basic vocabulary set.

[0061] For each basic word in the basic vocabulary set, calculate multiple reference values;

[0062] Based on the reference values ​​of each basic vocabulary word, the basic vocabulary words are filtered at multiple levels, and the basic vocabulary words retained after multiple levels of filtering are used to form a sensitive keyword library.

[0063] Optionally, standardization can refer to the process of uniformly adjusting the format of database query statements to eliminate interfering factors. Specifically, this includes: lowercase conversion, comment removal, and syntax cleaning. Lowercase conversion refers to converting all letters in the statement to lowercase, such as converting the query statement SELECT to the query statement select, thereby eliminating the impact of case differences on word matching. Comment removal refers to deleting single-line comments and block comments in the database query statement to avoid the comment content interfering with word extraction. Syntax cleaning refers to removing redundant spaces, standardizing operator formats, etc., to ensure that the statement structure is standardized.

[0064] Optionally, after standardization, the statement can be split into indivisible atomic sequences of words using delimiters and database query statement operators, and reserved words specified in the database query statement can be deleted. For example, content that is not directly related to the query information, such as the select statement and the where conditional statement, can be deleted, thereby forming a basic vocabulary set of the remaining words.

[0065] Optionally, the reference value can refer to the index used to measure the sensitivity of words by quantitatively analyzing their distribution characteristics in sensitive and non-sensitive sample sets for each word in the basic vocabulary set. The reference value may include the number of samples in the sensitive and non-sensitive query sample sets, the frequency of each basic word in the sensitive and non-sensitive query sample sets, the word frequency-inverse document frequency weight of each basic word, the chi-square statistic of sensitive tags, and information gain.

[0066] Optionally, the basic vocabulary can be screened multiple times based on reference values ​​to retain words with significant sensitive characteristics, and the final retained basic vocabulary can be used to form a sensitive keyword library.

[0067] The advantages of this setup are as follows: by using lowercase, removing comments, and standardizing formatting, misjudgments of words caused by differences in capitalization, redundant comments, or non-standard formatting can be avoided. Based on the feature extraction of sample differences, compared with the method of relying on manual subjective definition of sensitive keyword library, the keyword library can be made to better fit the expression habits of sensitive information in actual business. Through multiple rounds of screening, the words that are finally retained can have clear sensitive orientation, reduce interference from irrelevant words, and improve the construction efficiency of sensitive keyword library.

[0068] Optionally, the method may further include:

[0069] If an initial sensitive word set is pre-constructed based on expert experience, the initial sensitive word set is filtered according to the basic vocabulary retained after multi-level filtering. A sensitive keyword library is then formed based on the basic vocabulary retained after multi-level filtering and the filtering results of the initial sensitive word set.

[0070] Optionally, the method may also include: periodically updating the sensitive keyword database.

[0071] S120. Parse the query statement of the target database, and calculate the sensitivity of each business term based on the sensitive keyword database and the parsing results.

[0072] This includes parsing the query statements in the target database and calculating the sensitivity of each business term based on the sensitive keyword database and the parsing results. This may include:

[0073] Multiple business terms are identified in the query statement of the target database, and each business term is matched with the sensitive keyword database. The basic confidence level of each business term is determined based on the matching results.

[0074] Perform syntactic analysis on the query statement of the target database, and determine the positional risk coefficient of each business term based on the syntactic context of each business term in the query statement of the target database.

[0075] When the grammatical analysis results of business terms trigger the preset dynamic environment correction mechanism, the environment correction factor of the business terms is determined.

[0076] The sensitivity of each business term is calculated based on its basic confidence level, location risk coefficient, and environmental correction factor.

[0077] Optionally, the target database query statement is the user query statement obtained in the actual business scenario, and the business terms can refer to the terms to be detected in the target database query statement.

[0078] Optionally, the basic confidence level can refer to the initial value that quantifies the degree of correlation between business terms and sensitive keyword database after they are matched, reflecting the sensitive attributes of the terms themselves. When business terms and sensitive keyword database match to different degrees, the corresponding basic confidence level is different.

[0079] In an optional example, a first base value is assigned when the business term and the sensitive term are completely identical; a second base value is assigned when the business term and the sensitive term can be matched with the thesaurus; a third base value is assigned when the compound word part of the business term matches the core word root of the sensitive term; and a fourth base value is assigned when the business term and the sensitive term are fuzzy matches.

[0080] Optionally, syntax analysis can refer to parsing the structure of the target database query statement based on an abstract syntax tree, identifying the position of business terms in the database query syntax, such as the projected columns in the query statement and the WHERE condition in the conditional statement. Business terms have different risk coefficients in different grammatical positions. For example, the WHERE condition value in the conditional statement is given the highest risk coefficient because it directly locates a specific individual; the projected columns in the query statement are given the second risk coefficient because they actively obtain sensitive information; subqueries or temporary tables are reduced to the third risk coefficient because they are not the final output, etc. Since database query statements are quite complex, they are not listed here one by one.

[0081] Optionally, the dynamic environment correction mechanism can refer to the rules for adjusting the sensitivity based on the real-time operating environment in which the business term is located. For example, when the business term is desensitized and the operation object is a system table, the dynamic environment correction mechanism can be triggered, and then the environment correction factor can be determined based on the real-time operating environment in which the business term is located.

[0082] Furthermore, the sensitivity of a business term can be calculated by multiplying its basic confidence level, location risk coefficient, and environmental correction factor.

[0083] The advantage of this setup is that traditional methods judge sensitivity solely through keyword matching, ignoring the actual role and environmental impact of words in database query statements, which can easily lead to misjudgments. In contrast, this application cross-validates from three dimensions, significantly reducing the false negative and false positive rates of single-dimensional detection, and can dynamically adapt to complex scenarios, thereby enhancing the robustness of sensitive word detection.

[0084] S130. When sensitive words are identified in the target database query statement based on the sensitivity of each business term, the source table name and source column name queried by the target database query statement are determined.

[0085] Specifically, when sensitive words are identified in the target database query statement based on the sensitivity of each business term, the source table name and source column name queried by the target database query statement are determined, which may include:

[0086] When it is determined that there are business terms in the target database query statement with a sensitivity greater than the sensitivity threshold, it is determined that there are sensitive terms in the target database query statement.

[0087] Extract structured quadruples from the query statement in the target database. Detect the validity of the source tracing based on the structured quadruples. When the source tracing is confirmed to be valid, determine the source table name and source column name queried by the query statement in the target database based on the structured quadruples. The source table name refers to the name of the physical data table corresponding to the sensitive words, and the source column name refers to the field name in the physical data table corresponding to the sensitive words.

[0088] Optionally, the query statement from the target database containing sensitive words can be input into a pre-trained large language model. The large language model can then perform in-depth analysis of the query statement to accurately trace the original data source of the final output column.

[0089] Optionally, in processing target database queries, the large language model ignores table aliases and computational transformations, focusing instead on identifying the base table and base column sources of the selected projection columns in the query statement. For direct column references, the model directly extracts the base table name and base column name; for output columns containing aliases, the model traces the physical source through the alias layer; for complex expressions, the model deconstructs the computation process to extract the original columns involved in the calculation; when processing nested structures, the model recursively parses subqueries, common table expressions, and view definitions until the physical base table is located. Then, based on the parsing results, it generates a set of structured quadruples <data query statement identifier, output alias, source table name, source column name>, and performs syntax consistency checks through an abstract syntax tree validator to ensure that each tracing path has a valid reference relationship in the database schema. For ambiguous columns without specified table names, the model resolves unique attribution based on the semantic context of the clause and database schema constraints.

[0090] The advantage of this setup is that it can accurately locate the original storage location of sensitive information through structured quadruples, ensuring the authenticity and reliability of traceability results, avoiding erroneous associations caused by syntactic ambiguity, and thus improving detection efficiency and interpretability.

[0091] S140. Based on the dual-channel verification mechanism, identify the sensitive attributes of the source table name and source column name, and determine the sensitivity detection result of the target database query statement based on the identified sensitive attributes.

[0092] The sensitive attributes for identifying source table names and source column names based on the dual-channel verification mechanism may include:

[0093] The first verification channel calls the application programming interface of the data query platform to identify the sensitive attributes of the source table name and the source column name;

[0094] If the sensitive attributes cannot be identified through the first verification channel, then the target database query statement, source table name, and source column name are input into the semantic analysis model through the second verification channel. Based on the type determination result and confidence score output by the semantic analysis model, the sensitive attributes of the source table name and source column name are determined.

[0095] Optionally, sensitive attributes can be either sensitive or non-sensitive. If the first verification channel is available, the sensitive attributes of the target database query statement can be directly output. If the first verification channel is unavailable, the type determination result and confidence score of the semantic analysis model are obtained. When the type determination result is sensitive and the confidence score is higher than the target score, the model output is adopted, and the target database query statement is determined to be a sensitive query statement.

[0096] The advantages of this setup are that the dual-channel verification mechanism can complement each other. For organizations with a data query platform, the first verification channel can directly reuse existing sensitive tags without additional development, thus improving efficiency. The second verification channel provides sensitive attribute identification for small organizations without a separate data query platform. It does not rely on external systems, has good compatibility, and can effectively improve the accuracy of sensitive query statement identification in various scenarios. It is adaptable to multiple scenarios and enhances the robustness of identification.

[0097] The technical solution of this invention establishes a sensitive keyword library based on a sample set of sensitive and non-sensitive query statements. It then parses the target database query statements and calculates the sensitivity of each business term based on the sensitive keyword library and the parsing results. When sensitive terms are identified in the target database query statement based on their sensitivity, the source table name and source column name are determined. A dual-channel verification mechanism identifies the sensitive attributes of the source table name and source column name, and the sensitivity detection result of the target database query statement is determined based on these identified attributes. This approach makes the sensitive keyword library more aligned with the expression habits of sensitive information in actual business operations, ensuring that the selected sensitive keywords have clear sensitivity targeting, reducing interference from irrelevant words, and improving the efficiency of building the sensitive keyword library. Furthermore, based on the sensitive keyword library, it enables rapid detection of large batches of database query statements and can identify non-standard named sensitive fields, improving detection timeliness and accuracy.

[0098] Example 2

[0099] Figure 2 This is a flowchart illustrating a database query statement detection method provided in Embodiment 2 of the present invention. Based on the above embodiments, this embodiment specifically describes the method for establishing a sensitive keyword database. Figure 2 As shown, the method includes:

[0100] S210. Standardize and split the historical database query statements in the sensitive data sample set and the non-sensitive data sample set to obtain a basic vocabulary set.

[0101] In an optional example, S can be used. sens S represents a set of sensitive data samples. non Let W represent a set of non-sensitive data samples. The basic vocabulary set can be represented by W, and the words in the basic vocabulary set can be represented by w (w∈W).

[0102] S220. For each basic word in the basic vocabulary set, calculate multiple reference values.

[0103] For each basic word in the basic vocabulary set, multiple reference values ​​are calculated, which may include:

[0104] Obtain the sample counts from the sensitive query statement sample set and the non-sensitive query statement sample set respectively, and count the frequency of each basic word in the sensitive query statement sample set and the non-sensitive query statement sample set.

[0105] Based on the sample size of each sample set and the frequency statistics of each basic word, the word frequency-inverse document frequency weight, sensitive tag chi-square statistic, and information gain of each basic word are calculated respectively.

[0106] Continuing the previous example, the number of samples in the sensitive query statement sample set can be represented by |S sens | indicates that the number of samples in the non-sensitive query statement sample set can be represented by |S. non | indicates that the frequency of the basic word 'w' appearing in the sensitive query sample set can be represented by 'f'. sens (w) indicates that the frequency of the basic word w in the non-sensitive query sample set can be represented by f. non (w) indicates.

[0107] Optionally, the term frequency-inverse document frequency weight is calculated as follows: based on the number of samples in the non-sensitive query sample set and the frequency of occurrence of basic words in the non-sensitive query sample set, a first logarithmic function is determined; the product of the frequency of occurrence of basic words in the sensitive query sample set and the first logarithmic function is calculated, and the result of the product calculation is determined as the term frequency-inverse document frequency weight.

[0108] Optionally, the term frequency-inverse document frequency (TFIDF) weights of the basic vocabulary can be used to represent the weights of the basic vocabulary on high-frequency words in the sensitive set but rare words in the non-sensitive set. In this invention, the traditional TFIDF is optimized for the sensitive query sample set. Specifically, the TFIDF weights of the basic vocabulary w can be calculated using the following formula. sens (w):

[0109]

[0110] Optionally, the chi-square statistic for sensitive labels can be calculated by: calculating multiple statistical index values ​​based on the number of samples in the sensitive query sample set, the number of samples in the non-sensitive query sample set, the frequency of occurrence of basic words in the sensitive query sample set, and the frequency of occurrence of basic words in the non-sensitive query sample set; and then calculating the chi-square statistic for sensitive labels based on each statistical index value.

[0111] Optionally, the chi-square statistic of sensitive labels can be used to quantify the statistical significance of the association between words and sensitive labels. The chi-square statistic χ of sensitive labels for the basic word w can be calculated using the following formula. 2 (w):

[0112]

[0113] Where N is the total number of samples in the sample set, N = |S sens |+|S non |,f 11f represents the number of statements in the sensitive set that contain w. 11 =f sens (w), f 10 f represents the number of statements containing w in the non-sensitive set. 10 =f non (w), f 01 f represents the number of statements in the sensitive set that do not contain w. 01 =|S sens |-f 11 f 00 f represents the number of statements f in the non-sensitive set that do not contain w. 00 =|S non |-f 10 .

[0114] Optionally, information gain can be used to represent the amount by which the prediction uncertainty of sensitive or non-sensitive category labels is reduced after introducing basic vocabulary w as a feature. Information gain can be used to evaluate and measure the information contribution of basic vocabulary to classification.

[0115] Optionally, calculating the information gain of the basic vocabulary may include:

[0116] Based on the number of samples in the sensitive query statement sample set and the non-sensitive query statement sample set, calculate the ratio of sensitive class to non-sensitive class, and then calculate the entropy of the entire sample set based on the ratio of sensitive class to non-sensitive class.

[0117] The number of samples containing the target basic vocabulary and the number of samples not containing the target basic vocabulary in the statistical sample set are counted. Based on the statistical results of the number of samples, the number of samples in the sensitive query statement sample set and the non-sensitive query statement sample set, and the frequency of the target basic vocabulary in the sensitive query statement sample set and the non-sensitive query statement sample set, the first conditional entropy and the second conditional entropy are calculated respectively.

[0118] The information gain of the target basic vocabulary is calculated based on the entropy of the entire sample set, the first conditional entropy, and the second conditional entropy.

[0119] Optionally, the entropy of the entire sample set is calculated as follows: the entropy of the sensitive sample set is summed with the entropy of the non-sensitive sample set, and the summation result is negative; the entropy of the sensitive sample set is the product of the proportion of sensitive samples in the sample set and the calculated logarithm of sensitive samples; the entropy of the non-sensitive sample set is the product of the proportion of non-sensitive samples in the sample set and the calculated logarithm of non-sensitive samples.

[0120] Continuing the previous example, the entropy H(S) of the entire sample set can be calculated using the following formula:

[0121] H(S)=-∑ c∈{0,1} p(c)log2p(c);

[0122] Where S represents the entire sample set, S = S sens ∪S non , where |S| is the total number of samples in the sample set; p(c=1) represents the proportion of sensitive samples in the sample set. p(c=0) represents the proportion of non-sensitive samples in the sample set.

[0123] Optionally, the first conditional entropy is calculated as follows: the first conditional entropy of the sensitive sample set is summed with the first conditional entropy of the non-sensitive sample set, and the summation result is negative; the first conditional entropy of the sensitive sample set is the product of the proportion of sensitive samples in the sample set containing basic words and the result of the first logarithm of the sensitive samples; the first conditional entropy of the non-sensitive sample set is the product of the proportion of non-sensitive samples in the sample set containing basic words and the result of the first logarithm of the non-sensitive samples.

[0124] Continuing the previous example, the first conditional entropy H(S) w It can be calculated using the following formula:

[0125] H(S w )=-∑ c∈{0,1} p(c|w)log2p(c|w);

[0126] in, This can represent the proportion of sensitive samples in a sample containing the basic vocabulary w. It can represent the proportion of non-sensitive samples in a sample containing the basic vocabulary w, |S w | represents the total number of samples in the sample set that contain the basic vocabulary w. The first conditional entropy can also represent the subset S containing the basic vocabulary w. w The conditional entropy.

[0127] Optionally, the second conditional entropy is calculated as follows: the second conditional entropy of the sensitive sample set is summed with the second conditional entropy of the non-sensitive sample set, and the summation result is negative; the second conditional entropy of the sensitive sample set is the product of the proportion of sensitive samples in the sample set that do not contain basic words and the result of the calculation of the second logarithm of the sensitive samples; the second conditional entropy of the non-sensitive sample set is the product of the proportion of non-sensitive samples in the sample set that do not contain basic words and the result of the calculation of the second logarithm of the non-sensitive samples.

[0128] Continuing the previous example, the second conditional entropy H(S) egw It can be calculated using the following formula:

[0129] H(S egw )=-∑ c∈{0,1} p(c|egw)log2p(c|egw);

[0130] in, This can represent the proportion of sensitive samples in samples that do not contain the basic vocabulary "w". It can represent the proportion of non-sensitive samples in a sample that does not contain the basic vocabulary w, |S egw | represents the total number of samples in the sample set that do not contain the basic word w. The second conditional entropy can also represent the subset S that does not contain the basic word w. egw The conditional entropy.

[0131] Optionally, the information gain of the basic vocabulary can be calculated based on the entropy of the entire sample set, the first conditional entropy, the second conditional entropy, the total number of samples in the sample set, the total number of samples in the sample set containing the basic vocabulary, and the total number of samples in the sample set not containing the basic vocabulary.

[0132] Furthermore, the information gain IG(w) of the basic vocabulary w can be calculated using the following formula:

[0133]

[0134] Where H(S) is the entropy of the entire sample set, H(S w H(S) is the first conditional entropy. egw Let |S| be the second conditional entropy, and |S| be the total number of samples in the sample set. w |S represents the total number of samples in the sample set that contain the basic vocabulary w. egw | represents the total number of samples in the sample set that do not contain the basic word w.

[0135] S230. Based on the reference values ​​of each basic vocabulary, perform multi-level filtering on each basic vocabulary, and compile the basic vocabulary retained after multi-level filtering into a sensitive keyword database.

[0136] Based on the reference values ​​of each basic vocabulary word, multi-level filtering is performed on each basic vocabulary word, and the basic vocabulary words retained after multi-level filtering are compiled into a sensitive keyword library, including:

[0137] Based on the frequency statistics of each basic word, the frequency ratio of each basic word is calculated, and a first-level filter is performed based on the frequency ratio of each basic word to determine the first-level words.

[0138] Based on the chi-square statistics of the sensitive tags of each primary word, the probability that the current association strength of each primary word is caused by random factors is calculated, and secondary filtering is performed based on the probability calculation results to determine the secondary words.

[0139] Based on the information gain of each secondary vocabulary, a tertiary filtering process is performed to determine the tertiary vocabulary.

[0140] Based on the word frequency-inverse document frequency weight, sensitive tag chi-square statistic, and information gain of each level 3 vocabulary, a comprehensive score is calculated for each level 3 vocabulary. The comprehensive scores are then sorted in descending order. Level 4 vocabulary is determined based on the sorting results, and each level 4 vocabulary is used to form a sensitive keyword library.

[0141] Optionally, the frequency ratio of basic words is the ratio of the frequency of basic words appearing in the sensitive query statement sample set to the frequency of basic words appearing in the non-sensitive query statement sample set. However, a minimum value is added to the denominator during the ratio calculation to prevent the denominator from being 0.

[0142] Optionally, the frequency ratio ρ(w) of the basic vocabulary can be calculated using the following formula:

[0143] ρ(w)=f sens (w) / (f non (w)+∈);

[0144] Among them, f sens (w) indicates the frequency of the basic word w in the sensitive query sample set, f non (w) represents the frequency of the basic word w in the sample set of non-sensitive query statements. ∈ is used to prevent the denominator from being 0, and ∈ can be taken as 10. -5 .

[0145] Optionally, a frequency ratio threshold can be preset. If the frequency ratio of a basic word is greater than or equal to the frequency ratio threshold, then the basic word is treated as a first-level word and it is determined to pass the first-level filter.

[0146] Optionally, the probability that the current association strength of a first-level word is caused by random factors can be represented by a p-value. The p-value of a first-level word can be calculated according to the following formula:

[0147]

[0148] Where γ is the incomplete gamma function, Γ is the gamma function, v is the preset degree of freedom, and v = 1.

[0149] Optionally, the probability that the current association strength of a first-level word is caused by random factors can be calculated using the chi-square statistic of sensitive tags, incomplete gamma function, gamma function, and preset degrees of freedom.

[0150] Optionally, if the probability that the current association strength of a first-level word is caused by random factors is less than a preset probability threshold, then the basic word is treated as a second-level word and it is determined to pass the second-level filtering.

[0151] Optionally, determine whether the information gain of the second-level vocabulary satisfies the following conditions. If so, then the information provided by the secondary vocabulary has actual classification value, and the basic vocabulary is designated as a tertiary vocabulary, thus passing the tertiary filtering.

[0152] Optionally, the comprehensive score of the third-level vocabulary can be calculated based on the pre-set hyperparameters, the maximum value of the chi-square statistics of the sensitive tags in each third-level vocabulary, the maximum and minimum values ​​of the information gain in each third-level vocabulary, the chi-square statistics of the sensitive tags of the third-level vocabulary, the information gain of the third-level vocabulary, and the word frequency-inverse document frequency weight of the third-level vocabulary.

[0153] Optionally, the overall score (Score(w)) for Level 3 vocabulary can be calculated using the following formula:

[0154]

[0155] in, max(χ 2 () represents the maximum value of the chi-square statistic for sensitive labels in each level 3 vocabulary. max(IG) and min(IG) are the maximum and minimum information gain values ​​for each level 3 vocabulary, respectively, and α, β, and γ are pre-defined hyperparameters.

[0156] The advantages of this setup are: it can verify the sensitivity of words from multiple dimensions based on calculations of multiple parameters, avoiding problems such as misjudging high-frequency non-sensitive words or missing low-frequency but key sensitive words caused by a single indicator. Through multi-level filtering, the influence of multiple-dimensional indicators can be balanced, and the core words with the highest scores can be selected to ensure the core nature of the sensitive keyword library, guarantee that the sensitive keyword library contains the most representative sensitive words, and avoid redundancy.

[0157] S240. Identify multiple business terms in the query statement of the target database, and match each business term with the sensitive keyword database. Determine the basic confidence level of each business term based on the matching results.

[0158] S250. Perform syntactic analysis on the query statement of the target database, and determine the positional risk coefficient of each business term based on the syntactic context of each business term in the query statement of the target database.

[0159] S260. When the grammatical analysis results of business terms trigger the preset dynamic environment correction mechanism, determine the environment correction factor of the business terms.

[0160] S270. Calculate the sensitivity of each business term based on its basic confidence level, location risk coefficient, and environmental correction factor.

[0161] S280. When it is determined that there are business terms in the target database query statement with a sensitivity greater than the sensitivity threshold, it is determined that there are sensitive terms in the target database query statement.

[0162] S290. Extract structured quadruples from the target database query statement, check the traceability validity based on the structured quadruples, and when the traceability is determined to be valid, determine the source table name and source column name queried by the target database query statement based on the structured quadruples.

[0163] S2100: Through the first verification channel, call the application programming interface of the data query platform to identify the sensitive attributes of the source table name and the source column name.

[0164] S2110. If the sensitive attributes cannot be identified through the first verification channel, then through the second verification channel, the target database query statement, source table name, and source column name are input into the semantic analysis model, and the sensitive attributes of the source table name and source column name are determined based on the type determination result and confidence score output by the semantic analysis model.

[0165] S2120. Based on the identified sensitive attributes, determine the sensitivity detection results of the target database query statement.

[0166] The technical solution of this invention establishes a sensitive keyword library based on a sample set of sensitive and non-sensitive query statements. It then parses the target database query statements and calculates the sensitivity of each business term based on the sensitive keyword library and the parsing results. When sensitive terms are identified in the target database query statement based on their sensitivity, the source table name and source column name are determined. A dual-channel verification mechanism identifies the sensitive attributes of the source table name and source column name, and the sensitivity detection result of the target database query statement is determined based on these identified attributes. This approach makes the sensitive keyword library more aligned with the expression habits of sensitive information in actual business operations, ensuring that the selected sensitive keywords have clear sensitivity targeting, reducing interference from irrelevant words, and improving the efficiency of building the sensitive keyword library. Furthermore, based on the sensitive keyword library, it enables rapid detection of large batches of database query statements and can identify non-standard named sensitive fields, improving detection timeliness and accuracy.

[0167] Example 3

[0168] Figure 3 This is a schematic diagram of a database query statement detection device provided in Embodiment 3 of the present invention. Figure 3 As shown, the device includes: a sensitive keyword database establishment module 310, a vocabulary sensitivity detection module 320, a query information acquisition module 330, and a sensitive statement recognition module 340.

[0169] The sensitive keyword database creation module 310 is used to create a sensitive keyword database based on a sample set of sensitive query statements and a sample set of non-sensitive query statements.

[0170] The vocabulary sensitivity detection module 320 is used to parse the query statement of the target database and calculate the sensitivity of each business term based on the sensitive keyword library and the parsing results.

[0171] The query information acquisition module 330 is used to determine the source table name and source column name of the target database query statement when sensitive words are identified in the target database query statement based on the sensitivity of each business term.

[0172] The sensitive statement identification module 340 is used to identify the sensitive attributes of the source table name and source column name according to the dual-channel verification mechanism, and determine the sensitivity detection result of the target database query statement based on the identified sensitive attributes.

[0173] The technical solution of this invention establishes a sensitive keyword library based on a sample set of sensitive and non-sensitive query statements. It then parses the target database query statements and calculates the sensitivity of each business term based on the sensitive keyword library and the parsing results. When sensitive terms are identified in the target database query statement based on their sensitivity, the source table name and source column name are determined. A dual-channel verification mechanism identifies the sensitive attributes of the source table name and source column name, and the sensitivity detection result of the target database query statement is determined based on these identified attributes. This approach makes the sensitive keyword library more aligned with the expression habits of sensitive information in actual business operations, ensuring that the selected sensitive keywords have clear sensitivity targeting, reducing interference from irrelevant words, and improving the efficiency of building the sensitive keyword library. Furthermore, based on the sensitive keyword library, it enables rapid detection of large batches of database query statements and can identify non-standard named sensitive fields, improving detection timeliness and accuracy.

[0174] Based on the above embodiments, the sensitive keyword database establishment module 310 may include:

[0175] The basic vocabulary set acquisition unit is used to standardize and split historical database query statements from sensitive data sample sets and non-sensitive data sample sets to obtain a basic vocabulary set.

[0176] The basic vocabulary reference value calculation unit is used to calculate multiple reference values ​​for each basic vocabulary in the basic vocabulary set.

[0177] The basic vocabulary filtering unit is used to perform multi-level filtering on each basic vocabulary based on the reference value of each basic vocabulary, and to form a sensitive keyword library by retaining the basic vocabulary after multi-level filtering.

[0178] Based on the above embodiments, the basic vocabulary reference value calculation unit can be specifically used for:

[0179] Obtain the sample counts from the sensitive query statement sample set and the non-sensitive query statement sample set respectively, and count the frequency of each basic word in the sensitive query statement sample set and the non-sensitive query statement sample set.

[0180] Based on the sample size of each sample set and the frequency statistics of each basic word, the word frequency-inverse document frequency weight, sensitive tag chi-square statistic, and information gain of each basic word are calculated respectively.

[0181] Based on the above embodiments, the basic vocabulary filtering unit can be specifically used for:

[0182] Based on the frequency statistics of each basic word, the frequency ratio of each basic word is calculated, and a first-level filter is performed based on the frequency ratio of each basic word to determine the first-level words.

[0183] Based on the chi-square statistics of the sensitive tags of each primary word, the probability that the current association strength of each primary word is caused by random factors is calculated, and secondary filtering is performed based on the probability calculation results to determine the secondary words.

[0184] Based on the information gain of each secondary vocabulary, a tertiary filtering process is performed to determine the tertiary vocabulary.

[0185] Based on the word frequency-inverse document frequency weight, sensitive tag chi-square statistic, and information gain of each level 3 vocabulary, a comprehensive score is calculated for each level 3 vocabulary. The comprehensive scores are then sorted in descending order. Level 4 vocabulary is determined based on the sorting results, and each level 4 vocabulary is used to form a sensitive keyword library.

[0186] Based on the above embodiments, the vocabulary sensitivity detection module 320 can be specifically used for:

[0187] Multiple business terms are identified in the query statement of the target database, and each business term is matched with the sensitive keyword database. The basic confidence level of each business term is determined based on the matching results.

[0188] Perform syntactic analysis on the query statement of the target database, and determine the positional risk coefficient of each business term based on the syntactic context of each business term in the query statement of the target database.

[0189] When the grammatical analysis results of business terms trigger the preset dynamic environment correction mechanism, the environment correction factor of the business terms is determined.

[0190] The sensitivity of each business term is calculated based on its basic confidence level, location risk coefficient, and environmental correction factor.

[0191] Based on the above embodiments, the information retrieval module 330 can be specifically used for:

[0192] When it is determined that there are business terms in the target database query statement with a sensitivity greater than the sensitivity threshold, it is determined that there are sensitive terms in the target database query statement.

[0193] Extract structured quadruples from the query statement in the target database, check the validity of the source tracing based on the structured quadruples, and when the source tracing is determined to be valid, determine the source table name and source column name queried by the query statement in the target database based on the structured quadruples.

[0194] Based on the above embodiments, the sensitive statement identification module 340 can be specifically used for:

[0195] The first verification channel calls the application programming interface of the data query platform to identify the sensitive attributes of the source table name and the source column name;

[0196] If the sensitive attributes cannot be identified through the first verification channel, then the target database query statement, source table name, and source column name are input into the semantic analysis model through the second verification channel. Based on the type determination result and confidence score output by the semantic analysis model, the sensitive attributes of the source table name and source column name are determined.

[0197] The database query statement detection device provided in this embodiment of the invention can execute the database query statement detection method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0198] Example 4

[0199] Figure 4 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0200] like Figure 4As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0201] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0202] Processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, central processing unit (CPU), graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the database query statement detection method described in any embodiment of the present invention. That is:

[0203] A sensitive keyword database was established based on a sample set of sensitive query statements and a sample set of non-sensitive query statements.

[0204] The query statements in the target database are parsed, and the sensitivity of each business term is calculated based on the sensitive keyword database and the parsing results.

[0205] When sensitive words are identified in the target database query statement based on the sensitivity of each business term, the source table name and source column name queried by the target database query statement are determined.

[0206] Based on the dual-channel verification mechanism, the sensitive attributes of the source table name and source column name are identified, and the sensitivity detection results of the target database query statement are determined according to the identified sensitive attributes.

[0207] In some embodiments, the database query statement detection method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the database query statement detection method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to execute the database query statement detection method by any other suitable means (e.g., by means of firmware).

[0208] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0209] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0210] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0211] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0212] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0213] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0214] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0215] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for detecting database query statements, characterized in that, include: A sensitive keyword database is established based on the sample sets of sensitive and non-sensitive query statements. The query statements in the target database are parsed, and the sensitivity of each business term is calculated based on the sensitive keyword database and the parsing results. When sensitive words are identified in the target database query statement based on the sensitivity of each business term, the source table name and source column name queried by the target database query statement are determined. Based on the dual-channel verification mechanism, the sensitive attributes of the source table name and source column name are identified, and the sensitivity detection results of the target database query statement are determined according to the identified sensitive attributes.

2. The method according to claim 1, characterized in that, Based on the sample sets of sensitive and non-sensitive query statements, a sensitive keyword database is established, including: Standardize and split historical database query statements from both sensitive and non-sensitive data sample sets to obtain a basic vocabulary set. For each basic word in the basic vocabulary set, calculate multiple reference values; Based on the reference values ​​of each basic vocabulary word, the basic vocabulary words are filtered at multiple levels, and the basic vocabulary words retained after multiple levels of filtering are used to form a sensitive keyword library.

3. The method according to claim 2, characterized in that, For each basic word in the basic vocabulary set, calculate multiple reference values, including: Obtain the sample counts from the sensitive query statement sample set and the non-sensitive query statement sample set respectively, and count the frequency of each basic word in the sensitive query statement sample set and the non-sensitive query statement sample set. Based on the sample size of each sample set and the frequency statistics of each basic word, the word frequency-inverse document frequency weight, sensitive tag chi-square statistic, and information gain of each basic word are calculated respectively.

4. The method according to claim 3, characterized in that, Based on the reference values ​​of each basic vocabulary word, multi-level filtering is performed on each basic vocabulary word, and the basic vocabulary words retained after multi-level filtering are compiled into a sensitive keyword library, including: Based on the frequency statistics of each basic word, the frequency ratio of each basic word is calculated, and a first-level filter is performed based on the frequency ratio of each basic word to determine the first-level words. Based on the chi-square statistics of the sensitive tags of each primary word, the probability that the current association strength of each primary word is caused by random factors is calculated, and secondary filtering is performed based on the probability calculation results to determine the secondary words. Based on the information gain of each secondary vocabulary, a tertiary filtering process is performed to determine the tertiary vocabulary. Based on the word frequency-inverse document frequency weight, sensitive tag chi-square statistic, and information gain of each level 3 vocabulary, a comprehensive score is calculated for each level 3 vocabulary. The comprehensive scores are then sorted in descending order. Level 4 vocabulary is determined based on the sorting results, and each level 4 vocabulary is used to form a sensitive keyword library.

5. The method according to claim 1, characterized in that, The query statements in the target database are parsed, and based on the sensitive keyword database and the parsing results, the sensitivity of each business term is calculated, including: Multiple business terms are identified in the query statement of the target database, and each business term is matched with the sensitive keyword database. The basic confidence level of each business term is determined based on the matching results. Perform syntactic analysis on the query statement of the target database, and determine the positional risk coefficient of each business term based on the syntactic context of each business term in the query statement of the target database. When the grammatical analysis results of business terms trigger the preset dynamic environment correction mechanism, the environment correction factor of the business terms is determined. The sensitivity of each business term is calculated based on its basic confidence level, location risk coefficient, and environmental correction factor.

6. The method according to claim 1, characterized in that, When sensitive words are identified in the target database query statement based on the sensitivity of various business terms, the source table name and source column name queried by the target database query statement are determined, including: When it is determined that there are business terms in the target database query statement with a sensitivity greater than the sensitivity threshold, it is determined that there are sensitive terms in the target database query statement. Extract structured quadruples from the query statement in the target database, check the validity of the source tracing based on the structured quadruples, and when the source tracing is determined to be valid, determine the source table name and source column name queried by the query statement in the target database based on the structured quadruples.

7. The method according to claim 1, characterized in that, Based on the dual-channel verification mechanism, sensitive attributes of the source table name and source column name are identified, including: The first verification channel calls the application programming interface of the data query platform to identify the sensitive attributes of the source table name and the source column name; If the sensitive attributes cannot be identified through the first verification channel, then the target database query statement, source table name, and source column name are input into the semantic analysis model through the second verification channel. Based on the type determination result and confidence score output by the semantic analysis model, the sensitive attributes of the source table name and source column name are determined.

8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the database query statement detection method according to any one of claims 1-7.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, implement the method for detecting database query statements according to any one of claims 1-7.

10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the method for detecting database query statements according to any one of claims 1-7.