canarytrap 0.2.0

Rust-native canary tokens and honeytokens for early detection of suspicious access to secrets and configuration.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
use crate::{CallbackSink, CanaryEvent, CanaryKind, Sink, TriggerSource};
use core::fmt;
use std::panic::{AssertUnwindSafe, catch_unwind};
use uuid::Uuid;

/// A managed fake secret that emits events when instrumented access occurs.
///
/// `CanaryToken` stores a canary value privately and exposes it only through
/// instrumented access APIs:
///
/// - [`CanaryToken::reveal`];
/// - [`CanaryToken::with_value`].
///
/// Every instrumented access produces a [`CanaryEvent`] containing only
/// metadata. The canary value itself is never stored in the event.
///
/// # Sinks
///
/// A token can deliver events to multiple sinks:
///
/// - [`CanaryToken::on_trigger`] registers a callback sink;
/// - [`CanaryToken::with_sink`] registers any [`Sink`] implementation.
///
/// # Example
///
/// ```
/// use std::sync::atomic::{AtomicUsize, Ordering};
/// use std::sync::Arc;
///
/// use canarytrap::{CanaryKind, CanaryToken, TriggerSource};
///
/// let count = Arc::new(AtomicUsize::new(0));
/// let counter = count.clone();
///
/// let token = CanaryToken::new(
///     "prod.db.password",
///     CanaryKind::Password,
///     "canary-fake-password",
/// )
/// .on_trigger(move |event| {
///     counter.fetch_add(1, Ordering::SeqCst);
///     assert_eq!(event.source, TriggerSource::Reveal);
/// });
///
/// assert_eq!(token.reveal(), "canary-fake-password");
/// assert_eq!(count.load(Ordering::SeqCst), 1);
///
/// let debug = format!("{token:?}");
/// assert!(debug.contains("[REDACTED]"));
/// assert!(!debug.contains("canary-fake-password"));
/// ```
///
/// # Security
///
/// The canary value is redacted in [`Debug`](std::fmt::Debug) and
/// [`Display`](std::fmt::Display) output. It is also not included in
/// [`CanaryEvent`].
pub struct CanaryToken {
    id: String,
    name: String,
    kind: CanaryKind,
    value: String,
    sinks: Vec<Box<dyn Sink>>,
}

impl CanaryToken {
    /// Creates a new canary token with a generated unique identifier.
    ///
    /// # Example
    ///
    /// ```
    /// use canarytrap::{CanaryKind, CanaryToken};
    ///
    /// let token = CanaryToken::new(
    ///     "prod.db.password",
    ///     CanaryKind::Password,
    ///     "canary-fake-password",
    /// );
    ///
    /// assert_eq!(token.name(), "prod.db.password");
    /// assert_eq!(token.kind(), &CanaryKind::Password);
    /// assert!(!token.id().is_empty());
    /// ```
    #[must_use]
    pub fn new(name: impl Into<String>, kind: CanaryKind, value: impl Into<String>) -> Self {
        Self {
            id: Uuid::new_v4().to_string(),
            name: name.into(),
            kind,
            value: value.into(),
            sinks: Vec::new(),
        }
    }

    /// Creates a builder for a canary token with the given name.
    ///
    /// # Example
    ///
    /// ```
    /// use canarytrap::{CanaryKind, CanaryToken};
    ///
    /// # fn main() -> Result<(), Box<dyn std::error::Error>> {
    /// let token = CanaryToken::builder("prod.db.password")
    ///     .kind(CanaryKind::Password)
    ///     .value("fake")
    ///     .build()?;
    ///
    /// assert_eq!(token.name(), "prod.db.password");
    /// # Ok(())
    /// # }
    /// ```
    #[must_use]
    pub fn builder(name: impl Into<String>) -> crate::builder::CanaryTokenBuilder {
        crate::builder::CanaryTokenBuilder::new(name)
    }

    pub(crate) fn from_parts(
        name: String,
        kind: CanaryKind,
        value: String,
        sinks: Vec<Box<dyn Sink>>,
    ) -> Self {
        Self {
            id: Uuid::new_v4().to_string(),
            name,
            kind,
            value,
            sinks,
        }
    }

