aikido-zen 1.1.0 → 1.1.1

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: 00d07a2e96b782a13c2ab2ec94582f318660ce4e2a3b77ff896490c5382bea47
4
- data.tar.gz: a9b4db0b7157206284d78f35e6530ccb5bdf2e851ea28152788a7d195406b7a3
3
+ metadata.gz: ff56705f799c52755fffdd6a584643ac02d8a4b275671fd488721fb14845a95a
4
+ data.tar.gz: d7be9020470fa9ea1bdbaf2ea5e4624a2f208aa6fba8ef325cad70e916c74cef
5
5
  SHA512:
6
- metadata.gz: 3e7229c3918e282d565ef0d25841e641e9133af719769748ee3626d6c7ad70573d899c33f46e290f8a5fdd56118d569c282d62ba6dab006970426bbccc33febb
7
- data.tar.gz: f1388b4b07679712ee999f245db8faf4c811f76c08ac7ca67e68df06ca8e5d74707cf53f35ca6e25fe195d31d41ba13ef51145804ae7f60a6e451f194672f670
6
+ metadata.gz: 9315eb15bb3c47f905566e857a7abad0ac8c575a1f11d6e0c357f1a0eccb0eda285000e45787cc6c3b48a3f126c291c08a16933e1a2d2b6ca47e05ad05241f0a
7
+ data.tar.gz: 470adc0df77eb9026a4aa7a830a5b5102405ddc346d3d7a50d33975e1a5805ad8fe840ec8d15638bf083936cf0ea14cee1bb30b112045249e34341184ef9e0da
@@ -3,6 +3,7 @@
3
3
  require "uri"
4
4
  require "json"
5
5
  require "logger"
6
+ require "digest"
6
7
 
7
8
  require_relative "context"
8
9
 
@@ -62,8 +63,8 @@ module Aikido::Zen
62
63
  attr_reader :logger
63
64
 
64
65
  # @return [String] Path of the socket where the detached agent will listen.
65
- # By default, is stored under the root application path with file name
66
- # `aikido-detached-agent.sock`
66
+ # By default, the socket file is created in the current working directory.
67
+ # Defaults to `aikido-detached-agent.sock`.
67
68
  attr_accessor :detached_agent_socket_path
68
69
 
69
70
  # @return [Boolean] is the agent in debugging mode?
@@ -263,12 +264,32 @@ module Aikido::Zen
263
264
  @api_timeouts.update(value)
264
265
  end
265
266
 
267
+ def api_token_hash
268
+ return unless api_token
269
+
270
+ @api_token_hash ||= Digest::SHA1.hexdigest(api_token)[0, 7]
271
+ end
272
+
266
273
  def detached_agent_socket_uri
267
274
  "drbunix:" + @detached_agent_socket_path
268
275
  end
269
276
 
277
+ def expanded_detached_agent_socket_path
278
+ @exanded_detached_agent_path ||= expand_socket_path(detached_agent_socket_path)
279
+ end
280
+
281
+ def expanded_detached_agent_socket_uri
282
+ @exanded_detached_agent_uri ||= expand_socket_path(detached_agent_socket_uri)
283
+ end
284
+
270
285
  private
271
286
 
287
+ def expand_socket_path(socket_path)
288
+ socket_path = socket_path.dup
289
+ socket_path.gsub!("%h", api_token_hash) if api_token_hash
290
+ socket_path
291
+ end
292
+
272
293
  def read_boolean_from_env(value)
273
294
  return value unless value.respond_to?(:to_str)
274
295
 
@@ -293,7 +314,7 @@ module Aikido::Zen
293
314
  DEFAULT_JSON_DECODER = JSON.method(:parse)
294
315
 
295
316
  # @!visibility private
296
- DEFAULT_DETACHED_AGENT_SOCKET_PATH = "aikido-detached-agent.sock"
317
+ DEFAULT_DETACHED_AGENT_SOCKET_PATH = "aikido-detached-agent.%h.sock"
297
318
 
298
319
  # @!visibility private
299
320
  DEFAULT_BLOCKED_RESPONDER = ->(request, blocking_type) do
@@ -34,7 +34,7 @@ module Aikido::Zen::DetachedAgent
34
34
 
35
35
  @collector = collector
36
36
 
37
- @front_object = DRbObject.new_with_uri(config.detached_agent_socket_uri)
37
+ @front_object = DRbObject.new_with_uri(config.expanded_detached_agent_socket_uri)
38
38
 
39
39
  @has_forked = false
40
40
  schedule_tasks
@@ -16,8 +16,8 @@ module Aikido::Zen::DetachedAgent
16
16
 
17
17
  @config = config
18
18
 
19
- @socket_path = config.detached_agent_socket_path
20
- @socket_uri = config.detached_agent_socket_uri
19
+ @socket_path = config.expanded_detached_agent_socket_path
20
+ @socket_uri = config.expanded_detached_agent_socket_uri
21
21
  end
22
22
 
23
23
  def started?
@@ -27,7 +27,7 @@ module Aikido::Zen
27
27
  {
28
28
  payload: value.to_s,
29
29
  source: SOURCE_SERIALIZATIONS[source],
30
- path: path.to_s
30
+ path: ".#{path}"
31
31
  }
32
32
  end
33
33
 
@@ -27,12 +27,20 @@ module Aikido::Zen
27
27
 
28
28
  def self.wrap_request(req, session)
29
29
  uri = req.uri if req.uri.is_a?(URI)
30
- uri ||= URI(format("%<scheme>s://%<hostname>s:%<port>s%<path>s", {
31
- scheme: session.use_ssl? ? "https" : "http",
32
- hostname: session.address,
33
- port: session.port,
34
- path: req.path
35
- }))
30
+
31
+ if uri.nil?
32
+ request_uri = URI.parse(req.path)
33
+
34
+ uri = URI.parse(
35
+ URI::Generic.build(
36
+ scheme: session.use_ssl? ? "https" : "http",
37
+ host: session.address,
38
+ port: session.port,
39
+ path: request_uri.path,
40
+ query: request_uri.query
41
+ ).to_s
42
+ )
43
+ end
36
44
 
37
45
  Scanners::SSRFScanner::Request.new(
38
46
  verb: req.method,
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Aikido
4
4
  module Zen
5
- VERSION = "1.1.0"
5
+ VERSION = "1.1.1"
6
6
 
7
7
  # The version of libzen_internals that we build against.
8
8
  LIBZEN_VERSION = "0.1.48"
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.1.0
4
+ version: 1.1.1
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-01-13 00:00:00.000000000 Z
11
+ date: 2026-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby