A heterogeneous database migration permission checking correction method, device and medium
By constructing a source-side permission semantic graph and a target-side capability constraint graph, a permission behavior verification matrix is generated, which solves the problem of inconsistent permission behaviors in heterogeneous database migration, achieves consistency between the permission behaviors of the target database and the source database, and improves the security and reliability of the migration.
Patent Information
- Application Number
- CN202611665501.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-27
- Publication Date
- 2026-11-27
AI Technical Summary
During the migration of heterogeneous databases, existing technologies cannot effectively verify whether the permission behavior of the target end is consistent with that of the source end, resulting in issues of unauthorized or excessive permissions. Furthermore, the lack of reverse rejection verification makes it difficult to generate minimal authorization results and form an auditable, verifiable, and rollback-capable chain of evidence for permission migration.
By constructing a source-side permission semantic graph and a target-side capability constraint graph, a permission behavior verification matrix is generated, candidate authorization scripts are executed, and a minimum authorization correction script is generated based on the verification results. This ensures that allowed items are executable and denied items are not executable, forming an auditable permission migration evidence chain.
It ensures the reliability and security of permission behavior during heterogeneous database migration, guarantees that the permission behavior of the target database is consistent with that of the source database, improves the security and reliability of migration, and provides an auditable and verifiable chain of evidence for permission migration.
Smart Images