    /// Creates a new canary token with a generated fake value.
    ///
    /// This requires the `generators` feature.
    ///
    /// # Example
    ///
    /// ```
    /// use canarytrap::{CanaryKind, CanaryToken};
    ///
    /// # fn main() -> Result<(), Box<dyn std::error::Error>> {
    /// let token = CanaryToken::generate("prod.db.password", CanaryKind::Password)?;
    ///
    /// assert_eq!(token.name(), "prod.db.password");
    /// assert_eq!(token.kind(), &CanaryKind::Password);
    ///
    /// let value = token.reveal();
    /// assert!(!value.is_empty());
    /// # Ok(())
    /// # }
    /// ```
    ///
    /// # Errors
    ///
    /// Returns an error if value generation fails.
    #[cfg(feature = "generators")]
    pub fn generate(name: impl Into<String>, kind: CanaryKind) -> crate::Result<Self> {
        let value = crate::generator::generate(&kind)?;

        Ok(Self::new(name, kind, value))
    }

    /// Returns the unique token identifier.
    ///
    /// # Example
    ///
    /// ```
    /// use canarytrap::{CanaryKind, CanaryToken};
    ///
    /// let token = CanaryToken::new("prod.db.password", CanaryKind::Password, "fake");
    /// assert!(!token.id().is_empty());
    /// ```
    #[must_use]
    pub fn id(&self) -> &str {
        &self.id
    }

    /// Returns the human-readable token name.
    ///
    /// # Example
    ///
    /// ```
    /// use canarytrap::{CanaryKind, CanaryToken};
    ///
    /// let token = CanaryToken::new("prod.db.password", CanaryKind::Password, "fake");
    /// assert_eq!(token.name(), "prod.db.password");
    /// ```
    #[must_use]
    pub fn name(&self) -> &str {
        &self.name
    }

    /// Returns the canary kind associated with this token.
    ///
    /// # Example
    ///
    /// ```
    /// use canarytrap::{CanaryKind, CanaryToken};
    ///
    /// let token = CanaryToken::new("prod.db.password", CanaryKind::Password, "fake");
    /// assert_eq!(token.kind(), &CanaryKind::Password);
    /// ```
    #[must_use]
    pub fn kind(&self) -> &CanaryKind {
        &self.kind
    }

    /// Registers a callback that will receive canary event metadata.
    ///
    /// This is a convenience wrapper around [`CallbackSink`].
    ///
    /// Callbacks receive [`CanaryEvent`], which never contains the canary
    /// value.
    ///
    /// # Example
    ///
    /// ```
    /// use std::sync::atomic::{AtomicUsize, Ordering};
    /// use std::sync::Arc;
    ///
    /// use canarytrap::{CanaryKind, CanaryToken};
    ///
    /// let count = Arc::new(AtomicUsize::new(0));
    /// let counter = count.clone();
    ///
    /// let token = CanaryToken::new("prod.db.password", CanaryKind::Password, "fake")
    ///     .on_trigger(move |_event| {
    ///         counter.fetch_add(1, Ordering::SeqCst);
    ///     });
    ///
    /// token.reveal();
    ///
    /// assert_eq!(count.load(Ordering::SeqCst), 1);
    /// ```
    #[must_use]
    pub fn on_trigger(mut self, callback: impl Fn(&CanaryEvent) + Send + Sync + 'static) -> Self {
        self.sinks.push(Box::new(CallbackSink::new(callback)));
        self
    }

    /// Registers a sink that will receive canary event metadata.
    ///
    /// # Example
    ///
    /// ```
    /// use std::sync::atomic::{AtomicUsize, Ordering};
    /// use std::sync::Arc;
    ///
    /// use canarytrap::{CallbackSink, CanaryKind, CanaryToken};
    ///
    /// let count = Arc::new(AtomicUsize::new(0));
    /// let counter = count.clone();
    ///
    /// let sink = CallbackSink::new(move |_event| {
    ///     counter.fetch_add(1, Ordering::SeqCst);
    /// });
    ///
    /// let token = CanaryToken::new("prod.db.password", CanaryKind::Password, "fake")
    ///     .with_sink(sink);
    ///
    /// token.reveal();
    ///
    /// assert_eq!(count.load(Ordering::SeqCst), 1);
    /// ```
    #[must_use]
    pub fn with_sink(mut self, sink: impl Sink + 'static) -> Self {
        self.sinks.push(Box::new(sink));
        self
    }

