Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/impls/translator_impls/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,9 @@ impl crate::traits::translator::TranslatorWithContext for Statement {
Self::CreateUser(_) => drop_with_warning("CREATE USER", REASON_ACCESS_CONTROL, emit),
Self::AlterRole { .. } => drop_with_warning("ALTER ROLE", REASON_ACCESS_CONTROL, emit),
Self::AlterUser(_) => drop_with_warning("ALTER USER", REASON_ACCESS_CONTROL, emit),
Self::Grant(_) => drop_with_warning("GRANT", REASON_ACCESS_CONTROL, emit),
Self::Grant(_) | Self::GrantRole(_) => {
drop_with_warning("GRANT", REASON_ACCESS_CONTROL, emit)
}
Self::Revoke(_) => drop_with_warning("REVOKE", REASON_ACCESS_CONTROL, emit),
Self::Deny { .. } => drop_with_warning("DENY", REASON_ACCESS_CONTROL, emit),
Self::CreateType { .. } => {
Expand Down
5 changes: 5 additions & 0 deletions tests/test_no_statement_is_silently_dropped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ const TABLE_AND_ROLE: &str = "CREATE TABLE t (id INTEGER PRIMARY KEY, a TEXT); C
const TABLE_ROLE_AND_GRANT: &str =
"CREATE TABLE t (id INTEGER PRIMARY KEY, a TEXT); CREATE ROLE r; GRANT SELECT ON t TO r;";

/// A membership `GRANT` names a role on each side, so both have to exist.
const TWO_ROLES: &str =
"CREATE TABLE t (id INTEGER PRIMARY KEY, a TEXT); CREATE ROLE r; CREATE ROLE u;";

const fn emitted(sql: &'static str) -> Case {
Case { setup: TABLE, sql, outcome: Outcome::Emitted }
}
Expand Down Expand Up @@ -167,6 +171,7 @@ const CASES: &[Case] = &[
sql: "REVOKE SELECT ON t FROM r",
outcome: Outcome::Warned,
},
Case { setup: TWO_ROLES, sql: "GRANT r TO u", outcome: Outcome::Warned },
warned("DENY SELECT ON t TO r"),
warned("DROP ROLE r"),
warned("DROP USER r"),
Expand Down