classPrivilegeChecks
final class PrivilegeChecks
Checks the privileges of a GRANT or REVOKE against the kind of object.
Rule: PG-PRIVILEGE-CHECK-001. The server knows a fixed list of privilege names (MAINTAIN from release 17; rule is accepted and ignored) and a fixed set of them for each kind of object (the table of privileges in the manual). A name outside the list is reported as unrecognized, a known privilege outside the set of the kind as invalid for that kind. A relation named in GRANT may be a sequence, so there the sequence privileges are valid too; for default privileges only the privileges of the kind itself are. A column list is valid on relations only, limits the privilege to SELECT, INSERT, UPDATE or REFERENCES, and cannot be written for default privileges. The right to grant cannot be given to PUBLIC. The names are compared as decoded, as the server does. Termination: one pass over a finite list. Source: https://www.postgresql.org/docs/17/ddl-priv.html#PRIVILEGES-SUMMARY-TABLE, https://www.postgresql.org/docs/16/ddl-priv.html, https://www.postgresql.org/docs/17/sql-grant.html, https://www.postgresql.org/docs/17/sql-alterdefaultprivileges.html. Status: Implemented.
Methods§
public function privileges(
Derivation $derivation,
list<Privilege> $privileges,
PrivilegeObjectKind $object,
bool $defaults,
): voidReports the privileges that are unknown, do not apply to the kind of object, or carry a column list where none is valid.
Parameters
$derivation | Derivation | |
$privileges | list<Privilege> | |
$object | PrivilegeObjectKind | |
$defaults | bool | Whether the privileges are default privileges |
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\DefaultPrivilegeChecks::check() packages/sql-semantics-postgres/src/Rules/Access/DefaultPrivilegeChecks.php:54
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Privilege\Grant::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Access/Privilege/Grant.php:69
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Privilege\Revoke::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Access/Privilege/Revoke.php:66
Calls 5
- class-const PrivilegeChecks::RIGHTS() line 78
- class-const PrivilegeObjectKind::Relation() line 79
- method-call PrivilegeChecks::columns() line 84
- method-call PrivilegeChecks::named() line 87
- method-call PrivilegeObjectKind::subject() line 87
public function columns(
Derivation $derivation,
Privilege $privilege,
PrivilegeObjectKind $object,
bool $defaults,
): voidReports the problems of a privilege that carries a column list.
Parameters
$derivation | Derivation | |
$privilege | Privilege | |
$object | PrivilegeObjectKind | |
$defaults | bool |
Called from 1
Calls 8
- method-call Derivation::report() line 97
- new AccessProblem line 97
- class-const AccessProblemRule::DefaultColumns() line 97
- class-const PrivilegeObjectKind::Relation() line 101
- class-const AccessProblemRule::ColumnPrivilegesTarget() line 102
- method-call PrivilegeChecks::named() line 106
- method-call Privilege::privilege() line 106
- class-const PrivilegeChecks::COLUMN() line 106
public function named(
Derivation $derivation,
?string $name,
list<string> $rights,
string $subject,
): voidReports a privilege name that is unknown or outside the given set; ALL, which has no name, is in every set.
Parameters
$derivation | Derivation | |
$name | ?string | |
$rights | list<string> | The privilege names that apply |
$subject | string | The words the server names the kind with |
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\PrivilegeChecks::privileges() packages/sql-semantics-postgres/src/Rules/Access/PrivilegeChecks.php:87
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\PrivilegeChecks::columns() packages/sql-semantics-postgres/src/Rules/Access/PrivilegeChecks.php:106
Calls 7
- method-call PrivilegeChecks::known() line 120
- method-call Derivation::report() line 121
- new AccessProblem line 121
- class-const AccessProblemRule::UnrecognizedPrivilege() line 121
- function-call
in_arrayline 122 - class-const AccessProblemRule::InvalidPrivilege() line 123
- function-call
strtoupperline 123
public function known(Derivation $derivation, string $name): boolTells whether the release knows a privilege name.
Parameters
$derivation | Derivation | |
$name | string |
Returns
boolCalled from 1
Calls 3
- function-call
in_arrayline 132 - class-const PrivilegeChecks::KNOWN() line 132
- class-const GrammarRelease::PostgreSql172() line 132
public function grantOption(Derivation $derivation, list<RoleSpec> $grantees): voidReports PUBLIC among the grantees of a grant that gives the right to grant.
Parameters
$derivation | Derivation | |
$grantees | list<RoleSpec> |
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\DefaultPrivilegeChecks::check() packages/sql-semantics-postgres/src/Rules/Access/DefaultPrivilegeChecks.php:56
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Privilege\Grant::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Access/Privilege/Grant.php:71
Calls 4
- class-const RoleSpecKind::Everyone() line 143
- method-call Derivation::report() line 144
- new AccessProblem line 144
- class-const AccessProblemRule::GrantOptionToPublic() line 144
Private surface 3§
Implementation details, listed for orientation only.
private const KNOWN = ['insert', 'select', 'update', 'delete', 'truncate', 'references', 'trigger', '…private const RIGHTS = ['Relation' => ['insert', 'select', 'update', 'delete', 'truncate', 'references…private const COLUMN = ['select', 'insert', 'update', 'references']Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
PrivilegeChecksTestcalls
Relations§
Instantiated in 4
- new SqlSemantics\Platform\PostgreSql\Rules\Access\DefaultPrivilegeChecks::check() packages/sql-semantics-postgres/src/Rules/Access/DefaultPrivilegeChecks.php:53
- new SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Privilege\Grant::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Access/Privilege/Grant.php:69
- new SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Privilege\Grant::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Access/Privilege/Grant.php:71
- new SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Privilege\Revoke::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Access/Privilege/Revoke.php:66
Method calls 5
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\DefaultPrivilegeChecks::check() packages/sql-semantics-postgres/src/Rules/Access/DefaultPrivilegeChecks.php:54
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\DefaultPrivilegeChecks::check() packages/sql-semantics-postgres/src/Rules/Access/DefaultPrivilegeChecks.php:56
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Privilege\Grant::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Access/Privilege/Grant.php:69
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Privilege\Grant::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Access/Privilege/Grant.php:71
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Privilege\Revoke::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Access/Privilege/Revoke.php:66