    /// Reveals the canary value and triggers a [`TriggerSource::Reveal`] event.
    ///
    /// # Example
    ///
    /// ```
    /// use canarytrap::{CanaryKind, CanaryToken};
    ///
    /// let token = CanaryToken::new("prod.db.password", CanaryKind::Password, "fake");
    /// assert_eq!(token.reveal(), "fake");
    /// ```
    #[must_use]
    pub fn reveal(&self) -> String {
        self.trigger(TriggerSource::Reveal);
        self.value.clone()
    }

    /// Reveals the canary value and triggers an event with an explicit source.
    ///
    /// This is useful when another component, such as a registry, reveals the
    /// token and wants to record the correct trigger source.
    ///
    /// # Example
    ///
    /// ```
    /// use std::sync::atomic::{AtomicUsize, Ordering};
    /// use std::sync::Arc;
    ///
    /// use canarytrap::{CanaryKind, CanaryToken, TriggerSource};
    ///
    /// let count = Arc::new(AtomicUsize::new(0));
    /// let counter = count.clone();
    ///
    /// let token = CanaryToken::new("prod.db.password", CanaryKind::Password, "fake")
    ///     .on_trigger(move |event| {
    ///         counter.fetch_add(1, Ordering::SeqCst);
    ///         assert_eq!(event.source, TriggerSource::Registry);
    ///     });
    ///
    /// assert_eq!(
    ///     token.reveal_with_source(TriggerSource::Registry),
    ///     "fake"
    /// );
    /// assert_eq!(count.load(Ordering::SeqCst), 1);
    /// ```
    #[must_use]
    pub fn reveal_with_source(&self, source: TriggerSource) -> String {
        self.trigger(source);
        self.value.clone()
    }

    /// Provides scoped access to the canary value and triggers a
    /// [`TriggerSource::WithValue`] event.
    ///
    /// The value is passed as a borrowed string and does not leave the closure
    /// unless the caller explicitly clones it.
    ///
    /// # Example
    ///
    /// ```
    /// use canarytrap::{CanaryKind, CanaryToken};
    ///
    /// let token = CanaryToken::new("prod.db.password", CanaryKind::Password, "fake");
    ///
    /// let len = token.with_value(|value| value.len());
    /// assert_eq!(len, 4);
    /// ```
    pub fn with_value<R>(&self, f: impl FnOnce(&str) -> R) -> R {
        self.trigger(TriggerSource::WithValue);
        f(&self.value)
    }

    /// Emits a canary event for the given trigger source.
    ///
    /// This can be used for manual or custom instrumentation.
    ///
    /// # Example
    ///
    /// ```
    /// use std::sync::atomic::{AtomicUsize, Ordering};
    /// use std::sync::Arc;
    ///
    /// use canarytrap::{CanaryKind, CanaryToken, TriggerSource};
    ///
    /// let count = Arc::new(AtomicUsize::new(0));
    /// let counter = count.clone();
    ///
    /// let token = CanaryToken::new("prod.db.password", CanaryKind::Password, "fake")
    ///     .on_trigger(move |event| {
    ///         counter.fetch_add(1, Ordering::SeqCst);
    ///         assert_eq!(event.source, TriggerSource::Custom("manual"));
    ///     });
    ///
    /// token.trigger(TriggerSource::Custom("manual"));
    ///
    /// assert_eq!(count.load(Ordering::SeqCst), 1);
    /// ```
    pub fn trigger(&self, source: TriggerSource) {
        let event = CanaryEvent::new(
            self.id.clone(),
            self.name.clone(),
            self.kind.clone(),
            source,
        );

        self.emit(&event);
    }

    fn emit(&self, event: &CanaryEvent) {
        for sink in &self.sinks {
            let result = catch_unwind(AssertUnwindSafe(|| sink.emit(event)));

            if let Err(_panic) = result {
                // Intentionally ignore sink panics. A misbehaving sink must not
                // break the instrumented application.
            }
        }
    }
}

impl fmt::Debug for CanaryToken {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        // The canary value is intentionally redacted.
        f.debug_struct("CanaryToken")
            .field("id", &self.id)
            .field("name", &self.name)
            .field("kind", &self.kind)
            .field("value", &"[REDACTED]")
            .field("sinks", &self.sinks.len())
            .finish()
    }
}

impl fmt::Display for CanaryToken {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(
            f,
            "canary token: name={name} id={id} kind={kind} value=[REDACTED]",
            name = self.name,
            id = self.id,
            kind = self.kind,
        )
    }
}

