aikido-zen 1.0.1.beta.3 → 1.0.1.beta.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b65ca1f70cfe358f45e5a32ebf7040ddd23e14fc06fcdc76ecc40787c7e900a
4
- data.tar.gz: 9eeec2fac0c811d58543f984a438729a2c335c1a04a3ca477f0cc580dc1850a2
3
+ metadata.gz: 77f21724c518120f8babf2de99cb851ca3883c7f30486c55f85b2e50fccda388
4
+ data.tar.gz: 60991be90b49872e9d31d3c84c5482a9e57191964bfc890478c876a89b18d848
5
5
  SHA512:
6
- metadata.gz: '07069063ad2ddf0cd07d1332cb9bd82a2a07670355fde427c21abdda64f6eaad32b8d7f3b5f841b93803e2e4c2e9588ce280d1af6158a14820482880e2e452f0'
7
- data.tar.gz: 421cef9738902e350617663306f95f52a92ed8773f192684b7c8f8546e02eaf8afe90ce619bb81c2d0797a36537c2beaa597e34dc7d5a620b905a61500f21a8d
6
+ metadata.gz: 8537a8ca813cd0480141b47976bed6a0577ef5c06ed07db0dcfa59c77cd2061954ffad805ea8daad3e2549cb73558f06e6d34a67f3ebec024ddc40b18958fc5c
7
+ data.tar.gz: d6f99986334e8435118e1516ae93152bf2f6f6f2a96e306c3649016eb878e1454885ef45fecf04875b57c3d6b89f6e73e7063db02780fe126c92f8a02f9b5a7f
@@ -10,8 +10,6 @@ module Aikido::Zen
10
10
  end
11
11
 
12
12
  initializer "aikido.add_middleware" do |app|
13
- next unless config.zen.protect?
14
-
15
13
  app.middleware.use Aikido::Zen::Middleware::SetContext
16
14
  app.middleware.use Aikido::Zen::Middleware::CheckAllowedAddresses
17
15
  # Request Tracker stats do not consider failed request or 40x, so the middleware
@@ -51,20 +49,8 @@ module Aikido::Zen
51
49
  end
52
50
 
53
51
  config.after_initialize do
54
- next unless config.zen.protect?
55
-
56
- # Make sure this is run at the end of the initialization process, so
57
- # that any gems required after aikido-zen are detected and patched
58
- # accordingly.
59
- Aikido::Zen.load_sinks!
60
-
61
- # It's important we start after loading sinks, so we can report the installed packages
52
+ # Start the Aikido Agent only once the application starts.
62
53
  Aikido::Zen.start!
63
-
64
- # Agent's bootstrap process has finished —Controllers are patched to block
65
- # unwanted requests, sinks are loaded, scanners are running—, so we mark
66
- # the agent as installed.
67
- Aikido::Zen.middleware_installed!
68
54
  end
69
55
  end
70
56
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Aikido
4
4
  module Zen
5
- VERSION = "1.0.1.beta.3"
5
+ VERSION = "1.0.1.beta.4"
6
6
 
7
7
  # The version of libzen_internals that we build against.
8
8
  LIBZEN_VERSION = "0.1.39"
data/lib/aikido/zen.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # IMPORTANT: Any files that load sinks or start the Aikido Agent should
4
- # be required in `Aikido::Zen.protect!`.
5
-
6
3
  require_relative "zen/version"
7
4
  require_relative "zen/errors"
8
5
  require_relative "zen/actor"
@@ -29,6 +26,9 @@ module Aikido
29
26
  # Enable protection. Until this method is called no sinks are loaded
30
27
  # and the Aikido Agent does not start.
31
28
  #
29
+ # This method should be called only once, in the application after the
30
+ # initialization process is complete.
31
+ #
32
32
  # @return [void]
33
33
  def self.protect!
34
34
  if config.disabled?
@@ -36,16 +36,14 @@ module Aikido
36
36
  return
37
37
  end
38
38
 
39
- # IMPORTANT: Any files that load sinks or start the Aikido Agent
40
- # should be required here only.
39
+ return unless config.protect?
41
40
 
42
- if Aikido::Zen.satisfy "rails", ">= 7.0"
43
- require_relative "zen/rails_engine"
41
+ unless load_sources! && load_sinks!
42
+ config.logger.warn "Zen could not find any supported libraries or frameworks. Visit https://github.com/AikidoSec/firewall-ruby for more information."
43
+ return
44
44
  end
45
45
 
46
- if Aikido::Zen::Sinks.registry.empty?
47
- warn "Zen could not find any supported libraries or frameworks. Visit https://github.com/AikidoSec/firewall-ruby for more information."
48
- end
46
+ middleware_installed!
49
47
  end
50
48
 
51
49
  # @!visibility private
@@ -173,15 +171,28 @@ module Aikido
173
171
  collector.middleware_installed!
174
172
  end
175
173
 
176
- # Load all sinks matching libraries loaded into memory. This method should
177
- # be called after all other dependencies have been loaded into memory (i.e.
178
- # at the end of the initialization process).
174
+ # @!visibility private
175
+ # Load all sources.
179
176
  #
180
- # If a new gem is required, this method can be called again safely.
177
+ # @return [Boolean] true if any sources were loaded
178
+ def self.load_sources!
179
+ if Aikido::Zen.satisfy("rails", ">= 7.0")
180
+ require_relative "zen/rails_engine"
181
+
182
+ return true
183
+ end
184
+
185
+ false
186
+ end
187
+
188
+ # @!visibility private
189
+ # Load all sinks.
181
190
  #
182
- # @return [void]
191
+ # @return [Boolean] true if any sinks were loaded
183
192
  def self.load_sinks!
184
193
  require_relative "zen/sinks"
194
+
195
+ !Aikido::Zen::Sinks.registry.empty?
185
196
  end
186
197
 
187
198
  # @!visibility private
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.0.1.beta.3
4
+ version: 1.0.1.beta.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aikido Security
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-06 00:00:00.000000000 Z
11
+ date: 2025-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby