classPrivilegeChecks
final class PrivilegeChecks
Derives the facts of the privilege list, level and object of GRANT and REVOKE.
Rule: MYSQL-PRIVILEGE-CHECKS-001. A privilege fits a level as sql/auth/auth_acls.h and the server's GRANT path (sql_parse.cc, mysql_grant, mysql_table_grant, mysql_routine_grant) state: every static privilege fits the global level; a database takes DB_ACLS (ER_WRONG_USAGE otherwise), a table TABLE_ACLS and a routine PROC_ACLS (ER_ILLEGAL_GRANT_FOR_TABLE otherwise); a column list fits a table only (ER_ILLEGAL_GRANT_FOR_TABLE, or a syntax error after FUNCTION or PROCEDURE); FUNCTION and PROCEDURE need a routine name (ER_ILLEGAL_GRANT_FOR_TABLE); a dynamic privilege fits the global level only (ER_ILLEGAL_PRIVILEGE_LEVEL, a warning under REVOKE IF EXISTS). ALL fits every level. In a privilege list a role written with a host is a RoleOrPrivilegeMismatch; in a role list a static privilege or a dynamic privilege written with columns is one. The table of a level resolves by CORE-TABLE-LOOKUP-001 and contributes the slots of its declaration; a name a complete context does not declare is MissingTable for GRANT, except that GRANT of CREATE or ALL without column privileges and every REVOKE accept it as AbsentGrantTable. A column of a GRANT column privilege that the completely declared table does not have is UnknownGrantColumn. Precision: every slot of a declared table is a known type. Terminates: one pass over the privileges and the columns. Source: https://dev.mysql.com/doc/refman/8.4/en/grant.html, https://dev.mysql.com/doc/refman/8.4/en/revoke.html. Status: Implemented.
Methods§
public function grant(
Derivation $derivation,
list<Grantable> $privileges,
ObjectKind $kind,
PrivilegeLevel $level,
): voidDerives the facts of a GRANT of privileges.
Parameters
$derivation | Derivation | |
$privileges | list<Grantable> | |
$kind | ObjectKind | |
$level | PrivilegeLevel |
Called from 1
Calls 7
- method-call PrivilegeChecks::level() line 69
- class-const ObjectKind::Table() line 70
- class-const PrivilegeKind::Create() line 77
- method-call Derivation::target() line 79
- method-call PrivilegeChecks::target() line 79
- method-call Derivation::report() line 84
- new UnknownGrantColumn line 84
public function revoke(
Derivation $derivation,
list<Grantable> $privileges,
ObjectKind $kind,
PrivilegeLevel $level,
bool $ifExists,
): voidDerives the facts of a REVOKE of privileges.
Parameters
$derivation | Derivation | |
$privileges | list<Grantable> | |
$kind | ObjectKind | |
$level | PrivilegeLevel | |
$ifExists | bool |
Called from 1
Calls 4
- method-call PrivilegeChecks::level() line 98
- class-const ObjectKind::Table() line 99
- method-call Derivation::target() line 100
- method-call PrivilegeChecks::target() line 100
public function level(
Derivation $derivation,
list<Grantable> $privileges,
ObjectKind $kind,
PrivilegeLevel $level,
bool $lenient,
): voidReports the privileges, column lists and object kind that do not fit the level.
Parameters
$derivation | Derivation | |
$privileges | list<Grantable> | |
$kind | ObjectKind | |
$level | PrivilegeLevel | |
$lenient | bool | Whether a dynamic privilege outside the global level is only a warning (REVOKE IF EXISTS) |
Called from 2
Calls 8
- class-const ObjectKind::Table() line 113
- method-call Derivation::report() line 114
- new MisplacedPrivilege line 114
- method-call ObjectKind::keyword() line 114
- method-call PrivilegeLevel::describe() line 114
- new RoleOrPrivilegeMismatch line 118
- method-call PrivilegeChecks::describe() line 118
- method-call PrivilegeChecks::fit() line 122
public function fit(
Derivation $derivation,
StaticPrivilege $privilege,
ObjectKind $kind,
PrivilegeLevel $level,
): voidReports a static privilege or its column list that does not fit the level.
Parameters
$derivation | Derivation | |
$privilege | StaticPrivilege | |
$kind | ObjectKind | |
$level | PrivilegeLevel |
Called from 1
Calls 4
- class-const ObjectKind::Table() line 133
- method-call Derivation::report() line 134
- new MisplacedPrivilege line 134
- method-call PrivilegeLevel::describe() line 134
public function roles(Derivation $derivation, list<Grantable> $roles): voidReports the items of a role list of GRANT … TO or REVOKE … FROM that are no roles.
Parameters
$derivation | Derivation | |
$roles | list<Grantable> |
Called from 2
- method-call SqlSemantics\Platform\MySql\Statement\Account\Privilege\GrantRoles::deriveStatement() packages/sql-semantics-mysql/src/Statement/Account/Privilege/GrantRoles.php:65
- method-call SqlSemantics\Platform\MySql\Statement\Account\Privilege\RevokeRoles::deriveStatement() packages/sql-semantics-mysql/src/Statement/Account/Privilege/RevokeRoles.php:63
Calls 3
- method-call Derivation::report() line 162
- new RoleOrPrivilegeMismatch line 162
- method-call PrivilegeChecks::describe() line 162
public function target(
Derivation $derivation,
ObjectLevel $level,
bool $absentAllowed,
): RelationFactResolves the table of a level and answers its facts.
Parameters
$derivation | Derivation | |
$level | ObjectLevel | |
$absentAllowed | bool | Whether a name a complete context does not declare is accepted |
Returns
Called from 2
Calls 8
- method-call Derivation::table() line 174
- method-call Derivation::environment() line 174
- new OutputSlot line 178
- new Known line 178
- new RelationFact line 181
- new RowShape line 181
- new IncompleteMembers line 181
- new AbsentGrantTable line 187
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Relations§
Instantiated in 4
- new SqlSemantics\Platform\MySql\Statement\Account\Privilege\GrantPrivileges::deriveStatement() packages/sql-semantics-mysql/src/Statement/Account/Privilege/GrantPrivileges.php:95
- new SqlSemantics\Platform\MySql\Statement\Account\Privilege\GrantRoles::deriveStatement() packages/sql-semantics-mysql/src/Statement/Account/Privilege/GrantRoles.php:65
- new SqlSemantics\Platform\MySql\Statement\Account\Privilege\RevokePrivileges::deriveStatement() packages/sql-semantics-mysql/src/Statement/Account/Privilege/RevokePrivileges.php:81
- new SqlSemantics\Platform\MySql\Statement\Account\Privilege\RevokeRoles::deriveStatement() packages/sql-semantics-mysql/src/Statement/Account/Privilege/RevokeRoles.php:63
Method calls 4
- method-call SqlSemantics\Platform\MySql\Statement\Account\Privilege\GrantPrivileges::deriveStatement() packages/sql-semantics-mysql/src/Statement/Account/Privilege/GrantPrivileges.php:95
- method-call SqlSemantics\Platform\MySql\Statement\Account\Privilege\GrantRoles::deriveStatement() packages/sql-semantics-mysql/src/Statement/Account/Privilege/GrantRoles.php:65
- method-call SqlSemantics\Platform\MySql\Statement\Account\Privilege\RevokePrivileges::deriveStatement() packages/sql-semantics-mysql/src/Statement/Account/Privilege/RevokePrivileges.php:81
- method-call SqlSemantics\Platform\MySql\Statement\Account\Privilege\RevokeRoles::deriveStatement() packages/sql-semantics-mysql/src/Statement/Account/Privilege/RevokeRoles.php:63