#[cfg(test)]
mod tests {
    use super::CanaryToken;
    use crate::{CallbackSink, CanaryEvent, CanaryKind, Sink, TriggerSource};
    use std::sync::atomic::{AtomicUsize, Ordering};
    use std::sync::{Arc, Mutex};

    #[derive(Debug, Clone, Default)]
    struct RecordingSink {
        events: Arc<Mutex<Vec<CanaryEvent>>>,
    }

    impl Sink for RecordingSink {
        fn emit(&self, event: &CanaryEvent) {
            self.events
                .lock()
                .expect("recording sink mutex poisoned")
                .push(event.clone());
        }
    }

    fn sample_token() -> CanaryToken {
        CanaryToken::new(
            "prod.db.password",
            CanaryKind::Password,
            "canary-fake-password",
        )
    }

    #[test]
    fn new_generates_unique_identifiers() {
        let first = sample_token();
        let second = sample_token();

        assert!(!first.id().is_empty());
        assert!(!second.id().is_empty());
        assert_ne!(first.id(), second.id());
    }

    #[test]
    fn new_stores_name_and_kind() {
        let token = sample_token();

        assert_eq!(token.name(), "prod.db.password");
        assert_eq!(token.kind(), &CanaryKind::Password);
    }

    #[test]
    fn reveal_returns_value_and_triggers_event() {
        let events = Arc::new(Mutex::new(Vec::new()));
        let events_clone = events.clone();

        let token = sample_token().on_trigger(move |event| {
            events_clone
                .lock()
                .expect("events mutex poisoned")
                .push(event.clone());
        });

        let value = token.reveal();

        assert_eq!(value, "canary-fake-password");

        let events = events.lock().expect("events mutex poisoned");
        assert_eq!(events.len(), 1);

        let event = &events[0];
        assert_eq!(event.token_id, token.id());
        assert_eq!(event.token_name, "prod.db.password");
        assert_eq!(event.kind, CanaryKind::Password);
        assert_eq!(event.source, TriggerSource::Reveal);
    }

    #[test]
    fn with_value_returns_closure_result_and_triggers_event() {
        let events = Arc::new(Mutex::new(Vec::new()));
        let events_clone = events.clone();

        let token = sample_token().on_trigger(move |event| {
            events_clone
                .lock()
                .expect("events mutex poisoned")
                .push(event.clone());
        });

        let len = token.with_value(|value| value.len());

        assert_eq!(len, "canary-fake-password".len());

        let events = events.lock().expect("events mutex poisoned");
        assert_eq!(events.len(), 1);
        assert_eq!(events[0].source, TriggerSource::WithValue);
    }

    #[test]
    fn trigger_emits_custom_source() {
        let events = Arc::new(Mutex::new(Vec::new()));
        let events_clone = events.clone();

        let token = sample_token().on_trigger(move |event| {
            events_clone
                .lock()
                .expect("events mutex poisoned")
                .push(event.clone());
        });

        token.trigger(TriggerSource::Custom("manual"));

        let events = events.lock().expect("events mutex poisoned");
        assert_eq!(events.len(), 1);
        assert_eq!(events[0].source, TriggerSource::Custom("manual"));
    }

    #[test]
    fn multiple_callbacks_are_called_in_registration_order() {
        let calls = Arc::new(Mutex::new(Vec::new()));

        let first_calls = calls.clone();
        let second_calls = calls.clone();

        let token = sample_token()
            .on_trigger(move |_| {
                first_calls.lock().expect("calls mutex poisoned").push(1);
            })
            .on_trigger(move |_| {
                second_calls.lock().expect("calls mutex poisoned").push(2);
            });

        token.trigger(TriggerSource::Reveal);

        let calls = calls.lock().expect("calls mutex poisoned");
        assert_eq!(*calls, vec![1, 2]);
    }

    #[test]
    fn with_sink_accepts_custom_sink() {
        let sink = RecordingSink::default();
        let events = sink.events.clone();

        let token = sample_token().with_sink(sink);

        token.trigger(TriggerSource::Reveal);

        let events = events.lock().expect("events mutex poisoned");
        assert_eq!(events.len(), 1);
        assert_eq!(events[0].source, TriggerSource::Reveal);
    }

