mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Made the roles the only lists of topics, Refused PRAGMAs in queries
- Removed `[server] topics` and `[replication] replicated_topics`: a push is taken by its roles' `push_topics`, a replicated message by the peer's `accept_topics`; a topic exists from its first message. - Topics that only came from a peer are read and listed like any other; `ListNames` lists the topics with messages, filtered by the roles. - A push to a topic no role names is `NotAllowed`; `UnknownName` is only for nodes. - Clients' queries: every PRAGMA refused as it's prepared (SQLite's authorizer), `PRAGMA query_only = 0` used to take effect. - Noted the leads found by reading the code in `docs/known-issues.md`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -702,6 +702,25 @@ fn queries() {
|
||||
] {
|
||||
assert!(matches!(runner.run(sql), Err(Error::Query(_))), "{sql}");
|
||||
}
|
||||
// PRAGMAs are refused as they're prepared, reading ones too: one that
|
||||
// changes the connection would have by the time it's looked at.
|
||||
for sql in [
|
||||
"PRAGMA query_only = 0",
|
||||
"PRAGMA query_only",
|
||||
"PRAGMA locking_mode = EXCLUSIVE",
|
||||
"PRAGMA database_list",
|
||||
"SELECT * FROM pragma_database_list",
|
||||
] {
|
||||
match runner.run(sql) {
|
||||
Err(Error::Query(why)) => assert!(why.contains("not authorized"), "{sql}: {why}"),
|
||||
other => panic!("{sql}: {other:?}"),
|
||||
}
|
||||
}
|
||||
// Still read-only, still answering.
|
||||
assert_eq!(
|
||||
json("SELECT count(*) FROM messages")["rows"],
|
||||
serde_json::json!([["3"]])
|
||||
);
|
||||
// A failing row fails it all, with SQLite's message.
|
||||
match runner.run("SELECT message_data ->> '$.t' FROM messages") {
|
||||
Err(Error::Query(why)) => assert!(why.contains("malformed JSON"), "{why}"),
|
||||
|
||||
Reference in New Issue
Block a user