Figure CN123178371A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of database migration and database security technology, and in particular to a method, device and medium for verifying and correcting permissions during heterogeneous database migration. Background Technology
[0002] In addition to migrating table structures and data, migrating heterogeneous databases also requires migrating users, roles, system permissions, object permissions, column-level permissions, row-level security policies, role inheritance, and authorization chains. However, different databases differ in permission names, granularity, inheritance rules, and row- and column-level control capabilities, so permissions cannot be accomplished solely through syntax conversion.
[0003] Existing technologies typically establish a source-target permission mapping table, read source-target user, role, object, and permission information, and generate target-target authorization statements. When completely equivalent permissions do not exist in the target database, they are handled manually by the administrator. While this approach reduces the workload of syntax conversion, it has the following drawbacks: First, it only converts authorization statements without verifying whether the target user's actual actions such as querying, updating, deleting, and calling functions are consistent with those on the source, which can easily lead to unauthorized or excessive permissions. Second, it lacks reverse denial verification. It usually only verifies whether operations that should be allowed can be executed, without verifying whether operations that should be denied on the source are still denied on the target. This can easily lead to privilege amplification when roles are merged, authorization granularity is expanded, or indirect access to views is made. Third, non-equivalent permissions rely on manual judgment, lacking an automatic correction loop, making it difficult to stably generate minimum authorization results. Fourth, it lacks structured records such as source snapshots, verification matrices, allow and deny verification results, and correction differences, making it difficult to reproduce during security audits and migration acceptance.
[0004] Therefore, how to verify whether the target-side permission behavior is consistent with the source-side through bidirectional verification of allow and deny behaviors, and generate a minimum authorization correction scheme that satisfies that allowed items are executable, denied items are not executable, and the authorization set is as small as possible, thereby forming an auditable, verifiable, and rollback-capable permission migration evidence chain, has become an urgent technical problem to be solved. Summary of the Invention
[0005] This application provides a heterogeneous database migration permission verification and correction method, device and medium to solve the following technical problem: how to verify whether the permission behavior of the target end is consistent with that of the source end through bidirectional verification of allow and deny behaviors, and generate a minimum authorization correction scheme that satisfies that allowed items are executable, denied items are not executable and the authorization set is as small as possible, thereby forming an auditable, verifiable and rollbackable permission migration evidence chain.
[0006] In a first aspect, embodiments of this application provide a method for verifying and correcting permissions during heterogeneous database migration. The method includes: constructing a source-side permission semantic graph based on permission metadata in the source database, and configuring target-side permission capabilities based on the target database type and version to construct a target-side capability constraint graph; generating a permission behavior verification matrix based on the source-side permission semantic graph and the migration object scope; generating target-side candidate authorization scripts based on the source-side permission semantic graph and the target-side capability constraint graph, and generating target-side authorization statements for permissions that can be equivalently mapped, and generating candidate authorization scripts for permissions that cannot be completely equivalently mapped; executing the candidate authorization scripts in the target database, and switching user or role contexts and executing verification SQL based on the permission behavior verification matrix to record the verification execution results; generating a minimum authorization correction script with constraints of allowing all passes in the allow matrix and rejecting all rejections in the reject matrix based on the verification execution results, and re-executing the verification logic until the permission behavior verification results converge to obtain a permission migration evidence chain.
[0007] In one implementation of this application, a source-side permission semantic graph is constructed based on permission metadata in the source database. Specifically, this includes: generating user nodes, role nodes, column nodes, and policy nodes based on user information, role information, column information, row-level security policy information, and operation types in the permission metadata; generating object nodes based on table, view, function, stored procedure, or synonym information; generating role inheritance edges, authorization edges, and sub-authorization edges based on the granting relationships, permission granting relationships, and sub-authorization relationships between roles; generating dependency edges based on the reference relationships from synonyms to base tables, views to base tables, and functions or stored procedures to dependent objects; and generating policy constraint edges based on the constraint relationships between row-level security policies and objects, users, or roles; and storing user nodes, role nodes, object nodes, column nodes, policy nodes, operation nodes, and role inheritance edges, authorization edges, dependency edges, sub-authorization edges, and policy constraint edges in association with migration task identifiers to generate the source-side permission semantic graph.
[0008] In one implementation of this application, target-side permission capabilities are configured based on the target library type and version to construct a target-side capability constraint graph. Specifically, this includes: reading the type and version information of the target database, and based on the type and version information, querying the target database's permission dictionary, role definition rules, authorization syntax rules, and security policy configuration rules to obtain the target-side permission capabilities; wherein, the target-side permission capabilities include the target-side supported permission granularity, role inheritance method, column-level authorization support capabilities, row-level security policy support capabilities, view authorization support capabilities, function execution authorization support capabilities, sub-authorization support capabilities, default role rules, and a list of non-equivalent permissions; the target-side permission capabilities are stored in association with migration task identifiers to generate a target-side capability constraint graph, and based on the target-side capability constraint graph, source-side permissions are matched item by item with target-side permission capabilities to determine the expression type of source-side permissions on the target side and record the matching results; wherein, the expression type includes direct expression, split expression, substitution expression, or non-equivalent expression.
[0009] In one implementation of this application, a permission behavior verification matrix is generated based on the source-side permission semantic graph and the scope of the migration object. Specifically, this includes: selecting corresponding object nodes, column nodes, policy nodes, and operation nodes from the source-side permission semantic graph based on the scope of the migration object, and traversing the authorization edges, role inheritance edges, dependency edges, sub-authorization edges, and policy constraint edges in the source-side permission semantic graph to determine the authorized user or role, the allowed operation, the object, column, and condition affected by the operation; generating an allowance matrix item based on the authorized user or role, the allowed operation, the object, column, and condition affected by the operation; wherein, the allowance matrix item includes... This includes user or role, operation type, database object, column, condition, expected allowed result, and verification SQL; based on objects and columns not covered by authorized edges in the source permission semantic graph, the scope restricted by policy constraint edges, the view-to-base table access boundary implied by dependency edges, and the sub-authorization capability restricted by sub-authorization edges, it determines the operations that unauthorized users or roles should not perform and generates a denial matrix item; wherein, the denial matrix item includes user or role, operation type, database object, column, condition, expected denial result, and verification SQL; allow matrix items and denial matrix items are associated and stored according to migration task identifier to generate permission behavior verification matrix.
[0010] In one implementation of this application, target-side candidate authorization scripts are generated based on the source-side permission semantic graph and the target-side capability constraint graph. Target-side authorization statements are generated for permissions that can be equivalently mapped, and candidate authorization scripts are generated for permissions that cannot be completely equivalently mapped. Specifically, this includes: when the expression type is a direct expression, generating target-side authorization statements corresponding to the source-side permissions based on the permission type, target object, scope, effective conditions, and whether sub-delegation is allowed in the authorization edge; when the expression type is a split expression, splitting the source-side permissions into several target-side permissions based on the split mapping relationship recorded in the target-side capability constraint graph, and generating target-side authorization statements corresponding to each of the several target-side permissions; when the expression type is a substitution expression, based on the target... The alternative mapping relationships recorded in the endpoint capability constraint diagram are used to generate candidate alternative authorization scripts. These scripts include column-level authorization statements that split table-level permissions into column-level permissions, view definition statements that convert unexpressible row-level restrictions into restricted views or policy definition statements for row-level security policies, role creation and authorization statements that split excessively large role permissions into multiple target roles, and dependency authorization supplementary statements that supplement object-dependent permissions to the dependent objects of views, functions, or stored procedures. When the expression type is non-equivalent, a manual confirmation item is generated, and the reason for the non-equivalence of the source endpoint permissions is recorded. The target endpoint authorization statements, candidate alternative authorization scripts, and manual confirmation items are associated and stored according to the migration task identifier to generate the target endpoint candidate authorization script.
[0011] In one implementation of this application, the process involves executing a candidate authorization script in the target database and switching the user or role context based on the permission behavior verification matrix and executing verification SQL. Specifically, this includes: executing the candidate authorization script in the target database to make the target-side authorization statement, candidate alternative authorization script, and manual confirmation item in the candidate authorization script effective in the target database; traversing the allowed and denied matrix items in the permission behavior verification matrix to obtain the user or role, operation type, database object, column, condition, expected result, and verification SQL corresponding to the current verification item; switching the current execution context of the target database to the corresponding user or role based on the user or role corresponding to the current verification item; executing the verification SQL corresponding to the current verification item in the switched execution context; and capturing the execution status, error code, number of affected rows, returned column set, returned row range, and permission exception information of the verification SQL to obtain the verification execution result.
[0012] In one implementation of this application, after executing the verification SQL, the method further includes: comparing the captured execution status with the expected result in the current verification item; when the current verification item belongs to the allowed matrix item and execution fails, it is recorded as a lack of privilege problem, and when the current verification item belongs to the rejected matrix item and execution succeeds, it is recorded as an excessive privilege problem; when the current verification item belongs to the allowed matrix item and execution succeeds but the returned column set or returned row range exceeds the source expectation, it is recorded as a permission granularity amplification problem, and when the current verification item involves functions, views, or synonyms and execution fails due to lack of privilege in dependent objects, it is recorded as a dependency authorization missing problem; when the current verification item involves a sub-authorization operation and the execution result is inconsistent with the source expectation, it is recorded as an authorization chain inconsistency problem; the execution status, error code, number of affected rows, returned column set, returned row range, permission exception information of each verification item, as well as the recorded lack of privilege problem, excessive privilege problem, permission granularity amplification problem, dependency authorization missing problem, and authorization chain inconsistency problem are associated and stored according to the migration task identifier to generate the verification execution result.
[0013] In one implementation of this application, based on the verification execution result, a minimum authorization correction script is generated with constraints of all passes in the allow matrix and all rejections in the reject matrix. The verification logic is then re-executed until the permission behavior verification result converges to obtain a permission migration evidence chain. Specifically, this includes: generating corresponding correction statements based on the verification execution result and combining the correction statements; generating a minimum authorization correction script according to a preset priority order of authorization scope, authorization object scope, validity period, and sub-authorization capability under the constraints of all passes in the allow matrix and all rejections in the reject matrix; executing the minimum authorization correction script in the target database and re-executing the permission behavior verification matrix to obtain a new verification execution result; if the new verification execution result still has issues such as missing permissions, excessive permissions, amplified permission granularity, missing dependent authorizations, or inconsistent authorization chains, then the minimum authorization correction script is regenerated until the permission behavior verification result converges; and associating and saving the source permission snapshot, target capability constraint graph, permission behavior verification matrix, candidate authorization scripts, verification results of each round, correction scripts of each round, final authorization result, and descriptions of non-equivalent items by migration task identifier to form a permission migration evidence chain.
[0014] Secondly, embodiments of this application also provide an apparatus, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: construct a source-side permission semantic graph based on permission metadata in a source database, and configure target-side permission capabilities based on the target database type and version to construct a target-side capability constraint graph; generate a permission behavior verification matrix based on the source-side permission semantic graph and the migration object scope; generate target-side candidate authorization scripts based on the source-side permission semantic graph and the target-side capability constraint graph, and generate target-side authorization statements for permissions that can be equivalently mapped, and generate candidate authorization scripts for permissions that cannot be completely equivalently mapped; execute the candidate authorization scripts in the target database, and switch user or role contexts and execute verification SQL based on the permission behavior verification matrix to record the verification execution results; and generate a minimum authorization correction script constrained by allowing all passes in the matrix and rejecting all rejections in the matrix based on the verification execution results, and re-execute the verification logic until the permission behavior verification results converge to obtain a permission migration evidence chain.
[0015] Thirdly, embodiments of this application also provide a non-volatile computer storage medium storing computer-executable instructions, which are configured to: construct a source-side permission semantic graph based on permission metadata in the source database, and configure target-side permission capabilities based on the target database type and version to construct a target-side capability constraint graph; generate a permission behavior verification matrix based on the source-side permission semantic graph and the migration object scope; generate target-side candidate authorization scripts based on the source-side permission semantic graph and the target-side capability constraint graph, and generate target-side authorization statements for permissions that can be equivalently mapped, and generate candidate authorization scripts for permissions that cannot be completely equivalently mapped; execute the candidate authorization scripts in the target database, and switch user or role contexts and execute verification SQL based on the permission behavior verification matrix to record the verification execution results; and generate a minimum authorization correction script with constraints of allowing all passes in the allow matrix and rejecting all rejections in the reject matrix based on the verification execution results, and re-execute the verification logic until the permission behavior verification results converge to obtain a permission migration evidence chain.
[0016] This application provides a heterogeneous database migration permission verification and correction method, device, and medium, which has the following beneficial effects: By constructing a source-side permission semantic graph and a target-side capability constraint graph, heterogeneous database permission modeling is completed, moving beyond simple authorization statement mapping tables. This allows for the complete inclusion of multi-dimensional permission metadata, including source database users, roles, various permissions, object dependencies, authorization chains, and row-level security policies. A permission behavior verification matrix containing allowed and denied behaviors is generated based on the migration object scope, simultaneously identifying two types of problems: permission loss and permission amplification. This overcomes the shortcomings of traditional solutions, which lack reverse denial verification and are prone to privilege escalation vulnerabilities. Based on the source-side permission semantic graph and the target-side capability constraint graph, candidate authorization scripts for the target side are generated. Authorization statements can be directly generated for equivalent permissions, and multiple candidate alternatives are output for permissions that cannot be fully mapped. A minimum authorization correction script is generated with all allowed permissions passing and all denied permissions passing as hard constraints. This effectively improves the security and reliability of heterogeneous database permission migration, ensuring that the actual permission behavior of the target database remains consistent with that of the source database after migration. Attached Figure Description
[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 A flowchart of a heterogeneous database migration permission verification and correction method provided in this application embodiment; Figure 2 This is a schematic diagram of the internal structure of a heterogeneous database migration permission verification and correction device provided in an embodiment of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] This application provides a heterogeneous database migration permission verification and correction method, device and medium to solve the following technical problem: how to verify whether the permission behavior of the target end is consistent with that of the source end through bidirectional verification of allow and deny behaviors, and generate a minimum authorization correction scheme that satisfies that allowed items are executable, denied items are not executable and the authorization set is as small as possible, thereby forming an auditable, verifiable and rollbackable permission migration evidence chain.
[0020] The technical solutions proposed in the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0021] Figure 1 This document provides a flowchart of a heterogeneous database migration permission verification and correction method as an embodiment of this application. Figure 1 As shown in the figure, the heterogeneous database migration permission verification and correction method provided in this application embodiment specifically includes the following steps: Step 10: Based on the permission metadata in the source database, construct the source permission semantic graph, and configure the target permission capabilities based on the target library type and version to construct the target capability constraint graph.
[0022] As an optional embodiment, a source-side permission semantic graph is constructed based on the permission metadata in the source database, and the target-side permission capabilities are configured based on the target database type and version to construct a target-side capability constraint graph. Specifically, it may include: Step 101: Based on the user information, role information, column information, row-level security policy information and operation type in the permission metadata, user nodes, role nodes, column nodes, policy nodes and object nodes are generated based on table, view, function, stored procedure or synonym information.
[0023] In this step, after extracting the permission metadata from the source database, user information, role information, column information, row-level security policy information, and operation type information are extracted from the metadata. Based on this, corresponding user nodes, role nodes, column nodes, and policy nodes are constructed. Simultaneously, information related to tables, views, functions, stored procedures, and synonyms is further extracted to generate object nodes. These various nodes collectively constitute the node elements of the source-side permission semantic graph, with different nodes carrying the basic attribute information of their corresponding entities. Building upon this, various edges of the semantic graph are constructed through the relationships recorded in the permission metadata, such as role inheritance, authorization allocation, object dependency, sub-authorization, and policy constraints. Different edges record... The association features such as permission type, target object, scope of effect, conditions for effectiveness, and sub-authorization attributes link the independent nodes together to form a complete source-end permission semantic graph. This semantic graph can fully depict the complex permission logic and dependencies between users, roles, database objects, columns, access policies, and operation behaviors within the source database. It organizes the scattered permission metadata into a structured semantic model, providing a complete source-end permission logic basis for subsequent equivalence judgment and generation of permission behavior verification matrix in combination with the target-end permission capabilities. It gets rid of the limitation of relying solely on scattered authorization statements for migration and transformation, and facilitates the complete identification of various implicit permission logics, including object dependencies, policy constraints, and authorization chains.
[0024] Step 102: Generate role inheritance edges, authorization edges, and sub-authorization edges based on the granting relationship, permission granting relationship, and sub-authorization relationship between roles, respectively. Generate dependency edges based on the reference relationship from synonyms to base tables, views to base tables, and functions or stored procedures to dependent objects. Generate policy constraint edges based on the constraint relationship between row-level security policies and objects, users, or roles.
[0025] In this step, after constructing the various nodes of the source-side permission semantic graph, role inheritance edges are generated based on the granting relationships between roles recorded in the source database permission metadata. These edges represent the inheritance and subordination logic between different roles. Authorization edges are generated based on the permission granting relationships in the metadata. These authorization edges fully record attributes such as permission type, target object, scope, effective conditions, and whether sub-authorization is supported, reflecting the permission granting logic between users, roles, and various database objects. Sub-authorization edges are then generated based on the sub-authorization relationships recorded in the metadata to depict the authorization chain relationship where permissions can be granted a second time. Simultaneously, the reference relationships between various objects within the database are analyzed, and dependency edges are generated based on the reference relationships between synonyms pointing to base tables, views pointing to base tables, and functions or stored procedures pointing to their dependent objects. These edges represent the different relationships between different database objects. This model incorporates the underlying dependencies between database objects, including the implicit access dependencies of views, functions, and other objects, into a semantic graph model. Furthermore, it combines row-level security policies with constraints between corresponding objects, users, or roles to generate policy constraint edges. These edges represent the access restrictions imposed by row-level security policies on specific subjects accessing corresponding database objects. By connecting the various independent nodes in the semantic graph through these edges, the model fully reproduces the inherent logic of role inheritance, permission allocation, permission transfer, object dependencies, and row-level access constraints in the source database. This integrates scattered permission and object information into a unified semantic model, capturing implicit dependencies and constraints that cannot be directly reflected in authorization statements. This provides a complete and comprehensive source-end permission logic foundation for subsequent permission equivalence judgments and the construction of permission behavior verification matrices.
[0026] Step 103: Associate and store user nodes, role nodes, object nodes, column nodes, policy nodes, operation nodes, as well as role inheritance edges, authorization edges, dependency edges, sub-authorization edges, and policy constraint edges according to the migration task identifier to generate the source permission semantic graph.
[0027] In this step, the constructed user nodes, role nodes, object nodes, column nodes, policy nodes, and operation nodes, along with role inheritance edges, authorization edges, dependency edges, sub-authorization edges, and policy constraint edges, are uniformly assigned to the corresponding migration task identifiers for associated storage, thus forming a source-side permission semantic graph. Each node carries the basic information of its corresponding entity, while various edges record the associated parties and their relationship attributes, such as permission type, scope, effective conditions, sub-authorization attributes, object reference relationships, and access constraints. The migration task identifier binds and distinguishes all nodes and edges belonging to the same migration project, preventing data confusion between different migration tasks. This semantic graph structurally organizes the scattered users, roles, database objects, columns, access policies, operation behaviors, and the complex permission logic such as inheritance, authorization, permission transfer, object dependencies, and access constraints in the source database. It not only records explicit authorization information but also captures various implicit permissions and object dependencies that are not easily reflected in the authorization script, providing a complete and unified source-side permission logic model to support subsequent construction of the target-side capability constraint graph, generation of permission behavior verification matrices, and performance of permission equivalence analysis.
[0028] Step 104: Read the type and version information of the target database, and based on the type and version information, query the target database's permission dictionary, role definition rules, authorization syntax rules, and security policy configuration rules to obtain the target's permission capabilities.
[0029] In this step, the type and version information of the target database to be migrated are read. Based on this, the permission dictionary, role definition rules, authorization syntax rules, and security policy configuration rules of the database are queried to obtain the complete target-side permission capabilities. This process will sort out the scope of permission granularity natively supported by the target database, the role inheritance implementation method, and identify whether it supports column-level authorization, row-level security policies, view authorization, function execution authorization, and sub-authorization capabilities. At the same time, the default role rules of the target database and the list of permissions that cannot be equivalently expressed are compiled. By parsing the above rule information, the boundaries of the permission expression capabilities that the target database can achieve can be clarified. This allows us to determine whether various permissions on the source side can be directly equivalently mapped in the target environment, whether permission splitting is required, whether the scope of permissions will be expanded or narrowed, or whether the permission effect needs to be indirectly achieved through substitution mechanisms. This provides an objective basis for the subsequent construction of the target-side capability constraint diagram, analysis of heterogeneous permission differences, and generation of candidate authorization scripts.
[0030] Step 105: Associate and store the target end permissions and capabilities according to the migration task identifier, generate a target end capability constraint graph, and match the source end permissions with the target end permissions and capabilities item by item based on the target end capability constraint graph to determine the expression type of the source end permissions on the target end and record the matching results.
[0031] In this step, the acquired target-side permissions and capabilities are associated and stored according to the corresponding migration task identifiers, thereby generating a target-side capability constraint graph. The migration task identifiers are used to bind the target-side capability data and the source-side permission semantic graph data under the same migration task. Through this target-side capability constraint graph, each source-side permission carried by the source-side permission semantic graph is matched and compared with the target-side permissions and capabilities. This determines the expression type of each source-side permission in the target database environment, distinguishing between situations where it can be directly equivalently expressed, requires splitting for equivalence, requires substitution for equivalence, and cannot achieve equivalence. The matching results for each permission are fully recorded. These matching results reflect various situations that may occur when the source-side permissions are implemented in the target database, such as expansion or reduction of the permission scope. It clarifies that some permissions require substitution mechanisms for implementation, providing a basis for subsequent generation of target-side candidate authorization scripts and design of candidate substitution schemes for non-equivalent permissions, avoiding judgment biases caused by relying solely on simple permission mapping tables.
[0032] Step 20: Generate a permission behavior verification matrix based on the source permission semantic graph and the scope of the migrated object.
[0033] As an optional embodiment, generating a permission behavior verification matrix based on the source permission semantic graph and the scope of the migration object can specifically include: Step 201: Based on the scope of the migration object, select the corresponding object node, column node, policy node and operation node from the source permission semantic graph, and traverse the authorization edge, role inheritance edge, dependency edge, sub-authorization edge and policy constraint edge in the source permission semantic graph to determine the authorized user or role and the operation allowed to be executed, the object, column and condition of the operation.
[0034] In this step, based on the established scope of migration objects, matching object nodes, column nodes, policy nodes, and operation nodes are selected from the source permission semantic graph. Then, the authorization edges, role inheritance edges, dependency edges, sub-authorization edges, and policy constraint edges within the source permission semantic graph are traversed. Link analysis is performed along the relationships represented by each type of edge to identify the corresponding authorized user or role subject. At the same time, the various operations that the subject is allowed to perform, as well as the objects, columns, and access conditions to be affected by the corresponding operations are determined. Through the traversal and analysis of nodes and related edges, it is possible to penetrate multiple layers of logic such as role inheritance, permission sub-authorization, object dependency, and row-level policy constraints, and to uncover the actual access capabilities that take effect after permission transfer. It is also possible to identify the underlying object access dependencies hidden behind objects such as views and stored procedures, and to fully identify the actual effective permission behaviors in the source environment, rather than being limited to the surface-level authorization statements. This provides the basic material for extracting foundational materials for the subsequent construction of a permission behavior verification matrix that includes allow and deny behaviors.
[0035] Step 202: Generate an allowance matrix based on the authorized user or role, the allowed operations, the objects affected by the operations, the columns, and the conditions.
[0036] In this step, the operations that authorized users or roles and subjects are allowed to perform, along with the corresponding target objects, columns, and access conditions, are parsed as input to generate permission matrix items. Each permission matrix item encapsulates the permission subject, operation behavior, target object, and constraints to form verifiable entries. These entries represent various business operations that should be permitted in the source database environment, including various data operations on data tables, view access, function and stored procedure calls, etc. Each permission matrix item specifies the expected result and generates corresponding verification SQL that can be executed in the target database. This is used to verify whether the corresponding operations can be executed normally in the target environment, thereby identifying potential permission gaps after migration. It is a core component of the permission behavior verification matrix used to verify positive access capabilities, providing a positive verification benchmark for subsequent bidirectional permission behavior verification.
[0037] Step 203: Based on the objects and columns not covered by the unauthorized edges in the source permission semantic graph, the scope restricted by the policy constraint edges, the view-to-base table access boundary implied by the dependency edges, and the sub-authorization capabilities restricted by the sub-authorization edges, determine the operations that unauthorized users or roles should not perform and generate a denial matrix item.
[0038] In this step, reverse analysis is performed based on the source-side permission semantic graph. Objects and columns not covered by authorized edges in the semantic graph are selected. Combined with the access restriction range defined by policy constraint edges, and referring to the access boundary between the view and the base table reflected by dependency edges, as well as the constraints formed by the sub-authorization edges on sub-authorization capabilities, various operations that unauthorized users or roles should not perform in the source database environment are comprehensively determined. Based on this, a denial matrix item is generated. The denial matrix item records the corresponding user or role, operation type, objects involved in the operation, columns, and related conditions, and configures the corresponding expected denial result and matching verification SQL. This type of matrix item covers scenarios such as unauthorized object access, unauthorized column modification, bypassing the view to directly access the underlying base table, data access exceeding row-level policy constraints, and sub-authorization behavior exceeding the limit. It serves as the reverse verification benchmark for the permission behavior verification matrix, used to detect the risk of permission amplification and unauthorized access after the target database migration, realizing the verification of prohibited behaviors on the source side and making up for the verification blind spots caused by only verifying allowed operations.
[0039] Step 204: Associate and store the allow and deny matrix items by migration task identifier to generate a permission behavior verification matrix.
[0040] In this step, all generated allow and deny matrix items are associated and stored using their corresponding migration task identifiers, thus constructing a permission behavior verification matrix. Using migration task identifiers, forward and reverse verification entries under the same migration project are bound together, isolating verification data from different migration tasks. This permission behavior verification matrix comprehensively gathers all behaviors that should be allowed and denied execution corresponding to the source permissions. Each entry in the matrix includes user or role, operation type, database object, column, condition, expected result, and corresponding verification SQL, used to detect permission deficiencies and privilege escalation issues on the target side. This provides a unified and structured verification dataset for subsequent bidirectional permission behavior verification in the target database or sandbox environment, realizing the transformation from static authorization information to executable behavior verification test cases.
[0041] Step 30: Generate target-side candidate authorization scripts based on the source-side permission semantic graph and the target-side capability constraint graph, and generate target-side authorization statements for permissions that can be equivalently mapped, and generate candidate authorization scripts for permissions that cannot be completely equivalently mapped.
[0042] As an optional embodiment, a target-side candidate authorization script is generated based on the source-side permission semantic graph and the target-side capability constraint graph. For permissions that can be equivalently mapped, a target-side authorization statement is generated, and for permissions that cannot be completely equivalently mapped, a candidate authorization script is generated. Specifically, it may include: Step 301: When the expression type is direct expression, a target-side authorization statement corresponding to the source-side permission is generated based on the permission type, target object, scope, effective conditions, and whether sub-authorization is allowed in the authorization edge.
[0043] In this step, when the expression type obtained by matching the source-end permissions is a direct expression, the permissions type, target object, scope, effective conditions, and whether sub-delegation is allowed are read from the authorization edge. Combined with the syntax rules of the target database, the target-end authorization statement corresponding to the source-end permissions is generated. This process fully inherits the various permission attributes carried by the source-end authorization edge, transforms the source-end permission semantics into authorization syntax that the target database can recognize and execute, and ensures that the granting subject, the granted subject, the permission carrier, the permission effective constraints, and the sub-delegation capability all correspond to the source end. No additional alternative processing logic is needed, thus obtaining an authorization statement that can be directly applied to the target end, which serves as a component of the target-end candidate authorization script.
[0044] Step 302: When the expression type is split expression, based on the split mapping relationship recorded in the target end capability constraint diagram, the source end permission is split into several target end permissions, and target end authorization statements corresponding to the several target end permissions are generated respectively.
[0045] In this step, when the expression type obtained by matching the source-end permissions is a split expression, the split mapping relationship stored in the target-end capability constraint diagram is retrieved. Based on this mapping relationship, the single permission of the source end is decomposed into multiple mutually cooperating target-end permissions. Then, for each target-end permission obtained after splitting, a corresponding target-end authorization statement is generated. This processing method is suitable for scenarios where the target database cannot fully reproduce the semantics of the source-end permissions using a single authorization syntax. By combining multiple permissions, the original permission effect of the source end is restored. The authorization statements generated by the splitting together constitute part of the candidate authorization script, thereby restoring the permission logic of the source end as much as possible within the capability boundary of the target database and avoiding the semantic distortion problem of directly copying the source end authorization.
[0046] Step 303: When the expression type is substitution expression, generate candidate substitution authorization scripts based on the substitution mapping relationship recorded in the target capability constraint graph.
[0047] In this step, when the expression type obtained by matching the source-end permissions is a substitute expression, the substitute mapping relationship recorded in the target-end capability constraint diagram is retrieved. Combined with the permission implementation methods available in the target database, a candidate substitute authorization script is generated. This type of substitute mapping relationship includes multiple implementation methods. Depending on the actual situation, different implementation methods such as column-level authorization, restricted views, row-level security policies, and role splitting can be selected to indirectly reproduce the permission effect of the source end, avoiding the risk of permission amplification caused by directly using a wider range of authorizations. Permissions that cannot be automatically processed will also be marked as manual confirmation items. The generated candidate substitute authorization script, as a component of the target-end candidate authorization script, is used to provide a feasible permission implementation scheme in scenarios where the target database capabilities cannot directly and equivalently restore the semantics of the source end permissions, providing an authorization basis to be verified for subsequent behavior verification.
[0048] Step 304: When the expression type is non-equivalent, generate a manual confirmation item and record the reason for the non-equivalence of the source permissions; associate and store the target authorization statement, candidate alternative authorization script and manual confirmation item according to the migration task identifier to generate the target candidate authorization script.
[0049] In this step, when the expression type obtained by matching the source permission is not equivalent, a corresponding manual confirmation item is generated. At the same time, the specific reason why the source permission cannot achieve an equivalent expression is recorded and handed over to the subsequent management personnel for evaluation and handling. Then, the target authorization statement, candidate alternative authorization script and manual confirmation item output by the above process are associated and stored according to the corresponding migration task identifier, and integrated to form the target candidate authorization script. This candidate authorization script gathers various authorization contents obtained by direct mapping, split mapping and alternative mapping, and also includes permission marking information that cannot be automatically processed. It realizes the collection of all permission processing schemes under the same migration task. It includes both authorization contents that can be directly executed in the target database and permission entries that require manual intervention and judgment, providing complete authorization input to be executed for subsequent permission behavior verification in the target database or sandbox environment.
[0050] Step 40: Execute the candidate authorization script in the target database, switch the user or role context based on the permission behavior verification matrix and execute the verification SQL, and record the verification execution results.
[0051] As an optional embodiment, the candidate authorization script is executed in the target database, and the user or role context is switched and the verification SQL is executed based on the permission behavior verification matrix to record the verification execution result. Specifically, it may include: Step 401: Execute the candidate authorization script in the target database to make the target authorization statement, candidate alternative authorization script and manual confirmation item in the candidate authorization script effective in the target database.
[0052] In this step, candidate authorization scripts are executed in the target database or target sandbox environment. During execution, the target-side authorization statements and candidate alternative authorization scripts contained in the scripts are deployed and executed, so that the corresponding permission configurations, role configurations, and security policy configurations take effect in the target database environment. The manual confirmation items in the scripts are not executed directly in the database, but are only stored as marker information to be manually processed. After the candidate authorization scripts are executed, the target database loads the candidate permission configurations corresponding to this migration, forming a permission environment to be verified. This lays the actual operational foundation for subsequent switching of different user or role contexts and running the verification SQL in the permission behavior verification matrix to perform permission behavior verification.
[0053] Step 402: Traverse the allowed and denied matrix items in the permission behavior verification matrix, obtain the user or role, operation type, database object, column, condition, expected result and verification SQL corresponding to the current verification item, and switch the current execution context of the target database to the corresponding user or role based on the user or role corresponding to the current verification item.
[0054] In this step, the allowed and denied matrix items within the permission behavior verification matrix are traversed. Each item is used to extract the user or role, operation type, database object, column, condition, expected result, and verification SQL corresponding to the current verification item. Based on the user or role associated with the current verification item, the execution context of the target database is switched to that corresponding user or role. Through context switching, the identity environment of the permission subject in a real business scenario is simulated. This ensures that when the verification SQL is executed subsequently, all permissions, role inheritance relationships, and security policy constraints already obtained by the user or role in the target database can be fully reused, restoring the actual operating environment when the subject accesses the database. This ensures that the subsequent verification results accurately reflect the actual permission behavior of the user or role in the target database.
[0055] Step 403: Execute the verification SQL corresponding to the current verification item in the switched execution context, and capture the execution status, error code, number of affected rows, set of returned columns, range of returned rows and permission exception information of the verification SQL to obtain the verification execution result.
[0056] In this step, within the already switched execution context, the verification SQL corresponding to the current verification item is run. Simultaneously, various runtime information corresponding to this verification SQL is captured, including execution status, error codes, number of affected rows, set of returned columns, range of returned rows, and permission exception information, thus obtaining a complete verification execution result. By collecting multi-dimensional runtime information, it goes beyond simply determining whether the SQL execution was successful or failed. It can also identify permission granularity amplification issues caused by inconsistencies between the returned column set and the returned row range and the source's expectations, as well as various permission-related anomalies. This objectively reconstructs the target database's true access behavior under the user or role context, providing original factual evidence for subsequent identification of various permission issues such as lack of privileges, excessive privileges, missing dependent authorizations, and inconsistent authorization chains.
[0057] Step 404: Compare the captured execution status with the expected result in the current verification item.
[0058] Step 405: If the current verification item belongs to the allowed matrix item and the execution fails, it is recorded as an unweighted problem; if the current verification item belongs to the rejected matrix item and the execution succeeds, it is recorded as an overweighted problem.
[0059] In this step, the captured execution status is compared and analyzed with the pre-set expected result of the current verification item. If the current verification item is an allowed item in the matrix, the corresponding business behavior should be able to execute normally, but it actually fails. This situation is marked as a lack of permissions, indicating that the target database lacks the necessary permissions to complete the corresponding business operation. If the current verification item is a denied item in the matrix, the operation should be blocked and denied according to the source permission logic, but it actually executes successfully. This situation is marked as an excessive permissions issue, indicating that the target database has a risk of privilege amplification or unauthorized access. By comparing the actual execution status with the expected result, two typical permission defects are distinguished, clarifying the problem type for the subsequent generation of the minimum authorization correction script. This is the core judgment logic for identifying permission defects.
[0060] Step 406: When the current verification item belongs to the allowed matrix item and the execution is successful but the returned column set or returned row range exceeds the source end expectation, it is recorded as a permission granularity amplification problem. When the current verification item involves a function, view or synonym and the execution fails due to the lack of permissions of the dependent object, it is recorded as a dependency authorization missing problem.
[0061] In this step, if the current verification item belongs to the allowed matrix item, although the verification SQL executes successfully, but the actual returned column set or returned row range exceeds the expected range set by the source, this phenomenon is recorded as a permission granularity amplification problem. This indicates that although the target end can complete the corresponding operation, its accessible data range has expanded compared to the source end, posing a potential privilege escalation risk. When the operation object of the verification item involves functions, views, or synonyms, and the root cause of the execution failure is insufficient permissions of its underlying dependent objects, this failure is recorded as a dependency authorization missing problem. This type of problem is not due to the operation subject itself directly lacking object permissions, but rather because the underlying objects on which the upper-level database objects depend have not been configured with corresponding access permissions, thus preventing the upper-level objects from being called normally. By identifying this type of scenario separately, we can capture implicit permission failures that are not directly reflected in the authorization edge, providing corresponding problem classification criteria for the subsequent generation of minimum authorization correction scripts.
[0062] Step 407: When the current verification item involves a sub-authorization operation and the execution result is inconsistent with the source end's expectation, it is recorded as an authorization chain inconsistency problem.
[0063] In this step, if the operation corresponding to the current verification item is a sub-authorization related operation, the actual verification execution result is compared with the expected result preset on the source end. When the two do not match, the situation is recorded as an authorization chain inconsistency problem. This problem indicates that there is a deviation between the permission sub-authorization and transfer capability of the target database and the authorization chain logic of the source database after migration. It reflects that the transfer rules related to role inheritance and secondary authorization of permissions have changed during the heterogeneous migration process. This type of problem is classified and recorded independently from ordinary lack of permissions and excessive permissions problems, providing clear problem input for the subsequent minimum authorization correction step to handle the differences in the permission transfer chain.
[0064] Step 408: Associate and store the execution status, error code, number of affected rows, set of returned columns, range of returned rows, permission exception information, and recorded issues such as lack of permissions, excessive permissions, amplified permission granularity, missing dependent authorization, and inconsistent authorization chain for each verification item according to the migration task identifier, so as to generate the verification execution result.
[0065] In this step, the execution status, error code, number of affected rows, set of returned columns, range of returned rows, and permission exception information corresponding to each verification item, as well as the identified and recorded issues such as lack of permissions, excessive permissions, amplified permission granularity, missing dependent authorization, and inconsistent authorization chains, are associated, collected, and stored according to the corresponding migration task identifier to generate a complete verification execution result. Data ownership is bound using the migration task identifier to ensure that verification data from different migration tasks are isolated from each other. This verification execution result completely retains the original running data and various identified permission defects during this round of permission verification, fully recording the various differences between the target-side permission behavior and the source-side expectations. This provides a comprehensive original problem dataset for subsequently generating a minimum authorization correction script with all allowed matrices passing and all denied matrices rejecting as constraints.
[0066] Step 50: Based on the verification execution results, generate a minimal authorization correction script with constraints of allowing all matrices to pass and rejecting all matrices to reject, and re-execute the verification logic until the permission behavior verification results converge to obtain the permission migration evidence chain.
[0067] As an optional embodiment, based on the verification execution result, a minimal authorization correction script is generated with the constraint that all matrices are allowed to pass and all matrices are rejected. The verification logic is re-executed until the permission behavior verification result converges to obtain the permission migration evidence chain. Specifically, it may include: Step 501: Based on the verification execution result, the corresponding correction statement is generated and the correction statement is combined.
[0068] In this step, corresponding correction statements are generated by verifying the execution results, and various correction statements are combined. For permission deficiency issues, correction statements are generated to supplement the corresponding permissions on the target end. For permission overreach issues, correction statements are generated to revoke redundant permissions or split roles. For permission granularity amplification issues, correction statements are generated to shrink database-level or table-level authorization to object-level, column-level, view-level, or policy-level authorization. For scenarios where row-level restrictions are missing in permission granularity amplification issues, correction statements are generated to configure row-level security policies or build restricted views. For dependency authorization deficiency issues, correction statements are generated to supplement the minimum execution permissions or access permissions of dependent objects. The combined correction statements constitute the authorization adjustment scheme for this round, aiming to eliminate the identified permission differences. The minimum scope of permission adjustment methods is prioritized to avoid introducing new permission overreach risks during the correction process. This serves as the content of the minimum authorization correction script, used to update the permission configuration in the target database, providing an adjusted permission environment for the next round of permission behavior verification.
[0069] Step 502: Under the constraints of allowing all matrices to pass and rejecting all matrices to reject, generate a minimum authorization correction script according to the preset priority order of authorization scope, authorization object scope, validity period and sub-authorization capability.
[0070] In this step, under the constraints of allowing all matrices to pass and rejecting all matrices to reject, a minimum authorization correction script is generated according to the preset priority order of authorization scope, authorized object scope, validity period, and sub-authorization capability. This generation logic takes ensuring that all positive verification test cases can be executed normally and all reverse verification test cases can be successfully intercepted as a hard premise. Then, according to the predetermined priority, the optional permission adjustment schemes are screened and selected. The scheme with a smaller authorization scope is selected first, followed by narrowing the coverage of authorized objects, and then the permission validity period and sub-authorization capability are considered. Among the many feasible schemes that can meet the verification constraints, the scheme with the most convergent permission boundary is selected, thus obtaining the minimum authorization correction script. This script ensures that the permission behavior is consistent with the source end, avoids configuring access capabilities beyond the business needs, and prevents security risks caused by permission redundancy. Applying this script to the target database can complete the iterative correction of the permission configuration in this round, and prepare the adjusted permission environment for the next permission behavior verification.
[0071] Step 503: Execute the minimum authorization correction script in the target database and re-execute the permission behavior verification matrix to obtain new verification execution results.
[0072] In this step, the minimum authorization correction script is executed in the target database to complete the iterative update of the target database permission configuration. Then, the permission behavior verification matrix is re-executed, traversing all allowed and denied matrix items in the matrix, switching the corresponding user or role context to run the verification SQL, and capturing the running information corresponding to each verification to obtain the execution results of a new round of verification. This process puts the corrected permission configuration into actual verification, objectively evaluates whether this round of permission adjustment has eliminated the various permission defects previously identified, and judges whether the current target-side permission behavior is consistent with the source-side expectation. This serves as the basis for judging whether to continue iterative correction and continuously promote the permission convergence process.
[0073] Step 504: If the new verification execution results still contain issues such as lack of privileges, excessive privileges, amplified permission granularity, missing dependent authorizations, or inconsistent authorization chains, then regenerate the minimum authorization correction script until the permission behavior verification results converge.
[0074] In this step, if the verification results obtained in the new round still contain issues such as lack of privileges, excessive privileges, amplified permission granularity, missing dependent authorizations, or inconsistent authorization chains, then a minimum authorization correction script is regenerated based on the various permission defects newly identified in this round. The permission configuration of the target database is iteratively adjusted, and the complete process of permission behavior verification is repeated. This iterative process continues to cycle, constantly correcting the permission configuration of the target end and verifying permission behavior until the permission behavior verification results converge, that is, no longer detecting the aforementioned permission defects, and both the allow and deny matrices meet the expected verification results. At this point, the permission behavior of the target database is consistent with the permission behavior of the source end, and the iterative correction process is terminated. This closed-loop iterative mechanism can gradually eliminate various permission differences generated during the migration of heterogeneous databases, ensuring that the final permission configuration meets the principle of least privilege.
[0075] Step 505: Save the source permission snapshot, target capability constraint graph, permission behavior verification matrix, candidate authorization script, verification results for each round, correction script for each round, final authorization result, and description of non-equivalent items by the migration task identifier to form a permission migration evidence chain.
[0076] In this step, the source-side permission snapshot, target-side capability constraint diagram, permission behavior verification matrix, candidate authorization scripts, verification results for each round, correction scripts for each round, final authorization results, and explanations of non-equivalent items are associated and saved according to the corresponding migration task identifiers, thus forming a complete permission migration evidence chain. This evidence chain integrates all process data under the same migration task, including permission modeling, capability assessment, verification test case construction, script generation, iterative verification, and correction. It completely retains all intermediate products and final outputs in the heterogeneous database permission migration process, allowing for the retrospective analysis of each step of permission determination, each round of permission defects, and corresponding correction schemes. For non-equivalent permission items, the differences are synchronously retained, making the entire permission migration process auditable, verifiable, and traceable. In the event of permission disputes or when security audits are required, the entire process of permission mapping and verification iterations can be completely reproduced.
[0077] The above are embodiments of the method proposed in this application. Based on the same inventive concept, embodiments of this application also provide a heterogeneous database migration permission verification and correction device, the structure of which is as follows: Figure 2 As shown.
[0078] Figure 2 This is a schematic diagram of the internal structure of a heterogeneous database migration permission verification and correction device provided in an embodiment of this application. Figure 2 As shown, the device includes: At least one processor 201; And a memory 202 that is communicatively connected to at least one processor; The memory 202 stores instructions executable by at least one processor. These instructions are executed by at least one processor 201 to enable the processor 201 to: construct a source-side permission semantic graph based on permission metadata in the source database, and configure target-side permission capabilities based on the target database type and version to construct a target-side capability constraint graph; generate a permission behavior verification matrix based on the source-side permission semantic graph and the migration object scope; generate target-side candidate authorization scripts based on the source-side permission semantic graph and the target-side capability constraint graph, and generate target-side authorization statements for permissions that can be equivalently mapped, and generate candidate authorization scripts for permissions that cannot be completely equivalently mapped; execute the candidate authorization scripts in the target database, and switch user or role contexts and execute verification SQL based on the permission behavior verification matrix to record the verification execution results; and generate a minimum authorization correction script based on the verification execution results, constrained by allowing all passes in the matrix and rejecting all rejections in the matrix, and re-execute the verification logic until the permission behavior verification results converge to obtain a permission migration evidence chain.
[0079] Some embodiments of this application provide corresponding to Figure 1A non-volatile computer storage medium for heterogeneous database migration permission verification and correction stores computer-executable instructions. These instructions are configured as follows: Based on permission metadata in the source database, construct a source-side permission semantic graph and configure target-side permission capabilities based on the target database type and version to construct a target-side capability constraint graph; generate a permission behavior verification matrix based on the source-side permission semantic graph and the migration object scope; generate target-side candidate authorization scripts based on the source-side permission semantic graph and the target-side capability constraint graph, generating target-side authorization statements for permissions that can be equivalently mapped, and generating candidate authorization scripts for permissions that cannot be completely equivalently mapped; execute the candidate authorization scripts in the target database, and switch user or role contexts based on the permission behavior verification matrix and execute verification SQL to record the verification execution results; based on the verification execution results, generate a minimal authorization correction script constrained by allowing all passes in the matrix and rejecting all rejections in the matrix, and re-execute the verification logic until the permission behavior verification results converge to obtain a permission migration evidence chain.
[0080] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments for IoT devices and media are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0081] The systems, media, and methods provided in this application are one-to-one correspondences. Therefore, the systems and media also have similar beneficial technical effects as their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the systems and media will not be repeated here.
[0082] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0083] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0084] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0085] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0086] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0087] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0088] Computer-readable media include both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0089] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0090] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for correcting permissions during heterogeneous database migration, characterized in that, The method includes: Based on the permission metadata in the source database, a source-side permission semantic graph is constructed, and the target-side permission capabilities are configured based on the target database type and version to construct a target-side capability constraint graph. The permission metadata includes user, role, inheritance, system, object, schema, table, column, view, function permissions, sub-authorization, dependency, row-level policy, and default permissions. The nodes in the source-side permission semantic graph include user nodes, role nodes, object nodes, column nodes, policy nodes, and operation nodes, and the edges include role inheritance edges, authorization edges, dependency edges, sub-authorization edges, and policy constraint edges. Based on the source-side permission semantic graph and the scope of the migration object, a permission behavior verification matrix is generated. The permission behavior verification matrix includes an allow matrix and a deny matrix. The allow matrix is used to record the query, update, delete, execute, and access operations that authorized users on the source side should perform, as well as the verification SQL and the expected allowed results. The deny matrix is used to record the access to unauthorized tables, updates to unauthorized columns, bypassing views, accessing data outside the row-level policy, and sub-authorization operations that unauthorized users on the source side should not perform, as well as the expected deny results. Based on the source-side permission semantic graph and the target-side capability constraint graph, a target-side candidate authorization script is generated. For permissions that can be equivalently mapped, a target-side authorization statement is generated, and for permissions that cannot be completely equivalently mapped, a candidate authorization script is generated. The candidate authorization script includes column-level authorization, restricted views, row-level security policies, role splitting, supplementary authorization for dependent objects, or manual confirmation items. The candidate authorization script is executed in the target database, and the user or role context is switched and the verification SQL is executed based on the permission behavior verification matrix to record the verification execution results; wherein, the verification execution results include error codes, number of affected rows, set of returned columns, range of returned rows and permission anomalies, and identify lack of permissions, excessive permissions, amplified granularity, missing dependent authorizations and inconsistent authorization chains; Based on the verification execution results, a minimal authorization correction script is generated with the constraints of allowing all matrices to pass and rejecting all matrices to reject. The verification logic is then re-executed until the permission behavior verification results converge, thereby obtaining the permission migration evidence chain.
2. The heterogeneous database migration permission verification and correction method according to claim 1, characterized in that, Based on the permission metadata in the source database, a source-side permission semantic graph is constructed, specifically including: User nodes, role nodes, column nodes, policy nodes, and object nodes are generated based on user information, role information, column information, row-level security policy information, and operation types in the permission metadata, and object nodes are generated based on table, view, function, stored procedure, or synonym information. Based on the granting relationship, permission granting relationship and sub-granting relationship between roles, role inheritance edge, authorization edge and sub-granting edge are generated respectively. Dependency edge is generated based on the reference relationship from synonym to base table, view to base table, function or stored procedure to dependent object. Policy constraint edge is generated based on the constraint relationship between row-level security policy and object, user or role. The user node, role node, object node, column node, policy node, operation node, as well as the role inheritance edge, authorization edge, dependency edge, sub-authorization edge, and policy constraint edge are associated and stored according to the migration task identifier to generate the source-end permission semantic graph.
3. The heterogeneous database migration permission verification and correction method according to claim 1, characterized in that, Configure target-side permissions and capabilities based on the target library type and version to construct a target-side capability constraint graph, specifically including: The target database's type and version information are read, and based on the type and version information, the target database's permission dictionary, role definition rules, authorization syntax rules, and security policy configuration rules are queried to obtain the target's permission capabilities. The target's permission capabilities include the granularity of permissions supported by the target, role inheritance methods, column-level authorization support, row-level security policy support, view authorization support, function execution authorization support, sub-authorization support, default role rules, and a list of non-equivalent permissions. The target-side permissions and capabilities are associated and stored according to the migration task identifier, a target-side capability constraint graph is generated, and based on the target-side capability constraint graph, the source-side permissions are matched with the target-side permissions and capabilities item by item to determine the expression type of the source-side permissions on the target side and the matching results are recorded; wherein, the expression type includes direct expression, split expression, substitution expression or non-equivalent expression.
4. The heterogeneous database migration permission verification and correction method according to claim 1, characterized in that, Based on the source-side permission semantic graph and the scope of the migrated object, a permission behavior verification matrix is generated, specifically including: Based on the scope of the migration objects, the corresponding object nodes, column nodes, policy nodes and operation nodes are selected from the source permission semantic graph, and the authorization edge, role inheritance edge, dependency edge, sub-authorization edge and policy constraint edge in the source permission semantic graph are traversed to determine the authorized user or role and the operation that is allowed to be executed, the object, column and condition that the operation is applied to; Based on the authorized user or role, the allowed operations, the objects affected by the operations, columns, and conditions, an allowance matrix is generated; wherein, the allowance matrix includes user or role, operation type, database object, columns, conditions, expected allowed result, and validation SQL; Based on the objects and columns not covered by the unauthorized edges in the source permission semantic graph, the scope restricted by the policy constraint edges, the view-to-base table access boundary implied by the dependency edges, and the sub-authorization capability restricted by the sub-authorization edges, the operations that unauthorized users or roles should not perform are determined and a rejection matrix item is generated; wherein, the rejection matrix item includes user or role, operation type, database object, column, condition, expected rejection result, and verification SQL; The allowed matrix items and the denied matrix items are associated and stored according to the migration task identifier to generate a permission behavior verification matrix.
5. The heterogeneous database migration permission verification and correction method according to claim 3, characterized in that, Based on the source-side permission semantic graph and the target-side capability constraint graph, candidate authorization scripts for the target side are generated. For permissions that can be equivalently mapped, target-side authorization statements are generated; for permissions that cannot be completely equivalently mapped, candidate authorization scripts are generated. Specifically, this includes: When the expression type is direct expression, based on the permission type, target object, scope, effective conditions and whether sub-delegation is allowed in the authorization edge, a target authorization statement corresponding to the source permission is generated; When the expression type is a split expression, based on the split mapping relationship recorded in the target end capability constraint diagram, the source end permission is split into several target end permissions, and target end authorization statements corresponding to the several target end permissions are generated respectively. When the expression type is an alternative expression, a candidate alternative authorization script is generated based on the alternative mapping relationship recorded in the target capability constraint diagram; wherein, the candidate alternative authorization script includes column-level authorization statements that split table-level permissions into column-level permissions, view definition statements that convert unexpressible row-level restrictions into restricted views or policy definition statements for row-level security policies, role creation and authorization statements that split excessive role permissions into multiple target roles, and dependency authorization supplement statements that supplement the view, function, or stored procedure dependent objects with object dependency permissions; When the expression type is a non-equivalent expression, a manual confirmation item is generated, and the reason for the non-equivalence of the source permission is recorded. The target authorization statement, the candidate alternative authorization script, and the manual confirmation item are associated and stored according to the migration task identifier to generate the target candidate authorization script.
6. The heterogeneous database migration permission verification and correction method according to claim 5, characterized in that, Execute the candidate authorization script in the target database, and switch the user or role context based on the permission behavior verification matrix and execute the verification SQL, specifically including: Execute the candidate authorization script in the target database to make the target-end authorization statement, the candidate alternative authorization script, and the manual confirmation item in the candidate authorization script effective in the target database. Traverse the allowed and denied matrix items in the permission behavior verification matrix to obtain the user or role, operation type, database object, column, condition, expected result and verification SQL corresponding to the current verification item, and switch the current execution context of the target database to the corresponding user or role based on the user or role corresponding to the current verification item. In the switched execution context, execute the verification SQL corresponding to the current verification item, and capture the execution status, error code, number of affected rows, set of returned columns, range of returned rows, and permission exception information of the verification SQL to obtain the verification execution result.
7. The heterogeneous database migration permission verification and correction method according to claim 6, characterized in that, After executing the validation SQL, the method further includes: The captured execution status is compared with the expected result in the current verification item; When the current verification item belongs to the allowed matrix item and the execution fails, it is recorded as an unweighted problem; when the current verification item belongs to the rejected matrix item and the execution succeeds, it is recorded as an overweighted problem. When the current verification item belongs to the allowed matrix item and is executed successfully but the returned column set or returned row range exceeds the source end expectation, it is recorded as a permission granularity amplification problem. When the current verification item involves a function, view or synonym and fails to execute due to the lack of permissions of the dependent object, it is recorded as a dependency authorization missing problem. When the current verification item involves a sub-authorization operation and the execution result is inconsistent with the source end's expectation, it is recorded as an authorization chain inconsistency problem; The execution status, error code, number of affected rows, set of returned columns, range of returned rows, permission exception information, and recorded issues such as lack of permissions, excessive permissions, amplified permission granularity, missing dependent authorization, and inconsistent authorization chains for each verification item are associated and stored according to the migration task identifier to generate verification execution results.
8. The heterogeneous database migration permission verification and correction method according to claim 7, characterized in that, Based on the verification execution results, a minimal authorization correction script is generated with the constraints of allowing all matrices to pass and rejecting all matrices to reject. The verification logic is then re-executed until the permission behavior verification results converge, thereby obtaining a permission migration evidence chain, specifically including: Based on the verification execution results, corresponding correction statements are generated and the correction statements are combined. Under the constraints that all allowed matrices pass and all rejected matrices reject, a minimum authorization correction script is generated according to the preset priority order of authorization scope, authorization object scope, validity period and sub-authorization capability; Execute the minimum authorization correction script in the target database and re-execute the permission behavior verification matrix to obtain new verification execution results; If the new verification execution results still contain issues such as lack of privileges, excessive privileges, amplified permission granularity, missing dependent authorizations, or inconsistent authorization chains, then the minimum authorization correction script will be regenerated until the permission behavior verification results converge. The source permission snapshot, the target capability constraint graph, the permission behavior verification matrix, the candidate authorization script, the verification results of each round, the correction script of each round, the final authorization result, and the description of non-equivalent items are associated and saved according to the migration task identifier to form a permission migration evidence chain.
9. A heterogeneous database migration permission verification and correction device, characterized in that, The device includes: At least one processor; And, a memory communicatively connected to the at least one processor; The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform a method as described in any one of claims 1-8.
10. A non-volatile computer storage medium for heterogeneous database migration permission verification and correction, storing computer-executable instructions, characterized in that, When the computer-executable instructions are executed, they implement a method as described in any one of claims 1-8.