    #[test]
    fn on_trigger_and_with_sink_can_be_combined() {
        let calls = Arc::new(Mutex::new(Vec::new()));

        let callback_calls = calls.clone();
        let sink_calls = calls.clone();

        let sink = CallbackSink::new(move |_| {
            sink_calls
                .lock()
                .expect("sink calls mutex poisoned")
                .push("sink");
        });

        let token = sample_token()
            .on_trigger(move |_| {
                callback_calls
                    .lock()
                    .expect("callback calls mutex poisoned")
                    .push("callback");
            })
            .with_sink(sink);

        token.trigger(TriggerSource::Reveal);

        let calls = calls.lock().expect("calls mutex poisoned");
        assert_eq!(*calls, vec!["callback", "sink"]);
    }

    #[test]
    fn debug_redacts_canary_value() {
        let token = sample_token();
        let debug = format!("{token:?}");

        assert!(debug.contains("CanaryToken"));
        assert!(debug.contains("prod.db.password"));
        assert!(debug.contains("[REDACTED]"));
        assert!(!debug.contains("canary-fake-password"));
    }

    #[test]
    fn display_redacts_canary_value() {
        let token = sample_token();
        let display = token.to_string();

        assert!(display.contains("canary token"));
        assert!(display.contains("prod.db.password"));
        assert!(display.contains("[REDACTED]"));
        assert!(!display.contains("canary-fake-password"));
    }

    #[test]
    fn event_does_not_contain_canary_value() {
        let events = Arc::new(Mutex::new(Vec::new()));
        let events_clone = events.clone();

        let token = sample_token().on_trigger(move |event| {
            events_clone
                .lock()
                .expect("events mutex poisoned")
                .push(event.clone());
        });

        token.trigger(TriggerSource::Reveal);

        let events = events.lock().expect("events mutex poisoned");
        let event = &events[0];

        let event_debug = format!("{event:?}");
        let event_display = event.to_string();

        assert!(!event_debug.contains("canary-fake-password"));
        assert!(!event_display.contains("canary-fake-password"));
    }

    #[test]
    fn supports_custom_kind_and_source() {
        let events = Arc::new(Mutex::new(Vec::new()));
        let events_clone = events.clone();

        let token = CanaryToken::new(
            "ldap.bind.password",
            CanaryKind::custom("ldap"),
            "canary-fake-ldap",
        )
        .on_trigger(move |event| {
            events_clone
                .lock()
                .expect("events mutex poisoned")
                .push(event.clone());
        });

        token.trigger(TriggerSource::custom("manual"));

        let events = events.lock().expect("events mutex poisoned");
        let event = &events[0];

        assert_eq!(event.kind.to_string(), "custom:ldap");
        assert_eq!(event.source.to_string(), "custom:manual");
    }

    #[test]
    fn trigger_count_is_correct() {
        let count = Arc::new(AtomicUsize::new(0));
        let counter = count.clone();

        let token = sample_token().on_trigger(move |_| {
            counter.fetch_add(1, Ordering::SeqCst);
        });

        token.trigger(TriggerSource::Reveal);

        token.with_value(|_| {});
        token.trigger(TriggerSource::Registry);

        assert_eq!(count.load(Ordering::SeqCst), 3);
    }

    #[test]
    fn token_is_send_and_sync() {
        fn assert_send_sync<T: Send + Sync>() {}

        assert_send_sync::<CanaryToken>();
    }

    #[test]
    fn event_metadata_matches_token() {
        let events = Arc::new(Mutex::new(Vec::new()));
        let events_clone = events.clone();

        let token = sample_token().on_trigger(move |event| {
            events_clone
                .lock()
                .expect("events mutex poisoned")
                .push(event.clone());
        });

        token.trigger(TriggerSource::Reveal);

        let events = events.lock().expect("events mutex poisoned");
        let event: &CanaryEvent = &events[0];

        assert_eq!(event.token_id, token.id());
        assert_eq!(event.token_name, token.name());
        assert_eq!(event.kind, *token.kind());
    }

    #[test]
    fn reveal_with_source_emits_given_source() {
        let events = Arc::new(Mutex::new(Vec::new()));
        let events_clone = events.clone();

        let token = sample_token().on_trigger(move |event| {
            events_clone
                .lock()
                .expect("events mutex poisoned")
                .push(event.clone());
        });

        let value = token.reveal_with_source(TriggerSource::Registry);

        assert_eq!(value, "canary-fake-password");

        let events = events.lock().expect("events mutex poisoned");
        assert_eq!(events.len(), 1);
        assert_eq!(events[0].source, TriggerSource::Registry);
    }
}