SQL statement audit method, device, equipment and medium based on database
By installing the audit plug-in in the integrated development environment tool and configuring the third-party audit tool, the automated audit of SQL statements is realized, which solves the problem of low audit efficiency and improves the work efficiency of developers.
Patent Information
- Application Number
- CN202311768250.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-21
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2043-12-21
AI Technical Summary
In the existing technology, the audit efficiency of SQL statements is low, requiring developers to manually export from integrated development environment tools and import into third-party audit tools, resulting in an incoherent and time-consuming audit process, affecting the work efficiency of developers.
Install the audit plug-in in the integrated development environment tool, and configure the third-party audit tool. The audit plug-in parses and sends SQL statements to the third-party tool for audit, and displays the results in the integrated development environment tool to realize the closed-loop function of analysis-audit-display. Automate the review process without developers leaving their current tools.
It improves the efficiency of SQL statement review, shortens the review time, improves the work efficiency of developers, and realizes the automated review of SQL statements.
Smart Images

Figure CN117435515B
Abstract
Description
Technical Field
[0001] The present application relates to the field of database technology, and in particular to a method, device, equipment and medium for auditing SQL statements based on a database. Background Art
[0002] Relational databases, such as Oracle and MySQL, firmly occupy the mainstream position in the database market and are usually used in the core business of major companies. The only interface for manipulating relational databases is SQL (Structured Query Language). As an important part of the database management system, the performance and quality of SQL directly affect the overall performance of the database. Incorrect SQL statements may cause data corruption, database performance degradation, security vulnerabilities and other problems.
[0003] In the related art, developers manually check SQL statements to find potential syntax errors, or audit SQL statements through third-party audit tools. However, manual audits are prone to errors and have low audit efficiency. When auditing through third-party audit tools, developers need to log in to the third-party audit tools to operate, and developers need to manually export SQL statements from the integrated development environment tool and then import them into the third-party audit tool. When viewing the audit results, they also need to view them in the third-party audit tool, resulting in an incoherent audit process, a long audit time, and low audit efficiency. Therefore, how to improve the audit efficiency of SQL statements has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a database-based SQL statement auditing method, device, equipment and medium, aiming to improve the auditing efficiency of SQL statements.
[0005] To achieve the above purpose, a first aspect of an embodiment of the present application proposes a database-based SQL statement audit method, the method comprising:
[0006] The audit plug-in receives an audit instruction for at least one target file; wherein the audit plug-in is a plug-in pre-installed in an integrated development environment tool;
[0007] The audit plug-in parses each of the target files according to the audit instruction to obtain the SQL statement of each of the target files;
[0008] The third-party audit tool audits the SQL statements of the target file to obtain a first audit result of each target file; wherein the third-party audit tool is configured in the integrated development environment tool according to a preset configuration file;
[0009] The audit plug-in displays the first audit result on the integrated development environment tool; wherein the first audit result includes the risk type of the SQL statement, the risky file identification information and the SQL statement identification information.
[0010] In some embodiments, the audit plug-in displays the first audit result on the integrated development environment tool, including:
[0011] The audit plug-in obtains the risk type of the SQL statement in the first audit result;
[0012] Classify the SQL statements according to the risk type to obtain risk levels; wherein the risk levels include: severe level, warning level and prompt level;
[0013] The risk type, the file identification information and the SQL statement identification information are rendered in layers on the integrated development environment tool according to the risk level.
[0014] In some embodiments, after rendering the risk type, the file identification information, and the statement identification information in layers on the integrated development environment tool according to the risk level, the method further includes:
[0015] In response to a click on the selected file identification information, jumping to the target file corresponding to the file identification information;
[0016] In response to a click on the selected SQL statement identification information, the program jumps to the target file corresponding to the SQL statement identification information, and the cursor is positioned on the SQL statement corresponding to the SQL statement identification information.
[0017] In some embodiments, the interface of the integrated development environment tool is provided with a first window and a second window, and the method further comprises:
[0018] Rendering the risk type, the file identification information, and the SQL statement identification information in layers on the first window according to the risk level;
[0019] In response to a click on the file identification information or the SQL statement identification information selected in the first window, a target file corresponding to the file identification information or the SQL statement identification information is displayed in the second window.
[0020] In some embodiments, the method further comprises:
[0021] Acquire a first window adjustment instruction of the first window or a second window adjustment instruction of the second window;
[0022] The first window and the second window are adjusted according to the first window adjustment instruction, or the first window and the second window are adjusted according to the second window adjustment instruction.
[0023] In some embodiments, the third-party audit tool is configured in the integrated development environment tool according to a preset configuration file, including:
[0024] Receive a configuration request for a third-party audit tool;
[0025] In response to the third-party audit tool configuration request, displaying a configuration interface in the integrated development environment tool;
[0026] Obtain the configuration fields filled in the box in the configuration interface to obtain a configuration file; wherein the configuration file includes: a third-party audit tool service address, an audit database IP, an audit database type, an audit database interface, and an audit template;
[0027] The third-party audit tool is configured into the integrated development environment tool according to the configuration file.
[0028] In some embodiments, after the audit plug-in displays the first audit result on the integrated development environment tool, the method further includes:
[0029] The audit plug-in receives the audit instruction of the newly added file, and parses the newly added file according to the audit instruction to obtain the SQL statement of the newly added file;
[0030] The third-party audit tool audits the SQL statement of the newly added file to obtain a second audit result of the newly added file;
[0031] The audit plug-in updates the first audit result according to the second audit result.
[0032] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application proposes a SQL statement auditing device based on a database, the device comprising:
[0033] A receiving module, configured to receive an audit instruction for at least one target file through an audit plug-in; wherein the audit plug-in is a plug-in pre-installed in an integrated development environment tool;
[0034] A parsing module, used to parse each of the target files according to the audit instruction through the audit plug-in to obtain the SQL statement of each of the target files;
[0035] An audit module, used to audit the SQL statements of the target files through a third-party audit tool to obtain a first audit result of each target file; wherein the third-party audit tool is configured in the integrated development environment tool according to a preset configuration file;
[0036] A display module is used to display the first audit result on the integrated development environment tool through the audit plug-in, wherein the first audit result includes the risk type of the SQL statement, the file identification information with risk and the SQL statement identification information.
[0037] To achieve the above objectives, a third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.
[0038] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.
[0039] The database-based SQL statement audit method, device, equipment and medium proposed in the present application are implemented by installing an audit plug-in in an integrated development environment tool and configuring a third-party audit tool. When the audit plug-in receives an audit instruction for at least one target file, it parses each target file to obtain the SQL statement of each target file, sends the SQL statement of each target file to the third-party audit tool, and the third-party audit tool audits the SQL statement of the target file to obtain the first audit result of each target file, sends the first audit result of each target file to the audit plug-in, and the audit plug-in displays the first audit result on the integrated development environment tool. The closed-loop function of parsing-auditing-displaying and the automation of SQL statement auditing in the integrated development environment tool are realized, and during the whole process, developers do not need to leave the current integrated development environment tool, which improves the work efficiency of developers, shortens the audit time, and thus improves the audit efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is an optional flowchart of the database-based SQL statement audit method provided in the embodiment of the present application;
[0041] Figure 2 yes Figure 1 Flow chart of step S104 in FIG.
[0042] Figure 3 It is a schematic diagram showing the audit results in the integrated development environment tool;
[0043] Figure 4 It is a flowchart of a database-based SQL statement audit method provided by the second embodiment of the present application;
[0044] Figure 5 It is a schematic diagram of the interface of the integrated development environment tool;
[0045] Figure 6 It is a flowchart of a database-based SQL statement audit method provided by the third embodiment of the present application;
[0046] Figure 7 It is a flowchart of a database-based SQL statement audit method provided by the fourth embodiment of the present application;
[0047] Figure 8 yes Figure 1 Flow chart of step S103 in FIG.
[0048] Fig. 9 It is a schematic diagram of the configuration interface in the integrated development environment tool;
[0049] Fig.10 It is a flowchart of a database-based SQL statement audit method provided by the fifth embodiment of the present application;
[0050] Fig.11 It is a structural diagram of a database-based SQL statement auditing device provided in an embodiment of the present application;
[0051] Fig.12 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0053] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0055] First, some nouns involved in this application are analyzed:
[0056] Third-party auditing tools: Third-party SQL statement auditing tools can help developers and database administrators manage SQL statements safely and efficiently, check whether SQL statements comply with database best practices and security standards, and provide some customized SQL rules and retrieval commands to enhance database performance and security.
[0057] Integrated Development Environment Tool: It integrates SQL statement editing and debugging functions, which can help developers quickly write and optimize SQL statements. Developers can use it to enhance the development efficiency of Java applications.
[0058] HTTP SSE (Server-Sent Events): is a server push technology based on the HTTP protocol, used to achieve real-time, two-way communication between the client and the server. Compared with the traditional polling method, SSE uses a persistent connection method, which can achieve real-time push of server-side events and client-side monitoring and processing of events.
[0059] IntelliJ Platform Plugin SDK: A plugin development framework based on the IntelliJ IDEA platform that provides a series of APIs and tools to help developers develop, debug, and publish their own plugin applications.
[0060] Java Swing: A graphical user interface (GUI) toolkit in the Java language that provides a rich component library that can help developers easily create cross-platform graphical interface applications.
[0061] MyBatis: A Java persistence framework that is often used to combine Java applications with relational databases. The MyBatis XML file is one of the configuration files of the MyBatis framework, which is used to specify SQL statements and mapping rules for interacting with the database.
[0062] In the related art, the main method of SQL statement auditing is manual auditing, where developers manually check SQL statements to find potential syntax errors, performance issues, and security issues. However, manual auditing is prone to miss errors, especially for complex SQL statements, which can easily ignore potential performance issues and security risks, and the audit efficiency is low. Auditing with third-party audit tools requires logging into the third-party audit tool to operate, and requires developers to manually export SQL statements from the integrated development environment tool and then import them into the third-party audit tool. When viewing the audit results, they also need to view them in the third-party audit tool, resulting in an incoherent audit process, a long audit time, low audit efficiency, and the need for developers to leave the integrated development environment tool, affecting the work efficiency of developers.
[0063] Based on this, the embodiment of the present application provides a method, device, equipment and medium for auditing SQL statements based on a database. By installing an audit plug-in in an integrated development environment tool and configuring a third-party audit tool, the audit plug-in parses the SQL statements of the target file in the integrated development environment tool, sends it to the third-party audit tool for audit, and sends the audit results back to the audit plug-in, which displays the audit results in the integrated development environment tool. The closed-loop function of parsing-auditing-displaying and the automation of SQL statement auditing in the integrated development environment tool are realized, and during the whole process, developers do not need to leave the current integrated development environment tool, which improves the work efficiency of developers, shortens the audit time, and thus improves the audit efficiency.
[0064] The database-based SQL statement auditing method, device, equipment and medium provided in the embodiments of the present application are specifically illustrated through the following embodiments. First, the database-based SQL statement auditing method in the embodiments of the present application is described.
[0065] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0066] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0067] The database-based SQL statement audit method provided in the embodiment of the present application can be applied to the terminal, can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements a database-based SQL statement audit method, etc., but is not limited to the above forms.
[0068] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0069] Please refer to Figure 1 , Figure 1 It is an optional flow chart of the database-based SQL statement auditing method provided in the embodiment of the present application. The database-based SQL statement auditing method is applied to an integrated development environment tool. Figure 1 The method may include but is not limited to steps S101 to S404.
[0070] Step S101, the audit plug-in receives an audit instruction for at least one target file; wherein the audit plug-in is a plug-in pre-installed in an integrated development environment tool;
[0071] Step S102, the audit plug-in parses each target file according to the audit instruction to obtain the SQL statement of each target file;
[0072] Step S103, the third-party audit tool audits the SQL statements of the target file to obtain a first audit result of each target file; wherein the third-party audit tool is configured in the integrated development environment tool according to a preset configuration file;
[0073] Step S104, the audit plug-in displays the first audit result on the integrated development environment tool; wherein the first audit result includes the risk type of the SQL statement, the risky file identification information and the SQL statement identification information.
[0074] In step S101 of some embodiments, the integrated development environment tool may be IntelliJ IDEA, which is a powerful Java integrated development environment (IDE) tool. The plug-in mechanism of IntelliJ IDEA can install various plug-ins to enhance its functions, allowing developers to expand the capabilities of IDEA according to their own needs. After building the audit plug-in using IntelliJPlatform Plugin SDK and Java Swing, the audit plug-in is installed in IntelliJ IDEA, and the target file may be a MyBatis XML file. The audit plug-in uses the MyBatis kernel to complete the scanning and parsing functions of the MyBatis XML file, and uses the IntelliJ Platform Plugin SDK to complete the rendering of the audit results.
[0075] Specifically, open at least one project with a MyBatis XML file in IntelliJ IDEA, click the MyBatis XML file that needs to be audited, and open it in the editing interface. Right-click the editing interface to pop up a drop-down list, and click the "Audit" button in the drop-down list. The audit plug-in will receive the audit instructions for the MyBatis XML file. At this time, open other MyBatis XML files in the editing interface, and click the "Audit" button. The audit plug-in will receive the audit instructions for other MyBatis XML files. You can also select multiple MyBatis XML files at the same time, right-click to pop up a drop-down list, and click the "Audit" button in the drop-down list. The audit plug-in can receive the audit instructions for multiple MyBatis XML files at the same time.
[0076] In step S102 of some embodiments, when the audit plug-in receives the audit instruction of the first MyBatis XML file, it starts to parse the first MyBatis XML file. During the parsing process, the audit plug-in can also continue to receive the audit instruction of the second MyBatis XML file, and after parsing the first MyBatis XML file, continue to parse the second MyBatis XML file. When the audit plug-in receives the audit instructions of multiple MyBatis XML files at the same time, each MyBatis XML file can be parsed successively.
[0077] In step S103 of some embodiments, the third-party audit tool may be SQM. SQM (SQL StatementQuality Monitor) is a third-party SQL statement audit tool. After configuring the third-party audit tool in the integrated development environment tool according to the configuration file, the audit plug-in can interact with the third-party audit tool in real time through HTTP SSE.
[0078] It should be noted that when the audit plug-in receives audit instructions from multiple MyBatis XML files at the same time, each time a SQL statement in a MyBatis XML file is parsed, the SQL statement in the MyBatis XML file is sent to the third-party audit tool for audit, and the audit progress is displayed. After the third-party audit tool has audited the SQL statement in a MyBatis XML file, the audit result will be sent to the audit plug-in via HTTP SSE, so that the audit plug-in can display the audit result in time. After the third-party audit tool has audited the SQL statement in the next MyBatis XML file, the next audit result will be sent to the audit plug-in. The audit plug-in updates the displayed audit result according to the next audit result, so that developers do not need to wait for all MyBatis XML files to be audited before viewing the audit results. Real-time audit and asynchronous result feedback will not block the normal use of IDEA, and enable developers to immediately understand problems with SQL statements and take measures to deal with them.
[0079] In step S104 of some embodiments, the audit results include the risk type of the SQL statement, the file identification information of the risk, and the SQL statement identification information. The risk type is the type of rule violated by the SQL statement. Developers can quickly understand which SQL statement in which MyBatis XML file violates which rules based on the displayed audit results, so that they can quickly handle it.
[0080] In the steps S101 to S104 shown in the embodiment of the present application, an audit plug-in is installed in the integrated development environment tool, and a third-party audit tool is configured. When the audit plug-in receives an audit instruction for at least one target file, each target file is parsed to obtain the SQL statement of each target file, and the SQL statement of each target file is sent to the third-party audit tool. The third-party audit tool audits the SQL statement of the target file to obtain the first audit result of each target file, and the first audit result of each target file is sent to the audit plug-in. The audit plug-in displays the first audit result on the integrated development environment tool. The closed-loop function of parsing-auditing-displaying and the automation of SQL statement auditing in the integrated development environment tool are realized, and during the whole process, developers do not need to leave the current integrated development environment tool, which improves the work efficiency of developers, shortens the audit time, and thus improves the audit efficiency.
[0081] See also Figure 2 In some embodiments, step S104 may include but is not limited to steps S201 to S203:
[0082] Step S201, the audit plug-in obtains the risk type of the SQL statement in the first audit result;
[0083] Step S202, classifying the SQL statements according to the risk type to obtain the risk level; wherein the risk level includes: severe level, warning level and prompt level;
[0084] Step S203: render the risk type, file identification information and SQL statement identification information in layers on the integrated development environment tool according to the risk level.
[0085] In some embodiments, in steps S201 to S202, the risk type is the type of rule violated by the SQL statement, and the correspondence between the risk type and the risk level can be predefined, so that the corresponding risk level can be obtained according to the risk type. For example, the risk types corresponding to the severe level include "no related objects during the joint database audit (addition, deletion, and modification)" and "no related objects during the joint database audit (check)", etc., the risk types corresponding to the warning level include "when connecting multiple tables, the alias of the table must be used" and "the primary key column or index column must be used in the where condition", etc., and the risk types corresponding to the prompt level include "the object lacks an owner" and "MySQL-SQL scans too many rows", etc.
[0086] In step S203 of some embodiments, the risk level is the first layer, the risk type is the second layer, the file identification information is the third layer, and the SQL statement identification information is the fourth layer. The first layer contains all risk types belonging to the corresponding risk level, the second layer contains file identification information belonging to the corresponding risk type, and the third layer contains SQL statement identification information belonging to the corresponding file identification information.
[0087] For example, Figure 3 As shown in the figure, "critical" indicates the severity level, "warning" indicates the warning level, and "info" indicates the prompt level. They are all the first level. When the arrow of the first level points downward, the corresponding second level information can be fully displayed. When the arrow of the first level points to the right, all the information of the lower levels can be hidden. By clicking the corresponding level, the direction of the arrow of the level can be switched. Taking the prompt level as an example, the arrow corresponding to the "info" level points downward, and all the second level information is displayed, which are "The object lacks an owner" and "MySQL-SQL scans too many rows". The arrow corresponding to the "The object lacks an owner" level points to the right, so the third level information is not displayed. The arrow corresponding to the "MySQL-SQL scans too many rows" layer points downward, displaying the corresponding third layer information, which indicates that the MyBatis XML file corresponding to the file identification information "PubCommonParas.xml" has an SQL statement that violates the "MySQL-SQL scans too many rows" rule. The arrow corresponding to the "PubCommonParas.xml" layer points downward, displaying the corresponding fourth layer information, which indicates that in the MyBatis XML file corresponding to the file identification information "PubCommonParas.xml", the SQL statement corresponding to the SQL statement identification information "getParamByType" violates the "MySQL-SQL scans too many rows" rule.
[0088] In steps S201 to S203 shown in this embodiment, by rendering the audit results in layers, developers can immediately understand the risk level and risk type corresponding to each SQL statement that violates the audit, locate the MyBatis XML file where the SQL statement is located, and the specific SQL statement, and take measures to process it, thereby improving the work efficiency of developers.
[0089] See also Figure 4 In some embodiments, after step S203, the database-based SQL statement audit method may also include but is not limited to steps S401 to S402:
[0090] Step S401, in response to a click on the selected file identification information, jump to the target file corresponding to the file identification information;
[0091] Step S402, in response to a click on the selected SQL statement identification information, jump to the target file corresponding to the SQL statement identification information, and position the cursor on the SQL statement corresponding to the SQL statement identification information.
[0092] Step S401 and step S402 shown in the embodiment of the present application are shown in FIG. Figure 5 , the interface of IntelliJ IDEA includes at least three display areas, the first display area is used to display the audit results, the second display area is used to display the content corresponding to the MyBatis XML file being edited, and the third display area is used to display the file identification information corresponding to the MyBatis XML file added to the project. When the file identification information in the third display area is clicked, the second display area will display the MyBatis XML file content corresponding to the file identification information. When the user clicks the file identification information in the audit results, IntelliJ IDEA responds to the click on the selected file identification information, jumps to the MyBatis XML file corresponding to the file identification information, and displays the corresponding MyBatis XML file content in the second display area. When the user clicks the SQL statement identification information in the audit results, IntelliJ IDEA responds to the click on the selected SQL statement identification information, jumps to the MyBatis XML file corresponding to the SQL statement identification information, displays the corresponding MyBatis XML file content in the second display area, and the cursor is positioned on the SQL statement corresponding to the SQL statement identification information in the second display area. Through this embodiment, developers can quickly locate MyBatis XML files and specific SQL statements that violate the rules, thereby improving the work efficiency of developers.
[0093] See also Figure 6 In some embodiments, a first window and a second window are provided on the interface of the integrated development environment tool, and the database-based SQL statement audit method may also include but is not limited to steps S601 to S602:
[0094] Step S601, rendering the risk type, file identification information and SQL statement identification information in layers on the first window according to the risk level;
[0095] Step S602: in response to a click on the file identification information or the SQL statement identification information selected in the first window, displaying a target file corresponding to the file identification information or the SQL statement identification information in the second window.
[0096] Steps S601 to S602 shown in the embodiment of the present application display the audit results and the content in the MyBatis XML file in different windows, so that developers can view the audit results and the content in the MyBatis XML file at the same time without switching different pages, and it is convenient for developers to edit and modify the content in the MyBatis XML file according to the audit results, thereby improving the work efficiency of developers.
[0097] See also Figure 7 In some embodiments, the database-based SQL statement audit method further includes but is not limited to steps S701 to S702:
[0098] Step S701, obtaining a first window adjustment instruction of a first window or a second window adjustment instruction of a second window;
[0099] Step S702: adjusting the first window and the second window according to the first window adjustment instruction, or adjusting the first window and the second window according to the second window adjustment instruction.
[0100] In the steps S701 to S702 shown in the embodiment of the present application, the window size in the integrated development environment tool can be adjusted. Since the size of the entire interface of the integrated development environment tool is fixed, when the interface of the integrated development environment tool is provided with a first window and a second window, if the size of one of the windows is adjusted, the sizes of the two windows will change accordingly. When the interface of the integrated development environment tool is provided with a first window, a second window and a third window, if the size of one of the windows is adjusted, the sizes of the three windows will change accordingly. It is also possible to set multiple fixed windows based on the three windows for switching different interfaces of the integrated development environment tool. The fixed windows are not adjusted with the size adjustment of other windows, and different settings can be made for different requirements of window size, shape and color.
[0101] See also Figure 8 In some embodiments, step S103 may include but is not limited to steps S801 to S804:
[0102] Step S801, receiving a third-party audit tool configuration request;
[0103] Step S802, in response to the third-party audit tool configuration request, displaying a configuration interface in the integrated development environment tool;
[0104] Step S803, obtaining the configuration fields filled in the box in the configuration interface to obtain a configuration file; wherein the configuration file includes: a third-party audit tool service address, an audit database IP, an audit database type, an audit database interface, and an audit template;
[0105] Step S804: configure the third-party audit tool into the integrated development environment tool according to the configuration file.
[0106] In steps S801 to S804 shown in the embodiment of the present application, after receiving the configuration request of the third-party audit tool, in response to the configuration request of the third-party audit tool, a configuration interface is displayed in the integrated development environment tool, and the user fills in the corresponding configuration fields in the fill-in box of the configuration interface. The integrated development environment tool obtains the configuration fields in the fill-in box in the configuration interface, obtains the configuration file, and configures the third-party audit tool to the integrated development environment tool according to the configuration file. The configuration file includes: the service address of the third-party audit tool, the IP address of the audit database, the type of the audit database, the interface of the audit database, and the audit template. Through this embodiment, after the third-party audit tool is configured to the integrated development environment tool, the audit plug-in installed in the integrated development environment tool interacts with the third-party audit tool, so that developers can implement the audit of SQL statements and view the audit results without leaving the current integrated development environment tool.
[0107] See also Fig. 9 , Fig. 9 It is the configuration interface displayed by the integrated development environment tool. The SQM service address is the address link used for local login to the SQM environment. The currently selected audit database type is MySQL, Port is the audit database port, IP is the audit database IP, the connection user is the audit database user name, the password is the audit database user password, the database name is the audit database library sid or schema, the SQM audit template is the existing audit template in SQM, the audit template includes specific audit rules, and the user information is the user's "work number" or "email" to facilitate the statistics of audit plug-in usage. By modifying the service address, different third-party audit tools can be configured into the integrated development environment tool. By modifying the audit database type and related audit database information, you can switch between multiple audit databases. By modifying the audit template, you can also switch between different audit templates to support multiple audit databases.
[0108] See also Fig.10 In some embodiments, after step S104, the database-based SQL statement audit method may also include but is not limited to steps S1001 to S1003:
[0109] Step S1001, the audit plug-in receives the audit instruction of the newly added file, and parses the newly added file according to the audit instruction to obtain the SQL statement of the newly added file;
[0110] Step S1002: A third-party audit tool audits the SQL statement of the newly added file to obtain a second audit result of the newly added file;
[0111] Step S1003: the audit plug-in updates the first audit result according to the second audit result.
[0112] In the steps S1001 to S1003 shown in the embodiment of the present application, the newly added MyBatis XML file is opened in IntelliJ IDEA. After the audit plug-in receives the audit instruction of the newly added MyBatis XML file, it parses it to obtain the SQL statement of the newly added MyBatis XML file, sends the SQL statement of the newly added MyBatis XML file to the third-party audit tool for audit, and receives the second audit result returned by the third-party audit tool, updates the first audit result according to the second audit result, and displays it on IntelliJ IDEA. For example, the second audit result is the first layer: severe level, the second layer: no related objects when auditing the linked library (addition, deletion, and modification), the third layer: PubCommonParas.xml, the fourth layer: getParamByType, and the first audit result is the first layer: severe level, the second layer: no related objects when auditing the linked library (checking), the third layer: MenuMapper.xml, the fourth layer: update. When the first audit result is updated according to the second audit result, the displayed content is the first layer: severity level, the second layer: no related objects when auditing the linked libraries (additions, deletions and modifications) and no related objects when auditing the linked libraries (checking); the third layer of no related objects when auditing the linked libraries (additions, deletions and modifications): PubCommonParas.xml, the third layer of no related objects when auditing the linked libraries (checking): MenuMapper.xml, the fourth layer of PubCommonParas.xml: getParamByType, the fourth layer of MenuMapper.xml: update. Through this embodiment, when auditing multiple MyBatis XML files one after another, the audit results of multiple MyBatis XML files can be merged together, which is convenient for developers to view and improves the work efficiency of developers.
[0113] See also Fig.11 The embodiment of the present application also provides a database-based SQL statement auditing device, which can implement the above-mentioned database-based SQL statement auditing method, and the device includes:
[0114] The receiving module 1101 is used to receive an audit instruction for at least one target file through an audit plug-in; wherein the audit plug-in is a plug-in installed in advance in an integrated development environment tool;
[0115] The parsing module 1102 is used to parse each target file according to the audit instruction through the audit plug-in to obtain the SQL statement of each target file;
[0116] The audit module 1103 is used to audit the SQL statements of the target file through a third-party audit tool to obtain a first audit result of each target file; wherein the third-party audit tool is configured in the integrated development environment tool according to a preset configuration file;
[0117] The display module 1104 is used to display the first audit result on the integrated development environment tool through the audit plug-in, wherein the first audit result includes the risk type of the SQL statement, the risky file identification information and the SQL statement identification information.
[0118] The specific implementation of the database-based SQL statement auditing device is basically the same as the specific implementation of the above-mentioned database-based SQL statement auditing method, which will not be repeated here.
[0119] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned database-based SQL statement audit method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0120] See also Fig.12 , Fig.12 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0121] The processor 301 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0122] The memory 302 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 302 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 302, and the processor 301 calls and executes the database-based SQL statement audit method of the embodiment of this application;
[0123] Input / output interface 303, used to implement information input and output;
[0124] Communication interface 304, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0125] A bus 305 that transmits information between the various components of the device (e.g., the processor 301, the memory 302, the input / output interface 303, and the communication interface 304);
[0126] The processor 301 , the memory 302 , the input / output interface 303 and the communication interface 304 are connected to each other in communication within the device via the bus 305 .
[0127] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned database-based SQL statement auditing method is implemented.
[0128] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0129] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0130] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0131] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0132] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0133] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0134] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0135] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0136] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0137] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0138] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0139] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for auditing SQL statements based on a database, characterized in that: Applied to an integrated development environment tool, the method comprises: The audit plug-in receives an audit instruction for at least one target file; wherein the audit plug-in is a plug-in pre-installed in an integrated development environment tool; The audit plug-in parses each of the target files according to the audit instruction to obtain the SQL statement of each of the target files; The third-party audit tool audits the SQL statements of the target file to obtain a first audit result of each target file; wherein the third-party audit tool is configured in the integrated development environment tool according to a preset configuration file, including: Receive a configuration request for a third-party audit tool; In response to the third-party audit tool configuration request, displaying a configuration interface in the integrated development environment tool; Obtain the configuration fields filled in the box in the configuration interface to obtain a configuration file; wherein the configuration file includes: a third-party audit tool service address, an audit database IP, an audit database type, an audit database interface, and an audit template; Configuring the third-party audit tool into the integrated development environment tool according to the configuration file; The audit plug-in displays the first audit result on the integrated development environment tool, including: The audit plug-in obtains the risk type of the SQL statement in the first audit result; wherein the first audit result includes the risk type of the SQL statement, the identification information of the file with risk, and the identification information of the SQL statement; According to the risk type and the correspondence between the risk type and the risk level, the SQL statement is divided into levels to obtain the risk level; wherein the correspondence between the risk type and the risk level is predefined, and the risk level includes: severe level, warning level and prompt level; The risk type, the file identification information, and the SQL statement identification information are layered and rendered on the integrated development environment tool according to the risk level, wherein the layered rendering includes: The risk level is the first layer, the risk type is the second layer, the file identification information is the third layer, and the SQL statement identification information is the fourth layer. The first layer contains all risk types belonging to the corresponding risk level, the second layer contains file identification information belonging to the corresponding risk type, and the third layer contains SQL statement identification information belonging to the corresponding file identification information. Clicking the first layer can display or hide the corresponding second layer, clicking the second layer can display or hide the corresponding third layer, and clicking the third layer can display or hide the corresponding fourth layer.
2. The method according to claim 1, characterized in that After rendering the risk type, the file identification information and the statement identification information in layers on the integrated development environment tool according to the risk level, the method further includes: In response to a click on the selected file identification information, jumping to the target file corresponding to the file identification information; In response to a click on the selected SQL statement identification information, the program jumps to the target file corresponding to the SQL statement identification information, and the cursor is positioned on the SQL statement corresponding to the SQL statement identification information.
3. The method according to claim 1, characterized in that The interface of the integrated development environment tool is provided with a first window and a second window, and the method further comprises: Rendering the risk type, the file identification information, and the SQL statement identification information in layers on the first window according to the risk level; In response to a click on the file identification information or the SQL statement identification information selected in the first window, a target file corresponding to the file identification information or the SQL statement identification information is displayed in the second window.
4. The method according to claim 3, characterized in that The method further comprises: Acquire a first window adjustment instruction of the first window or a second window adjustment instruction of the second window; The first window and the second window are adjusted according to the first window adjustment instruction, or the first window and the second window are adjusted according to the second window adjustment instruction.
5. The method according to claim 1, characterized in that After the audit plug-in displays the first audit result on the integrated development environment tool, the method further includes: The audit plug-in receives the audit instruction of the newly added file, and parses the newly added file according to the audit instruction to obtain the SQL statement of the newly added file; The third-party audit tool audits the SQL statement of the newly added file to obtain a second audit result of the newly added file; The audit plug-in updates the first audit result according to the second audit result.
6. A SQL statement auditing device based on a database, characterized in that: The device comprises: A receiving module, configured to receive an audit instruction for at least one target file through an audit plug-in; wherein the audit plug-in is a plug-in pre-installed in an integrated development environment tool; A parsing module, used to parse each of the target files according to the audit instruction through the audit plug-in to obtain the SQL statement of each of the target files; An audit module is used to audit the SQL statements of the target files through a third-party audit tool to obtain a first audit result of each target file; wherein the third-party audit tool is configured in the integrated development environment tool according to a preset configuration file, including: Receive a configuration request for a third-party audit tool; In response to the third-party audit tool configuration request, displaying a configuration interface in the integrated development environment tool; Obtain the configuration fields filled in the box in the configuration interface to obtain a configuration file; wherein the configuration file includes: a third-party audit tool service address, an audit database IP, an audit database type, an audit database interface, and an audit template; Configuring the third-party audit tool into the integrated development environment tool according to the configuration file; A display module, used for displaying the first audit result on the integrated development environment tool through the audit plug-in, comprising: The audit plug-in obtains the risk type of the SQL statement in the first audit result; wherein the first audit result includes the risk type of the SQL statement, the identification information of the file with risk, and the identification information of the SQL statement; According to the risk type and the correspondence between the risk type and the risk level, the SQL statement is divided into levels to obtain the risk level; wherein the correspondence between the risk type and the risk level is predefined, and the risk level includes: severe level, warning level and prompt level; The risk type, the file identification information, and the SQL statement identification information are layered and rendered on the integrated development environment tool according to the risk level, wherein the layered rendering includes: The risk level is the first layer, the risk type is the second layer, the file identification information is the third layer, and the SQL statement identification information is the fourth layer. The first layer contains all risk types belonging to the corresponding risk level, the second layer contains file identification information belonging to the corresponding risk type, and the third layer contains SQL statement identification information belonging to the corresponding file identification information. Clicking the first layer can display or hide the corresponding second layer, clicking the second layer can display or hide the corresponding third layer, and clicking the third layer can display or hide the corresponding fourth layer.
7. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the database-based SQL statement auditing method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the database-based SQL statement auditing method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
BIM model project approval review method and device and storage medium
CN112396393A
Work order auditing method and system, terminal and storage medium
CN112488652A
SQL statement auditing method and device, storage medium and electronic equipment
CN112783916A
Page display method and system
CN113420245A
SQL statement auditing method and device, electronic equipment and storage medium
CN114048139A
