crawlberg 1.3.3 → 1.4.0

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.
@@ -1,5 +1,5 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:468e05d35782efa941278f63a0e1f24595cf4a534fa469e7747a18fe91938bbf
2
+ # alef:hash:4c0568b31b53eb28d5e56237159cb0d1c93079e2bbae63713fbc6b85e9683aa7
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify
5
5
  # frozen_string_literal: true
@@ -222,6 +222,108 @@ module Crawlberg
222
222
  end
223
223
  end
224
224
 
225
+ module Crawlberg
226
+ # Hostname/IP allowlist matcher for SSRF policy.
227
+ #
228
+ # Serializes as an internally-tagged object so each variant is distinguishable on the
229
+ # wire and round-trips losslessly:
230
+ #
231
+ # ```json
232
+ # {"type": "exact", "value": "api.example.com"}
233
+ # {"type": "suffix", "value": ".example.com"}
234
+ # {"type": "cidr", "value": "10.0.0.0/8"}
235
+ # ```
236
+ #
237
+ # A bare JSON string is still accepted on deserialization and resolves to [`Exact`],
238
+ # preserving configs written against the previous untagged representation.
239
+ #
240
+ # [`Exact`]: HostMatcher::Exact
241
+ module HostMatcher
242
+ extend T::Helpers
243
+ extend T::Sig
244
+
245
+ interface!
246
+
247
+ # Dispatch from a Hash to the appropriate variant constructor.
248
+ # @param hash [Hash] with discriminator field and variant-specific fields
249
+ # @return [variant_class] an instance of the appropriate variant
250
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
251
+ def self.from_hash(hash)
252
+ discriminator = hash[:type] || hash["type"]
253
+ case discriminator
254
+ when "exact" then HostMatcherExact.from_hash(hash)
255
+ when "suffix" then HostMatcherSuffix.from_hash(hash)
256
+ when "cidr" then HostMatcherCidr.from_hash(hash)
257
+ else raise "Unknown discriminator: #{discriminator}"
258
+ end
259
+ end
260
+ end
261
+ ## Exact hostname match (case-insensitive).
262
+ HostMatcherExact = Data.define(:value) do
263
+ include HostMatcher
264
+ extend T::Sig
265
+
266
+ # The hostname to match.
267
+ sig { returns(String) }
268
+ def value = super # rubocop:disable Lint/UselessMethodDefinition
269
+ sig { returns(T::Boolean) }
270
+ def exact? = true
271
+ sig { returns(T::Boolean) }
272
+ def suffix? = false
273
+ sig { returns(T::Boolean) }
274
+ def cidr? = false
275
+ # @param hash [Hash] deserialized from the native extension
276
+ # @return [self]
277
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
278
+ def self.from_hash(hash)
279
+ new(value: hash[:value] || hash["value"])
280
+ end
281
+ end
282
+ ## Suffix match: ".xberg.io" matches "api.xberg.io" and "xberg.io".
283
+ HostMatcherSuffix = Data.define(:value) do
284
+ include HostMatcher
285
+ extend T::Sig
286
+
287
+ # The dot-prefixed suffix to match. A leading dot is optional.
288
+ sig { returns(String) }
289
+ def value = super # rubocop:disable Lint/UselessMethodDefinition
290
+ sig { returns(T::Boolean) }
291
+ def exact? = false
292
+ sig { returns(T::Boolean) }
293
+ def suffix? = true
294
+ sig { returns(T::Boolean) }
295
+ def cidr? = false
296
+ # @param hash [Hash] deserialized from the native extension
297
+ # @return [self]
298
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
299
+ def self.from_hash(hash)
300
+ new(value: hash[:value] || hash["value"])
301
+ end
302
+ end
303
+ ## CIDR match: "10.0.0.0/8" matches IP addresses in that range.
304
+ HostMatcherCidr = Data.define(:value) do
305
+ include HostMatcher
306
+ extend T::Sig
307
+
308
+ # The CIDR block. Validated when built through [`HostMatcher::cidr`] or
309
+ # deserialization.
310
+ sig { returns(String) }
311
+ def value = super # rubocop:disable Lint/UselessMethodDefinition
312
+ sig { returns(T::Boolean) }
313
+ def exact? = false
314
+ sig { returns(T::Boolean) }
315
+ def suffix? = false
316
+ sig { returns(T::Boolean) }
317
+ def cidr? = true
318
+ # @param hash [Hash] deserialized from the native extension
319
+ # @return [self]
320
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
321
+ def self.from_hash(hash)
322
+ new(value: hash[:value] || hash["value"])
323
+ end
324
+ end
325
+ end
326
+
225
327
  module Crawlberg
226
328
  # A single page interaction action.
227
329
  #
@@ -519,105 +621,3 @@ module Crawlberg
519
621
  end
