1
0
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:
2026-11-16 01:28:24 +01:00
parent cef99102f9
commit cf8264b21d
34 changed files with 304 additions and 227 deletions
+3 -2
View File
@@ -226,8 +226,9 @@ ptrdiff_t BakaShrot_GetMessageNodeA(char *buffer, ptrdiff_t size);
ptrdiff_t BakaShrot_GetMessageNodeW(uint16_t *buffer, ptrdiff_t size);
/**
* Lists the topics this client may push to or read (every one if it may
* query): how many, -1 on failure. Then `BakaShrot_GetNamesList()`.
* Lists the topics with messages that this client may push to or read
* (every one if it may query): how many, -1 on failure. Then
* `BakaShrot_GetNamesList()`.
*/
int32_t BakaShrot_ListTopics(void);
@@ -311,7 +311,7 @@ CompilerIf #PB_Compiler_IsMainFile
PrintN("Topics: " + BakaShrot_GetNamesListString())
If BakaShrot_PushMessageTo("nothing", "{}") < 0
PrintN("A push to an unknown topic: " + BakaShrot_ErrorName(BakaShrot_GetLastError()) + ", " + BakaShrot_GetRefusalReasonString())
PrintN("A push to a topic it may not push to: " + BakaShrot_ErrorName(BakaShrot_GetLastError()) + ", " + BakaShrot_GetRefusalReasonString())
EndIf
BakaShrot_Disconnect()
+1 -1
View File
@@ -49,7 +49,7 @@
; Not allowed to this client: its roles' permissions (or, when connecting,
; none of its roles is the server's).
#BakaShrot_Refused_NotAllowed = 1
; A topic or node this server doesn't know.
; A node this server has no message of.
#BakaShrot_Refused_UnknownName = 2
; No such message or attachment.
#BakaShrot_Refused_NotFound = 3
+2 -2
View File
@@ -79,7 +79,7 @@ class ErrorCode(enum.IntEnum):
NONE = 0
# Refused by the server, the connection still open.
NOT_ALLOWED = 1 # its roles don't allow it (or none is the server's, when connecting)
UNKNOWN_NAME = 2 # a topic or node this server doesn't know
UNKNOWN_NAME = 2 # a node this server has no message of
NOT_FOUND = 3 # no such message or attachment
NOT_READY = 4 # the attachment isn't on this server yet: retry later
TOO_BIG = 5 # over a limit, or more than this server keeps
@@ -542,7 +542,7 @@ class Client:
time.sleep(interval)
def list_topics(self) -> NamesList:
"""The topics the client may push to or read (every one if it may query)."""
"""The topics with messages that the client may push to or read (every one if it may query)."""
return self._list(self._dll.ListTopics, "List topics")
def list_nodes(self) -> NamesList:
+2 -2
View File
@@ -131,8 +131,8 @@ with kitchen:
check("limit 0: ValueError, before asking", ok, detail)
ok, detail = raises(lambda: kitchen.get_messages("logs", "kitchen", after=-1), ValueError)
check("after -1: ValueError", ok, detail)
ok, detail = raises(lambda: kitchen.push("x", "nothing"), RefusedError, "unknown topic", ErrorCode.UNKNOWN_NAME)
check("Push to an unknown topic: RefusedError, UNKNOWN_NAME", ok, detail)
ok, detail = raises(lambda: kitchen.push("x", "nothing"), RefusedError, "may not push to 'nothing'", ErrorCode.NOT_ALLOWED)
check("Push to a topic not in its push_topics: RefusedError, NOT_ALLOWED", ok, detail)
ok, detail = raises(lambda: kitchen.push("x", "a b"), BakaShrotError, "isn't a topic name", ErrorCode.INVALID_ARGUMENT)
check("A topic that isn't a name: refused before sending", ok, detail)
ok, detail = raises(lambda: kitchen.push("x" * (bakashrot.MAX_MESSAGE_SIZE + 1), "logs"), BakaShrotError, "too big",