aikido-zen 1.9.0.beta.2 → 1.9.0.beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/custom-event-tracking.md +5 -5
- data/lib/aikido/zen/agent.rb +1 -1
- data/lib/aikido/zen/event.rb +7 -4
- data/lib/aikido/zen/version.rb +2 -2
- data/lib/aikido/zen.rb +6 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ada1cbea91efe8d3351ac604504ce0153797785e1d054fd33838a26afcb5038b
|
|
4
|
+
data.tar.gz: cedb2ec0153e3604ece81999b7d9c87e32d67554c9544f4e43574fe8f0ea92b0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 833b0e13c05805b86e9060ad6061bc574811347d821139683b3cd0f6d73710f2db7449643075946773d7e0779dc0b1a99c9af7e1abd457d747f81e481ce90721
|
|
7
|
+
data.tar.gz: ff86f644f5453d99b8acf72cdf76348c5292fa28df03a84fbf174782f5e1498b8a03da7508d4378ab6ac354495f9bef9f91c3698f5081e4f66ad8299341650d8
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Track custom events
|
|
2
2
|
|
|
3
|
-
Use `Aikido::Zen.
|
|
3
|
+
Use `Aikido::Zen.track` to report events that only your application knows about, such as failed logins. [Playbooks](https://help.aikido.dev/zen-firewall/zen-features/playbooks) can act when an event occurs repeatedly, for example by blocking an IP after three failed logins in five minutes.
|
|
4
4
|
|
|
5
5
|
```ruby
|
|
6
6
|
# app/controllers/application_controller.rb
|
|
@@ -12,7 +12,7 @@ class ApplicationController < ActionController::Base
|
|
|
12
12
|
# ...
|
|
13
13
|
|
|
14
14
|
unless current_user
|
|
15
|
-
Aikido::Zen.
|
|
15
|
+
Aikido::Zen.track("user.login_failed")
|
|
16
16
|
return
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -21,13 +21,13 @@ class ApplicationController < ActionController::Base
|
|
|
21
21
|
name: current_user.name
|
|
22
22
|
)
|
|
23
23
|
|
|
24
|
-
Aikido::Zen.
|
|
24
|
+
Aikido::Zen.track("user.login_succeeded")
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
After adding `Aikido::Zen.
|
|
29
|
+
After adding `Aikido::Zen.track`, trigger the event at least once. It will then appear on the Playbooks page in the Aikido dashboard. From there, you can create a playbook and choose what should happen when the event occurs. Calling `Aikido::Zen.track` by itself does not create a playbook or block anything.
|
|
30
30
|
|
|
31
|
-
Call `Aikido::Zen.
|
|
31
|
+
Call `Aikido::Zen.track` while handling an HTTP request. Zen associates the event with the request's IP address. Playbook counts are per IP, not across your whole app. If you call [`Aikido::Zen.set_user`](./rails.md#rate-limiting-and-user-blocking) before tracking the event, Zen also includes the current user. `Aikido::Zen.set_user` is optional. Events without a user are still tracked.
|
|
32
32
|
|
|
33
33
|
Event names can use any format. We recommend lowercase, dot-separated names such as `user.login_failed`.
|
data/lib/aikido/zen/agent.rb
CHANGED
|
@@ -160,7 +160,7 @@ module Aikido::Zen
|
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
-
# Reports a custom event tracked via Aikido::Zen.
|
|
163
|
+
# Reports a custom event tracked via Aikido::Zen.track, if
|
|
164
164
|
# reporting is enabled.
|
|
165
165
|
#
|
|
166
166
|
# @param event [Aikido::Zen::Events::Custom]
|
data/lib/aikido/zen/event.rb
CHANGED
|
@@ -96,7 +96,7 @@ module Aikido::Zen
|
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
# Event sent by Aikido::Zen.
|
|
99
|
+
# Event sent by Aikido::Zen.track to record a custom,
|
|
100
100
|
# user-named event happening during an HTTP request.
|
|
101
101
|
class Custom < Event
|
|
102
102
|
# @param name [String] the name of the tracked event.
|
|
@@ -112,11 +112,14 @@ module Aikido::Zen
|
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
def as_json
|
|
115
|
+
request_json = @request.as_json
|
|
116
|
+
request_json.delete("url")
|
|
117
|
+
|
|
115
118
|
super.update(
|
|
116
119
|
{
|
|
117
|
-
name
|
|
118
|
-
request
|
|
119
|
-
user
|
|
120
|
+
"name" => @name,
|
|
121
|
+
"request" => request_json,
|
|
122
|
+
"user" => @user && {"id" => @user.id, "name" => @user.name}.compact
|
|
120
123
|
}.compact
|
|
121
124
|
)
|
|
122
125
|
end
|
data/lib/aikido/zen/version.rb
CHANGED
data/lib/aikido/zen.rb
CHANGED
|
@@ -282,14 +282,14 @@ module Aikido
|
|
|
282
282
|
# a password reset request. Zen automatically attaches the IP address, user
|
|
283
283
|
# agent, and current user (if you called .track_user) from the request.
|
|
284
284
|
#
|
|
285
|
-
# Only works inside an HTTP request;
|
|
286
|
-
# script,
|
|
285
|
+
# Only works inside an HTTP request; the custom event is not reported if
|
|
286
|
+
# called from a background job or script, or if the request is bypassed.
|
|
287
287
|
#
|
|
288
288
|
# @param name [String]
|
|
289
289
|
# @return [void]
|
|
290
|
-
def self.
|
|
290
|
+
def self.track(name)
|
|
291
291
|
unless name.is_a?(String) && !name.empty?
|
|
292
|
-
config.logger.warn("
|
|
292
|
+
config.logger.warn("track expects a non-empty String as the event name")
|
|
293
293
|
return
|
|
294
294
|
end
|
|
295
295
|
|
|
@@ -298,6 +298,8 @@ module Aikido
|
|
|
298
298
|
context = current_context
|
|
299
299
|
return unless context
|
|
300
300
|
|
|
301
|
+
return if request_bypassed?
|
|
302
|
+
|
|
301
303
|
event = Events::Custom.new(
|
|
302
304
|
name: name,
|
|
303
305
|
request: context.request,
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: aikido-zen
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.0.beta.
|
|
4
|
+
version: 1.9.0.beta.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aikido Security
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|