Database SQL script auditing method, device and equipment and storage medium
By receiving and parsing SQL scripts to be reviewed on the database SQL script audit platform, and using preset parsing and auditing rules, the problems of low efficiency and insufficient reliability of SQL script audit in the existing technology are solved, and an efficient and accurate audit process is achieved, reducing labor costs.
Patent Information
- Application Number
- CN202411425972.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-02-25
AI Technical Summary
In the prior art, the audit efficiency of database SQL scripts is low, the reliability and accuracy are insufficient, and the audit path is not unified, which makes it difficult to guarantee the credibility and accuracy of the audit results, and the skills requirements for auditors are high.
Through the preset database SQL script audit platform, the preset interface receives the SQL script to be reviewed uploaded by the smart operation and maintenance management platform, obtains the execution instance information and database type, and uses the preset SQL audit tool to determine the target classification analysis rules and audit rules library, performs keyword analysis and audit, and completes the script release operation.
It improves the efficiency, reliability, accuracy and applicability of database SQL script audits, reduces labor costs, and improves the user experience.
Smart Images

Figure CN119512931A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of SQL script development, and in particular to a database SQL script auditing method, device, equipment and storage medium. Background Art
[0002] At present, the data centers of most companies in the field publish a large number of SQL (Structured Query Language) scripts every week, and they are mainly manually reviewed by auditors. As a result, on the one hand, each SQL script review takes a long time, and the review of super-large SQL scripts is also limited by manpower, which makes it impossible to review them effectively. On the other hand, the company's application release, low / high-risk data modification orders, etc. involve many processes for SQL script release, and the SQL script review path is not unified, which makes it impossible to guarantee the credibility and accuracy of the review results, and requires auditors to have high audit skills. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a database SQL script audit method, device, equipment and storage medium, which can effectively improve the efficiency, reliability, accuracy and applicability of database SQL script audit, and greatly reduce labor costs, thereby improving user experience. The specific scheme is as follows:
[0004] In a first aspect, the present application provides a database SQL script audit method, which is applied to a preset database SQL script audit platform, including:
[0005] Receive the SQL script of the database to be reviewed that has completed development and testing and is uploaded by the preset intelligent operation and maintenance management platform based on the preset interface, and obtain the execution instance information and database type corresponding to the SQL script of the database to be reviewed;
[0006] Determine the target classification parsing rule corresponding to the SQL script of the database to be audited based on the preset SQL audit tool, the execution instance information, and the database type, and perform keyword parsing on the SQL script of the database to be audited according to the target classification parsing rule to obtain a corresponding parsing result;
[0007] Based on the preset SQL audit tool, a target audit rule library corresponding to the SQL script of the database to be audited is determined, and the corresponding target audit result is determined using the target audit rule library and the analysis result, so as to complete the script publishing operation corresponding to the SQL script of the database to be audited according to the target audit result.
[0008] Optionally, the receiving, based on a preset interface, a database SQL script to be reviewed that has completed development and testing and is uploaded by a preset intelligent operation and maintenance management platform includes:
[0009] After the preset IT development and testing management platform pushes the pending database SQL script that has completed development and testing to the preset intelligent operation and maintenance management platform, the pending database SQL script uploaded by the preset intelligent operation and maintenance management platform is obtained based on the preset interface;
[0010] Or, based on the preset interface, the to-be-reviewed database SQL script uploaded by the preset intelligent operation and maintenance management platform is received after a new database SQL script publishing task is created.
[0011] Optionally, the obtaining of the execution instance information and database type corresponding to the SQL script of the database to be reviewed includes:
[0012] Based on the preset interface, the execution instance information determined by the preset intelligent operation and maintenance management platform using the configuration management database is obtained;
[0013] The corresponding database type is determined based on the script name corresponding to the SQL script of the database to be audited.
[0014] Optionally, the determining of a target classification parsing rule corresponding to the SQL script of the database to be audited based on a preset SQL audit tool, the execution instance information, and the database type includes:
[0015] Based on the preset SQL audit tool, the execution instance information, and the database type, determine whether to perform ORACLE syntax parsing, MySQL syntax parsing, KINGBASE syntax parsing, and / or TDSQL syntax parsing on the SQL script of the database to be audited to obtain a corresponding judgment result;
[0016] Based on the judgment result, a target classification parsing rule corresponding to the SQL script of the database to be reviewed is determined.
[0017] Optionally, performing keyword parsing on the SQL script of the database to be audited according to the target classification parsing rule to obtain a corresponding parsing result includes:
[0018] According to the target classification parsing rules, the SQL syntax parser corresponding to the database type is called to extract the keyword features and parameters in each statement in the SQL script of the database to be audited, so as to obtain the corresponding parsing results.
[0019] Optionally, the determining a corresponding target audit result by using the target audit rule base and the parsing result includes:
[0020] Using the target audit rule library to compare the keyword features and the parameters in the parsing result to obtain a corresponding comparison result;
[0021] When the comparison result indicates that several rules in the target audit rule library are currently hit, the target audit result including the corresponding risk level and risk recommendation is determined based on the comparison result and the rules.
[0022] Optionally, completing the script publishing operation corresponding to the SQL script of the database to be audited according to the target audit result includes:
[0023] If the target audit result indicates that the SQL script of the database to be audited does not have any risk, a first execution task corresponding to the SQL script of the database to be audited is generated;
[0024] If the target audit result indicates that the SQL script of the database to be audited has risks, after determining that the risks are controllable based on the target audit result, generating a second execution task corresponding to the SQL script of the database to be audited;
[0025] If the target audit result indicates that there is a risk in the SQL script of the database to be audited, after determining that the risk is uncontrollable based on the target audit result, the target audit result will be returned to the preset intelligent operation and maintenance management platform, so that the preset intelligent operation and maintenance management platform can update the SQL script of the database to be audited based on the target audit result, and then upload the updated SQL script until the audit is successful, completing the corresponding script publishing operation.
[0026] In a second aspect, the present application provides a database SQL script auditing device, which is applied to a preset database SQL script auditing platform, including:
[0027] The SQL script acquisition module is used to receive the SQL script of the database to be reviewed that has completed development and testing and is uploaded by the preset intelligent operation and maintenance management platform based on the preset interface, and obtain the execution instance information and database type corresponding to the SQL script of the database to be reviewed;
[0028] A script parsing module, used to determine the target classification parsing rule corresponding to the SQL script of the database to be audited based on the preset SQL audit tool, the execution instance information, and the database type, and perform keyword parsing on the SQL script of the database to be audited according to the target classification parsing rule to obtain a corresponding parsing result;
[0029] An audit result determination module is used to determine the target audit rule library corresponding to the SQL script of the database to be audited based on the preset SQL audit tool, and use the target audit rule library and the analysis result to determine the corresponding target audit result, so as to complete the script publishing operation corresponding to the SQL script of the database to be audited according to the target audit result.
[0030] In a third aspect, the present application provides an electronic device, including:
[0031] Memory, used to store computer programs;
[0032] The processor is used to execute the computer program to implement the steps of the aforementioned database SQL script auditing method.
[0033] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, which implements the steps of the aforementioned database SQL script auditing method when executed by a processor.
[0034] It can be seen that in this application, the preset database SQL script audit platform first receives the database SQL script to be audited that has completed development and testing uploaded by the preset intelligent operation and maintenance management platform based on the preset interface, and obtains the execution instance information and database type corresponding to the database SQL script to be audited; based on the preset SQL audit tool and the execution instance information and the database type, the target classification parsing rule corresponding to the database SQL script to be audited is determined, and the keyword parsing of the database SQL script to be audited is performed according to the target classification parsing rule to obtain the corresponding parsing result; based on the preset SQL audit tool, the target audit rule library corresponding to the database SQL script to be audited is determined, and the corresponding target audit result is determined using the target audit rule library and the parsing result, so as to complete the script release operation corresponding to the database SQL script to be audited according to the target audit result. That is, in this application, the database SQL script to be audited is received through the preset interface on the preset database SQL script audit platform, and then the corresponding parsing rule is determined based on the corresponding database type and the preset SQL audit tool, and the keyword parsing is performed, and finally the target audit result is obtained using the obtained parsing result and the target audit rule library determined by the preset SQL audit tool to complete the script release. In this way, the efficiency, reliability, accuracy and applicability of database SQL script auditing can be effectively improved, and labor costs can be greatly reduced, thereby improving user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0036] Figure 1 A flow chart of a database SQL script audit method provided for this application;
[0037] Figure 2 A specific database SQL script audit method flow chart provided for this application;
[0038] Figure 3 A schematic diagram of the structure of a database SQL script audit device provided by this application;
[0039] Figure 4 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] At present, the data centers of most companies in the field publish a large number of SQL scripts every week, and they are mainly manually reviewed by auditors. As a result, on the one hand, each SQL script review takes a long time, and the review of super-large SQL scripts is also subject to manpower constraints, which makes it impossible to effectively review them. On the other hand, the company's application release, low / high-risk data modification orders, and other processes involving the release of SQL scripts are numerous, and the SQL script review paths are not unified, which makes it impossible to guarantee the credibility and accuracy of the audit results, and requires high audit skills from auditors. To this end, the present application provides a database SQL script audit solution that can effectively improve the efficiency, reliability, accuracy, and applicability of database SQL script audits, and greatly reduce labor costs, thereby improving user experience.
[0042] See also Figure 1 As shown, an embodiment of the present invention discloses a database SQL script audit method, which is applied to a preset database SQL script audit platform, including:
[0043] Step S11: Receive the SQL script of the database to be reviewed that has completed development and testing and is uploaded by the preset intelligent operation and maintenance management platform based on the preset interface, and obtain the execution instance information and database type corresponding to the SQL script of the database to be reviewed.
[0044] Specifically, when a change release script needs to be executed on the database, in order to avoid database failures caused by syntax or known risk rules, the SQL script to be released and executed needs to be reviewed. Figure 2 As shown, in this embodiment, the script is first obtained through a unified interface, that is, the preset interface receives the database SQL script to be reviewed that has completed development and testing and is uploaded by the preset smart operation and maintenance management platform, including: receiving the database SQL script to be reviewed uploaded by the preset smart operation and maintenance management platform after the new database SQL script release task is created based on the preset interface. Among them, the preset interface is the Figure 2 Or, after the preset IT (Information Technology) development and testing management platform pushes the pending database SQL script that has completed development and testing to the preset intelligent operation and maintenance management platform, the pending database SQL script uploaded by the preset intelligent operation and maintenance management platform is obtained based on the preset interface ( Figure 2 In addition, Figure 2 As shown, in this embodiment, the Figure 2 The entry 2 shown in the figure obtains the developed database SQL script to be audited sent by the preset IT development and test management platform through the push release task. In this way, the SQL audit path is converged, and the preset database SQL script audit platform provides a unified SQL audit service. Providing a unified standard SQL audit interface provides feasibility for rapid docking of various tool platforms.
[0045] Furthermore, in this embodiment, the acquisition of the execution instance information and database type corresponding to the SQL script of the database to be reviewed includes: acquiring the execution instance information determined by the preset intelligent operation and maintenance management platform using the configuration management database based on the preset interface; and determining the corresponding database type based on the script name corresponding to the SQL script of the database to be reviewed. Specifically, the SQL script of the database to be reviewed can be type matched, and the database type can be automatically identified based on the SQL script name.
[0046] Step S12: determine the target classification parsing rule corresponding to the SQL script of the database to be audited based on the preset SQL audit tool, the execution instance information, and the database type, and perform keyword parsing on the SQL script of the database to be audited according to the target classification parsing rule to obtain a corresponding parsing result.
[0047] Specifically, after obtaining the corresponding script information, the platform starts to statically audit the SQL script of the database to be audited, first determines the parsing rules of the script, and then performs parsing. That is, the target classification parsing rules corresponding to the SQL script of the database to be audited are determined based on the preset SQL audit tool, the execution instance information, and the database type, including: judging whether to perform ORACLE syntax parsing, MySQL syntax parsing, KINGBASE syntax parsing and / or TDSQL syntax parsing on the SQL script of the database to be audited based on the preset SQL audit tool, the execution instance information, and the database type to obtain the corresponding judgment result; determining the target classification parsing rules corresponding to the SQL script of the database to be audited based on the judgment result. Specifically, according to the identified database type, the SQL syntax parser of the corresponding database type can be automatically called to parse each SQL in the SQL script content.
[0048] It is further to be understood that, in this embodiment, the keyword parsing of the SQL script of the database to be audited according to the target classification parsing rule to obtain the corresponding parsing result includes: extracting the keyword features and parameters in each statement in the SQL script of the database to be audited according to the target classification parsing rule and calling the SQL syntax parser corresponding to the database type to obtain the corresponding parsing result. That is, based on the keywords identified after parsing, extracting built-in keyword features, parameters, etc. to determine the parsing result.
[0049] Step S13: determine the target audit rule library corresponding to the SQL script of the database to be audited based on the preset SQL audit tool, and use the target audit rule library and the analysis result to determine the corresponding target audit result, so as to complete the script publishing operation corresponding to the SQL script of the database to be audited according to the target audit result.
[0050] In this embodiment, after completing the script parsing, it is necessary to compare the parsing result with the corresponding audit rule library to return the statements that violate the SQL audit rules and output the optimization suggestions and risk levels corresponding to the SQL audit rules. That is, the use of the target audit rule library and the parsing result to determine the corresponding target audit result includes: using the target audit rule library to compare the keyword features and the parameters in the parsing result to obtain the corresponding comparison result; when the comparison result shows that several rules in the target audit rule library are currently hit, the target audit result including the corresponding risk level and risk recommendation is determined based on the comparison result and the rule. Specifically, the rules evaluated by the DBA (Database Administrator) are disassembled into rule syntax, and custom extensions are supported. Rule examples: "The owner name must be specified before the index name", "The table space used by the index must be specified", "The primary key must be created using a separate SQL statement and must not be written in the creation statement of the TABLE object", "The primary key name must be explicitly named and the system default name must not be used.", "New indexes for existing tables must be added in parallel", "The owner name must be specified before the table name related to the constraint", "The constraint must be created using a separate SQL statement and must not be written in the table creation statement", "The constraint name must be explicitly named and the system default name must not be used", "The owner name must be specified before the object name", "The DETETE statement must be backed up using the same SELECT condition" and other various rules. In addition, different SQL audit rules set different risk levels. If any SQL in the SQL script hits the "serious" risk level, the audit result of the script will not pass. In addition, the specific target audit result can include multiple script lines with violations and the corresponding reasons for violations and / or suggestions. In addition, the above-mentioned static audit can generate a report page, draw a trend chart for the number of static audits and audit status within a certain period of time, and display the latest audit record related script files, results, suggestions and other information.
[0051] Furthermore, in this embodiment, combined with Figure 2As shown, the script publishing operation corresponding to the SQL script of the database to be reviewed is completed according to the target audit result, including: if the target audit result shows that the SQL script of the database to be reviewed does not have risks, then a first execution task corresponding to the SQL script of the database to be reviewed is generated; if the target audit result shows that the SQL script of the database to be reviewed has risks, after determining that the risks are controllable based on the target audit result, a second execution task corresponding to the SQL script of the database to be reviewed is generated; if the target audit result shows that the SQL script of the database to be reviewed has risks, after determining that the risks are uncontrollable based on the target audit result, the target audit result is returned to the preset smart operation and maintenance management platform, so that the preset smart operation and maintenance management platform can upload the updated SQL script after updating the SQL script of the database to be reviewed based on the target audit result, until the audit is successful, the corresponding script publishing operation is completed. That is, if there is no risk or the risk is controllable, it can be published; otherwise, it will not be published, and the target audit result and the SQL script of the database to be reviewed will be returned to the corresponding entry 1 / 2 until the audit is passed.
[0052] It can be seen that in the embodiment of the present application, the preset database SQL script audit platform first receives the database SQL script to be audited that has completed development and testing uploaded by the preset intelligent operation and maintenance management platform based on the preset interface, and obtains the execution instance information and database type corresponding to the database SQL script to be audited; based on the preset SQL audit tool and the execution instance information and the database type, the target classification parsing rule corresponding to the database SQL script to be audited is determined, and the database SQL script to be audited is parsed by keywords according to the target classification parsing rule to obtain the corresponding parsing result; based on the preset SQL audit tool, the target audit rule library corresponding to the database SQL script to be audited is determined, and the corresponding target audit result is determined by using the target audit rule library and the parsing result, so as to complete the script release operation corresponding to the database SQL script to be audited according to the target audit result. That is, in the present application, the database SQL script to be audited is received through the preset interface on the preset database SQL script audit platform, and then the corresponding parsing rule is determined and the keyword parsing is performed based on the corresponding database type and the preset SQL audit tool, and finally the target audit result is obtained by using the obtained parsing result and the target audit rule library determined by the preset SQL audit tool to complete the script release. In this way, the efficiency, reliability, accuracy and applicability of database SQL script auditing can be effectively improved, and labor costs can be greatly reduced, thereby improving user experience.
[0053] See also Figure 3As shown, the embodiment of the present application also discloses a database SQL script auditing device, which is applied to a preset database SQL script auditing platform, including:
[0054] The SQL script acquisition module 11 is used to receive the SQL script of the database to be reviewed that has completed development and testing and is uploaded by the preset intelligent operation and maintenance management platform based on the preset interface, and obtain the execution instance information and database type corresponding to the SQL script of the database to be reviewed;
[0055] The script parsing module 12 is used to determine the target classification parsing rule corresponding to the SQL script of the database to be audited based on the preset SQL audit tool, the execution instance information, and the database type, and perform keyword parsing on the SQL script of the database to be audited according to the target classification parsing rule to obtain a corresponding parsing result;
[0056] The audit result determination module 13 is used to determine the target audit rule library corresponding to the SQL script of the database to be audited based on the preset SQL audit tool, and use the target audit rule library and the analysis result to determine the corresponding target audit result, so as to complete the script publishing operation corresponding to the SQL script of the database to be audited according to the target audit result.
[0057] Among them, for more specific working processes of the above-mentioned modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0058] It can be seen that in this application, the database SQL script to be audited is received through the preset interface on the preset database SQL script audit platform, and then the corresponding parsing rules are determined based on the corresponding database type and the preset SQL audit tool and keyword parsing is performed, and finally the target audit result is obtained using the obtained parsing result and the target audit rule library determined by the preset SQL audit tool to complete the script release. In this way, the efficiency, reliability, accuracy, and applicability of database SQL script audits can be effectively improved, and the labor cost can be greatly reduced, thereby improving the user experience.
[0059] In some specific embodiments, the SQL script acquisition module 11 may specifically include:
[0060] After the preset IT development and testing management platform pushes the pending database SQL script that has completed development and testing to the preset intelligent operation and maintenance management platform, the pending database SQL script uploaded by the preset intelligent operation and maintenance management platform is obtained based on the preset interface;
[0061] Or, based on the preset interface, the to-be-reviewed database SQL script uploaded by the preset intelligent operation and maintenance management platform is received after a new database SQL script publishing task is created.
[0062] In some specific embodiments, the SQL script acquisition module 11 may specifically include:
[0063] Based on the preset interface, the execution instance information determined by the preset intelligent operation and maintenance management platform using the configuration management database is obtained;
[0064] The corresponding database type is determined based on the script name corresponding to the SQL script of the database to be audited.
[0065] In some specific embodiments, the script parsing module 12 may specifically include:
[0066] Based on the preset SQL audit tool, the execution instance information, and the database type, determine whether to perform ORACLE syntax parsing, MySQL syntax parsing, KINGBASE syntax parsing, and / or TDSQL syntax parsing on the SQL script of the database to be audited to obtain a corresponding judgment result;
[0067] Based on the judgment result, a target classification parsing rule corresponding to the SQL script of the database to be reviewed is determined.
[0068] In some specific embodiments, the script parsing module 12 may specifically include:
[0069] According to the target classification parsing rules, the SQL syntax parser corresponding to the database type is called to extract the keyword features and parameters in each statement in the SQL script of the database to be audited, so as to obtain the corresponding parsing results.
[0070] In some specific embodiments, the audit result determination module 13 may specifically include:
[0071] Using the target audit rule library to compare the keyword features and the parameters in the parsing result to obtain a corresponding comparison result;
[0072] When the comparison result indicates that several rules in the target audit rule library are currently hit, the target audit result including the corresponding risk level and risk recommendation is determined based on the comparison result and the rules.
[0073] In some specific embodiments, the audit result determination module 13 may specifically include:
[0074] If the target audit result indicates that the SQL script of the database to be audited does not have any risk, a first execution task corresponding to the SQL script of the database to be audited is generated;
[0075] If the target audit result indicates that the SQL script of the database to be audited has risks, after determining that the risks are controllable based on the target audit result, generating a second execution task corresponding to the SQL script of the database to be audited;
[0076] If the target audit result indicates that there is a risk in the SQL script of the database to be audited, after determining that the risk is uncontrollable based on the target audit result, the target audit result will be returned to the preset intelligent operation and maintenance management platform, so that the preset intelligent operation and maintenance management platform can update the SQL script of the database to be audited based on the target audit result, and then upload the updated SQL script until the audit is successful, completing the corresponding script publishing operation.
[0077] Furthermore, the present application also discloses an electronic device. Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be considered as any limitation on the scope of use of the present application.
[0078] Figure 4 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the database SQL script audit method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0079] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0080] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0081] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the database SQL script audit method executed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include computer programs that can be used to complete other specific tasks.
[0082] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed database SQL script audit method is implemented. The specific steps of the method can be referred to the corresponding contents disclosed in the aforementioned embodiments, and will not be repeated here.
[0083] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0084] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0085] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0086] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0087] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A database SQL script audit method, characterized in that: Applied to the preset database SQL script audit platform, including: Receive the SQL script of the database to be reviewed that has completed development and testing and is uploaded by the preset intelligent operation and maintenance management platform based on the preset interface, and obtain the execution instance information and database type corresponding to the SQL script of the database to be reviewed; Determine the target classification parsing rule corresponding to the SQL script of the database to be audited based on the preset SQL audit tool, the execution instance information, and the database type, and perform keyword parsing on the SQL script of the database to be audited according to the target classification parsing rule to obtain a corresponding parsing result; Based on the preset SQL audit tool, a target audit rule library corresponding to the SQL script of the database to be audited is determined, and the corresponding target audit result is determined using the target audit rule library and the analysis result, so as to complete the script publishing operation corresponding to the SQL script of the database to be audited according to the target audit result.
2. The database SQL script audit method according to claim 1, characterized in that: The receiving, based on the preset interface, the SQL script of the database to be reviewed that has completed development and testing and is uploaded by the preset intelligent operation and maintenance management platform includes: After the preset IT development and testing management platform pushes the pending database SQL script that has completed development and testing to the preset intelligent operation and maintenance management platform, the pending database SQL script uploaded by the preset intelligent operation and maintenance management platform is obtained based on the preset interface; Or, based on the preset interface, the to-be-reviewed database SQL script uploaded by the preset intelligent operation and maintenance management platform is received after a new database SQL script publishing task is created.
3. The database SQL script audit method according to claim 1, characterized in that: The obtaining of the execution instance information and database type corresponding to the SQL script of the database to be reviewed includes: Based on the preset interface, the execution instance information determined by the preset intelligent operation and maintenance management platform using the configuration management database is obtained; The corresponding database type is determined based on the script name corresponding to the SQL script of the database to be audited.
4. The database SQL script audit method according to claim 1, characterized in that: The determining of the target classification parsing rule corresponding to the SQL script of the database to be audited based on the preset SQL audit tool, the execution instance information, and the database type includes: Based on the preset SQL audit tool, the execution instance information, and the database type, determine whether to perform ORACLE syntax parsing, MySQL syntax parsing, KINGBASE syntax parsing, and / or TDSQL syntax parsing on the SQL script of the database to be audited to obtain a corresponding judgment result; Based on the judgment result, a target classification parsing rule corresponding to the SQL script of the database to be reviewed is determined.
5. The database SQL script audit method according to claim 1, characterized in that: The keyword parsing of the SQL script of the database to be reviewed according to the target classification parsing rule to obtain the corresponding parsing result includes: According to the target classification parsing rules, the SQL syntax parser corresponding to the database type is called to extract the keyword features and parameters in each statement in the SQL script of the database to be audited, so as to obtain the corresponding parsing results.
6. The database SQL script audit method according to claim 5, characterized in that: The determining of the corresponding target audit result by using the target audit rule base and the analysis result includes: Using the target audit rule library to compare the keyword features and the parameters in the parsing result to obtain a corresponding comparison result; When the comparison result indicates that several rules in the target audit rule library are currently hit, the target audit result including the corresponding risk level and risk recommendation is determined based on the comparison result and the rules.
7. The database SQL script audit method according to any one of claims 1 to 6, characterized in that: The script publishing operation corresponding to the SQL script of the database to be audited is completed according to the target audit result, including: If the target audit result indicates that the SQL script of the database to be audited does not have any risk, a first execution task corresponding to the SQL script of the database to be audited is generated; If the target audit result indicates that the SQL script of the database to be audited has risks, after determining that the risks are controllable based on the target audit result, generating a second execution task corresponding to the SQL script of the database to be audited; If the target audit result indicates that there is a risk in the SQL script of the database to be audited, after determining that the risk is uncontrollable based on the target audit result, the target audit result will be returned to the preset intelligent operation and maintenance management platform, so that the preset intelligent operation and maintenance management platform can update the SQL script of the database to be audited based on the target audit result, and then upload the updated SQL script until the audit is successful, completing the corresponding script publishing operation.
8. A database SQL script auditing device, characterized in that: Applied to the preset database SQL script audit platform, including: The SQL script acquisition module is used to receive the SQL script of the database to be reviewed that has completed development and testing and is uploaded by the preset intelligent operation and maintenance management platform based on the preset interface, and obtain the execution instance information and database type corresponding to the SQL script of the database to be reviewed; A script parsing module, used to determine the target classification parsing rule corresponding to the SQL script of the database to be audited based on the preset SQL audit tool, the execution instance information, and the database type, and perform keyword parsing on the SQL script of the database to be audited according to the target classification parsing rule to obtain a corresponding parsing result; An audit result determination module is used to determine the target audit rule library corresponding to the SQL script of the database to be audited based on the preset SQL audit tool, and use the target audit rule library and the analysis result to determine the corresponding target audit result, so as to complete the script publishing operation corresponding to the SQL script of the database to be audited according to the target audit result.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor is used to execute the computer program to implement the database SQL script auditing method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, implements the database SQL script auditing method as described in any one of claims 1 to 7.
Citation Information
Cited By
SQL assessment risk control system and device and storage medium
CN120804136A