MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / rls_check_document

Function rls_check_document

nodedb/src/data/executor/handlers/rls_eval.rs:21–37  ·  view source on GitHub ↗

Evaluate RLS filters against a document. Returns `true` if the document passes all RLS filters (or if no filters). Returns `false` if any filter rejects the document (caller must deny). Used by point-get and key-get handlers after fetching the raw document.

(rls_filters: &[u8], doc: &serde_json::Value)

Source from the content-addressed store, hash-verified

19///
20/// Used by point-get and key-get handlers after fetching the raw document.
21pub fn rls_check_document(rls_filters: &[u8], doc: &serde_json::Value) -> bool {
22 if rls_filters.is_empty() {
23 return true;
24 }
25
26 let filters: Vec<ScanFilter> = match zerompk::from_msgpack(rls_filters) {
27 Ok(f) => f,
28 Err(_) => {
29 // Deserialization failure → deny (fail-closed).
30 tracing::warn!("RLS filter deserialization failed — denying access");
31 return false;
32 }
33 };
34
35 let msgpack = nodedb_types::json_to_msgpack_or_empty(doc);
36 filters.iter().all(|f| f.matches_binary(&msgpack))
37}
38
39/// Evaluate RLS filters against raw MessagePack document bytes.
40///

Callers

nothing calls this directly

Calls 5

json_to_msgpack_or_emptyFunction · 0.85
matches_binaryMethod · 0.80
is_emptyMethod · 0.45
allMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected