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

Method build_webhook_payload

nodedb/src/control/security/siem.rs:115–130  ·  view source on GitHub ↗

Build a webhook payload with HMAC signature. Returns `(json_body, hmac_signature_hex)`.

(&self, events: &[AuditEntry])

Source from the content-addressed store, hash-verified

113 ///
114 /// Returns `(json_body, hmac_signature_hex)`.
115 pub fn build_webhook_payload(&self, events: &[AuditEntry]) -> (String, String) {
116 let body = serde_json::json!({
117 "source": "nodedb",
118 "event_count": events.len(),
119 "events": events,
120 })
121 .to_string();
122
123 let signature = if !self.config.webhook_hmac_secret.is_empty() {
124 compute_hmac(&self.config.webhook_hmac_secret, &body)
125 } else {
126 String::new()
127 };
128
129 (body, signature)
130 }
131
132 /// Send buffered events to configured webhook (async).
133 pub async fn flush_webhook(&self) {

Callers 2

flush_webhookMethod · 0.80

Calls 3

to_stringMethod · 0.80
compute_hmacFunction · 0.70
is_emptyMethod · 0.45

Tested by 1