Method for enhancing database audit detection capability through unvarnished transmission application user ID
By implanting user ID information in the database JDBC driver and parsing the annotation information, the problem of existing technology being unable to associate SQL statements with operating users is solved, the database audit detection capability is enhanced, and the audit of users in the application system is realized.
Patent Information
- Application Number
- CN202410718849.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-08-30
AI Technical Summary
Existing database audit methods cannot audit the operating user information corresponding to SQL statements in the application system, resulting in the inability to effectively associate SQL statements with specific operating users, which limits the improvement of database audit detection capabilities.
By implanting the user ID information into the SQL statement in the database JDBC driver, the enhanced SQL statement is generated, and the annotation information is parsed during the database audit process to obtain the user ID information, thereby associating the original SQL statement with the operating user.
It realizes the audit of users who operate SQL statements in the application system, enhances the ability of database audit detection, and can effectively associate SQL statements with operating users.
Smart Images

Figure CN118568121A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of database audit methods, and in particular relates to a method for transparently transmitting an application user ID to enhance the database audit detection capability. Background Art
[0002] At present, the objects of database auditing are usually database-level operations rather than application-level operations. Therefore, the current database auditing method can audit the SQL statements of database operations, but cannot audit the operating user information corresponding to the SQL statements in the application system, and thus cannot effectively associate the SQL statements with specific operating users, limiting the improvement of database audit detection capabilities. Summary of the invention
[0003] In order to overcome the above defects of the existing database auditing methods, the present invention proposes a new method for transparently transmitting the application user ID to enhance the database auditing detection capability. The method of the present invention can audit the operation user information corresponding to the SQL statement in the application system, solve the problem that the SQL statement cannot be associated with the system user, and enhance the database auditing detection capability.
[0004] Specifically, the present invention provides a method for transparently transmitting application user IDs to enhance database audit detection capabilities, such as Figure 4 As shown, the method includes:
[0005] S1. Use the database JDBC driver to transform the original SQL statement, implant annotation information containing the user ID information of the current SQL statement, and generate an enhanced SQL statement;
[0006] S2. When the database audit agent monitors the enhanced SQL statement message information during the database audit process, it parses the original SQL statement based on the protocol parsing method and obtains the user ID information in the comment information;
[0007] S3. The database audit agent reports the original SQL statement and user ID information to the database audit system, and the database audit system obtains the association between the original SQL statement and the operation user ID information.
[0008] Furthermore, the method step S1 of transparently transmitting the application user ID to enhance the database audit detection capability of the present invention includes:
[0009] S11. Obtain database connection and intercept SQL statements;
[0010] S12. Call the method for obtaining user ID information in the business system in the JDBC driver to obtain the current user ID information;
[0011] S13. The annotation information containing the current user ID information is implanted into the original SQL statement through the JDBC driver to generate an enhanced SQL statement;
[0012] S14. Execute enhanced SQL statements through the JDBC driver.
[0013] Furthermore, the interception of SQL statements in step S11 of the method for transparently transmitting application user IDs to enhance database audit detection capabilities of the present invention is to intercept SQL statements by means of a proxy or an interceptor.
[0014] Furthermore, the method for obtaining user ID information in the business system described in step S12 of the method for transparently transmitting the application user ID to enhance the audit detection capability of the database of the present invention includes a session in the business system.
[0015] Furthermore, the method of transparently transmitting the application user ID to enhance the database audit detection capability described in step S13 of the present invention is to implant the comment information containing the current user ID information into the original SQL statement through the JDBC driver to generate an enhanced SQL statement, including: the JDBC driver assigns the acquired current user ID information to the _user_id field, and then splices the _user_id field into the original SQL statement in the form of SQL comments to generate an enhanced SQL statement.
[0016] Furthermore, the user ID information in the annotation information described in step S2 of the method for transparently transmitting the application user ID to enhance the audit detection capability of the database of the present invention is displayed in the form of a _user_id field value.
[0017] On the other hand, the present invention also provides a system for transparently transmitting application user IDs to enhance database audit detection capabilities. When the system is running, the steps of the method for transparently transmitting application user IDs to enhance database audit detection capabilities are implemented.
[0018] In addition, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the steps of the method for transparently transmitting application user IDs to enhance database audit detection capabilities are implemented.
[0019] In summary, the method of transparently transmitting application user ID to enhance database audit detection capability of the present invention overcomes the defect that the existing database audit method cannot effectively associate SQL statements with specific operating users, which limits the database audit detection capability. Through this method, the operating user information corresponding to the SQL statement in the application system can be audited, which solves the problem that SQL statements cannot be associated with system users and enhances the database audit detection capability. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the following drawings are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 The figure is a schematic diagram of the overall business logic of the method of the present invention.
[0022] Figure 2 The present invention provides a JDBC driver enhanced SQL logic schematic diagram in the method of the present invention.
[0023] Figure 3 The figure is a schematic diagram of JDBC driver integration logic in the method of the present invention.
[0024] Figure 4 The figure is a flow chart of the overall implementation of the method of the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. The present invention can also be implemented or applied through other different specific implementation methods. The details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention.
[0026] At the same time, it should be understood that the protection scope of the present invention is not limited to the specific embodiments described below; it should also be understood that the terms used in the embodiments of the present invention are for describing specific embodiments rather than for limiting the protection scope of the present invention.
[0027] Embodiment: A method for transparently transmitting application user ID to enhance database audit detection capability
[0028] The overall business logic of this method is as follows Figure 1 shown.
[0029] This method first transforms the database JDBC driver, that is, before executing the original SQL statement, the original SQL is extracted and the SQL statement is transformed, and comment information with user ID information is implanted therein (for example: / *_user_id:000000* / ). Moreover, based on the database characteristic that the comment information in the SQL statement will not be executed, although the JDBC driver executes the modified SQL statement (collectively referred to as enhanced SQL in this article), it will not affect the original SQL function. By implanting user ID comment information into the SQL statement to generate enhanced SQL, when the enhanced SQL message information is monitored during the database audit process, the user ID information contained in the comment information can also be obtained at the same time, so that the association relationship between the original SQL statement and the user ID in the comment information can be obtained, and finally the association relationship between the original SQL statement and the operating user (user ID) in the application system is realized. Database auditing by this method can detect which users at the application level operate the SQL statements at the database level, thereby enhancing the ability of database audit detection.
[0030] To achieve the above process, we first call the method of obtaining user ID information in the business system in the JDBC driver, and then embed the user ID information (as comment information) into the original SQL statement for SQL enhancement. Here, the JDBC driver enhances the SQL logic as follows: Figure 2 As shown, the following steps are included:
[0031] 1) Get a database connection.
[0032] 2) Intercept SQL statements through a proxy or interceptor.
[0033] 3) Get the incoming SQL statement and modify it:
[0034] a) Obtain current user information through the session in the business system;
[0035] b) Pass the current user information to the SQL statement modification method to modify the SQL statement;
[0036] c) Generate new enhanced SQL statements.
[0037] 4) Execute the modified enhanced SQL statement.
[0038] It should be noted that the principle of database auditing is to obtain network messages by monitoring the network card. Therefore, the user ID comment information contained in the enhanced SQL statement can also be monitored and the user ID information can be parsed out through it.
[0039] When the business system operates the database, it usually performs database operations based on the open source JDBC driver. As mentioned above, with the enhanced JDBC driver, the business system can replace the JDBC driver it references with the enhanced JDBC driver. Figure 3 As shown, the specific integration steps are as follows:
[0040] 1) The business system replaces the original database JDBC driver with the enhanced JDBC driver described above.
[0041] 2) The enhanced JDBC driver obtains user information according to the method of obtaining user information in the business system, assigns the user ID to the _user_id field, and then splices _user_id into the SQL statement in the form of SQL comments.
[0042] SQL enhancement effect example:
[0043] a) Select statement enhancement
[0044] Original SQL: SELECT name from users where id=1
[0045] Enhanced SQL: SELECT name from users where id=1 / *_user_id:000000* /
[0046] b) Enhanced insert statement
[0047] Original SQL: INSERT INTO users(username,email,userId)VALUES(?,?,?)
[0048] Enhanced SQL: INSERT INTO users(username,email,userId)VALUES(?,?,?) / *_user_id:000000* /
[0049] c) Enhanced delete statement
[0050] Original SQL: DELETE FROM users WHERE id=1
[0051] Enhanced SQL: DELETE FROM users WHERE id=1 / *_user_id:000000* /
[0052] 3) Enhance the JDBC driver to connect to the database and use enhanced SQL statements to perform database operations.
[0053] 4) After the database audit agent audits the enhanced SQL statement, it parses the original SQL statement based on the protocol parsing method and obtains the _user_id field value, that is, the user ID information of the user operating the current SQL statement.
[0054] 5) The database audit agent reports the original SQL statement and user ID information to the database audit system, thereby obtaining the association between the current SQL statement and the operating user ID information.
[0055] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any technician familiar with the profession can make some changes or modifications to the technical contents disclosed above without departing from the scope of the technical solution of the present invention to obtain equivalent embodiments of equivalent changes. However, any simple modification, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention should be included in the scope of protection of the claims of the present invention.
Claims
1. A method for transparently transmitting application user ID to enhance database audit detection capabilities. It is characterized in that The method comprises: S1. Use the database JDBC driver to transform the original SQL statement, implant annotation information containing the user ID information of the current SQL statement, and generate an enhanced SQL statement; S2. When the database audit agent monitors the enhanced SQL statement message information during the database audit process, it parses the original SQL statement based on the protocol parsing method and obtains the user ID information in the comment information; S3. The database audit agent reports the original SQL statement and user ID information to the database audit system, and the database audit system obtains the association between the original SQL statement and the operation user ID information.
2. According to the method of claim 1, the method of transparently transmitting the application user ID to enhance the database audit detection capability, It is characterized in that Step S1 includes: S11. Obtain database connection and intercept SQL statements; S12. Call the method for obtaining user ID information in the business system in the JDBC driver to obtain the current user ID information; S13. The annotation information containing the current user ID information is implanted into the original SQL statement through the JDBC driver to generate an enhanced SQL statement; S14. Execute enhanced SQL statements through the JDBC driver.
3. According to the method of claim 2, the method of transparently transmitting the application user ID to enhance the database audit detection capability, It is characterized in that The interception of SQL statements in step S11 is to intercept SQL statements by means of a proxy or an interceptor.
4. The method for transparently transmitting application user ID to enhance database audit detection capability according to claim 2, It is characterized in that The method for obtaining user ID information in the business system described in step S12 includes a session in the business system.
5. The method for transparently transmitting application user ID to enhance database audit detection capability according to claim 2, It is characterized in that The step S13 described in which the comment information containing the current user ID information is implanted into the original SQL statement through the JDBC driver to generate an enhanced SQL statement includes: the JDBC driver assigns the acquired current user ID information to the _user_id field, and then splices the _user_id field into the original SQL statement in the form of SQL comments to generate an enhanced SQL statement.
6. The method for transparently transmitting application user ID to enhance database audit detection capability according to claim 5, It is characterized in that The user ID information in the annotation information described in step S2 is displayed in the form of a _user_id field value.
7. A system that transparently transmits application user IDs to enhance database audit detection capabilities. It is characterized in that When the system is running, the steps of the method for transparently transmitting the application user ID to enhance the database audit detection capability as described in any one of claims 1 to 6 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the steps of the method for transparently transmitting an application user ID to enhance the audit detection capability of a database as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Tracking method, device and system for database DDL change operation and medium
CN110209684A
Method for realizing association of application access and database access behaviors based on PHP extended PDO
CN113157721A
Service association method and device, auditing method and database auditing system
CN114048191A
Method and system for obtaining user information accessing SQL database and storage medium
CN114547697A