520
622
  end
521
623
  end
522
-
523
- module Crawlberg
524
- # Hostname/IP allowlist matcher for SSRF policy.
525
- #
526
- # Serializes as an internally-tagged object so each variant is distinguishable on the
527
- # wire and round-trips losslessly:
528
- #
529
- # ```json
530
- # {"type": "exact", "value": "api.example.com"}
531
- # {"type": "suffix", "value": ".example.com"}
532
- # {"type": "cidr", "value": "10.0.0.0/8"}
533
- # ```
534
- #
535
- # A bare JSON string is still accepted on deserialization and resolves to [`Exact`],
536
- # preserving configs written against the previous untagged representation.
537
- #
538
- # [`Exact`]: HostMatcher::Exact
539
- module HostMatcher
540
- extend T::Helpers
541
- extend T::Sig
542
-
543
- interface!
544
-
545
- # Dispatch from a Hash to the appropriate variant constructor.
546
- # @param hash [Hash] with discriminator field and variant-specific fields
547
- # @return [variant_class] an instance of the appropriate variant
548
- sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
549
- def self.from_hash(hash)
550
- discriminator = hash[:type] || hash["type"]
551
- case discriminator
552
- when "exact" then HostMatcherExact.from_hash(hash)
553
- when "suffix" then HostMatcherSuffix.from_hash(hash)
554
- when "cidr" then HostMatcherCidr.from_hash(hash)
555
- else raise "Unknown discriminator: #{discriminator}"
556
- end
557
- end
558
- end
559
- ## Exact hostname match (case-insensitive).
560
- HostMatcherExact = Data.define(:value) do
561
- include HostMatcher
562
- extend T::Sig
563
-
564
- # The hostname to match.
565
- sig { returns(String) }
566
- def value = super # rubocop:disable Lint/UselessMethodDefinition
567
- sig { returns(T::Boolean) }
568
- def exact? = true
569
- sig { returns(T::Boolean) }
570
- def suffix? = false
571
- sig { returns(T::Boolean) }
572
- def cidr? = false
573
- # @param hash [Hash] deserialized from the native extension
574
- # @return [self]
575
- sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
576
- def self.from_hash(hash)
577
- new(value: hash[:value] || hash["value"])
578
- end
579
- end
580
- ## Suffix match: ".xberg.io" matches "api.xberg.io" and "xberg.io".
581
- HostMatcherSuffix = Data.define(:value) do
582
- include HostMatcher
583
- extend T::Sig
584
-
585
- # The dot-prefixed suffix to match. A leading dot is optional.
586
- sig { returns(String) }
587
- def value = super # rubocop:disable Lint/UselessMethodDefinition
588
- sig { returns(T::Boolean) }
589
- def exact? = false
590
- sig { returns(T::Boolean) }
591
- def suffix? = true
592
- sig { returns(T::Boolean) }
593
- def cidr? = false
594
- # @param hash [Hash] deserialized from the native extension
595
- # @return [self]
596
- sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
597
- def self.from_hash(hash)
598
- new(value: hash[:value] || hash["value"])
599
- end
600
- end
601
- ## CIDR match: "10.0.0.0/8" matches IP addresses in that range.
602
- HostMatcherCidr = Data.define(:value) do
603
- include HostMatcher
604
- extend T::Sig
605
-
606
- # The CIDR block. Validated when built through [`HostMatcher::cidr`] or
607
- # deserialization.
608
- sig { returns(String) }
609
- def value = super # rubocop:disable Lint/UselessMethodDefinition
610
- sig { returns(T::Boolean) }
611
- def exact? = false
612
- sig { returns(T::Boolean) }
613
- def suffix? = false
614
- sig { returns(T::Boolean) }
615
- def cidr? = true
616
- # @param hash [Hash] deserialized from the native extension
617
- # @return [self]
618
- sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
619
- def self.from_hash(hash)
620
- new(value: hash[:value] || hash["value"])
621
- end
622
- end
623
- end
@@ -1,10 +1,10 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:9716830c37f9c6de3924a6ebdc2f8f077d296794b443399aa1d4c4f0d483169a
2
+ # alef:hash:0a9a0a6f7c1b865f2c375eef53bab2695c7dbf595519ca3bd7f5d258c2936ef7
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify
5
5
  # frozen_string_literal: true
6
6
 
7
7
  module Crawlberg
8
8
  ## The version string for this package.
9
- VERSION = "1.3.3"
9
+ VERSION = "1.4.0"
10
10
  end
data/lib/crawlberg.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:5f14772be973afec2e94293f27da4258e3399457f1e279dc68d4d55a011f6b3a
2
+ # alef:hash:72251b3aa02bf769e473206839c833cf616e70a8dd38735f5ff3a3a2849e8c0a
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify
5
5
  # frozen_string_literal: true