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

Function rls_check_msgpack_bytes

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

Evaluate RLS filters against raw MessagePack document bytes. Evaluates filters directly on msgpack bytes — no decode to serde_json::Value. Returns `true` if passes. Returns `false` if any filter rejects.

(rls_filters: &[u8], doc_bytes: &[u8])

Source from the content-addressed store, hash-verified

41/// Evaluates filters directly on msgpack bytes — no decode to serde_json::Value.
42/// Returns `true` if passes. Returns `false` if any filter rejects.
43pub fn rls_check_msgpack_bytes(rls_filters: &[u8], doc_bytes: &[u8]) -> bool {
44 if rls_filters.is_empty() {
45 return true;
46 }
47
48 let filters: Vec<ScanFilter> = match zerompk::from_msgpack(rls_filters) {
49 Ok(f) => f,
50 Err(_) => {
51 tracing::warn!("RLS filter deserialization failed — denying access");
52 return false;
53 }
54 };
55
56 // Ensure bytes are standard msgpack for matches_binary.
57 let mp = super::super::doc_format::json_to_msgpack(doc_bytes);
58 filters.iter().all(|f| f.matches_binary(&mp))
59}
60
61#[cfg(test)]
62mod tests {

Callers 5

hydrate_text_hitsMethod · 0.85
execute_hybrid_searchMethod · 0.85
execute_kv_getMethod · 0.85
execute_point_getMethod · 0.85

Calls 5

matches_binaryMethod · 0.80
json_to_msgpackFunction · 0.50
is_emptyMethod · 0.45
allMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected