Module: ReeAudit

Includes:
Ree::PackageDSL
Defined in:
lib/ree_lib/packages/ree_audit/package/ree_audit/context.rb,
lib/ree_lib/packages/ree_audit/package/ree_audit.rb

Overview

Per-fiber stack of audited events.

A stack rather than a single slot: an action is allowed to call another audited action, and the inner one must not steal the outer one's annotations.

Thread.current is fiber-local in Ruby, so this is safe under Falcon as well; ree_datetime/functions/set_default_time_zone.rb relies on the same property.

Defined Under Namespace

Modules: Context Classes: AnnotateAudit, Audit, Config, Event, FilterParams, LoggerSink, NullSink, Sink

Class Method Summary collapse

Class Method Details

.annotate(**attrs) ⇒ Object

Attaches application-level facts to the call currently being audited: which permission was checked, which object was opened, whose data it is.

Returns nil when there is nothing to annotate — audit is disabled, or the code was reached from outside an audited route. Product code calls this through the annotate_audit fn, never through the constant directly, so that removing depends_on :ree_audit fails loudly instead of in production.



28
29
30
31
32
33
# File 'lib/ree_lib/packages/ree_audit/package/ree_audit.rb', line 28

def annotate(**attrs)
  event = Context.current
  return nil if event.nil?

  event.annotations.merge!(attrs)
end