launchdarkly-server-sdk 8.2.0 → 8.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98f2eba56f5e878e25f09c11f1899a9e08528951f168c0c99f8a366dc2774e42
4
- data.tar.gz: fab62196eca4450f87753d937fa229f67eece5811b6f3f9c2080d7c974939017
3
+ metadata.gz: 2582d6e0bd754b6fbb46d591713cb9b6d3784ae991a498dfa0f810aa079c491e
4
+ data.tar.gz: 68c0369beb8e2bd6f3a865129591a392511a82f85b22fda5b8a8c3c7161f4fa1
5
5
  SHA512:
6
- metadata.gz: 1702df3413b7d6652d040a4e03ae46b303af04172db296e5351e0a7e656c8fd93e8e9f64d8582f8a03bc2d79d3d77c3dbead0cac71d196a6f0cdd686af62a476
7
- data.tar.gz: 27d299283793f15aab495d01e8ece7c92dd026a73a44ffbf29925272c82a6810ea264eb36691d383238cda4cfc88664a0f9b4fd077547d2661bec9f1b3070358
6
+ metadata.gz: 0516d7e11b48b9d582878270ff533138b73f9fdfb8d89a9dc6470c0aeff8d71a9139d5e7b77a4b5eb0e7c6083c33446ecdf9d57b394cfb650ac53426fee2cd06
7
+ data.tar.gz: 71f2eb165af4d1ef812f1360f326b2dfefe6be266c4d476737943661a3c2534f7f275bb02245e4718c653aaa2df3e07675af3a3e3ca1f451cfb045d2bac506c8
@@ -458,7 +458,7 @@ module LaunchDarkly
458
458
  # @return [Logger] the Rails logger if in Rails, or a default Logger at WARN level otherwise
459
459
  #
460
460
  def self.default_logger
461
- if defined?(Rails) && Rails.respond_to?(:logger)
461
+ if defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger
462
462
  Rails.logger
463
463
  else
464
464
  log = ::Logger.new($stdout)
@@ -481,12 +481,14 @@ module LaunchDarkly
481
481
  key: event.key,
482
482
  value: event.value,
483
483
  }
484
+
484
485
  out[:default] = event.default unless event.default.nil?
485
486
  out[:variation] = event.variation unless event.variation.nil?
486
487
  out[:version] = event.version unless event.version.nil?
487
488
  out[:prereqOf] = event.prereq_of unless event.prereq_of.nil?
488
- out[:contextKeys] = event.context.keys
489
+ out[:context] = @context_filter.filter_redact_anonymous(event.context)
489
490
  out[:reason] = event.reason unless event.reason.nil?
491
+
490
492
  out
491
493
 
492
494
  when LaunchDarkly::Impl::MigrationOpEvent
@@ -23,14 +23,32 @@ module LaunchDarkly
23
23
  # @return [Hash]
24
24
  #
25
25
  def filter(context)
26
- return filter_single_context(context, true) unless context.multi_kind?
26
+ internal_filter(context, false)
27
+ end
28
+
29
+ #
30
+ # Return a hash representation of the provided context with attribute
31
+ # redaction applied.
32
+ #
33
+ # If a context is anonyomous, all attributes will be redacted except
34
+ # for key, kind, and anonymous.
35
+ #
36
+ # @param context [LaunchDarkly::LDContext]
37
+ # @return [Hash]
38
+ #
39
+ def filter_redact_anonymous(context)
40
+ internal_filter(context, true)
41
+ end
42
+
43
+ private def internal_filter(context, redact_anonymous)
44
+ return filter_single_context(context, true, redact_anonymous) unless context.multi_kind?
27
45
 
28
46
  filtered = {kind: 'multi'}
29
47
  (0...context.individual_context_count).each do |i|
30
48
  c = context.individual_context(i)
31
49
  next if c.nil?
32
50
 
33
- filtered[c.kind] = filter_single_context(c, false)
51
+ filtered[c.kind] = filter_single_context(c, false, redact_anonymous)
34
52
  end
35
53
 
36
54
  filtered
@@ -43,22 +61,24 @@ module LaunchDarkly
43
61
  # @param include_kind [Boolean]
44
62
  # @return [Hash]
45
63
  #
46
- private def filter_single_context(context, include_kind)
64
+ private def filter_single_context(context, include_kind, redact_anonymous)
47
65
  filtered = {key: context.key}
48
66
 
49
67
  filtered[:kind] = context.kind if include_kind
50
- filtered[:anonymous] = true if context.get_value(:anonymous)
68
+
69
+ anonymous = context.get_value(:anonymous)
70
+ filtered[:anonymous] = true if anonymous
51
71
 
52
72
  redacted = []
53
73
  private_attributes = @private_attributes.concat(context.private_attributes)
54
74
 
55
75
  name = context.get_value(:name)
56
- if !name.nil? && !check_whole_attribute_private(:name, private_attributes, redacted)
76
+ if !name.nil? && !check_whole_attribute_private(:name, private_attributes, redacted, anonymous && redact_anonymous)
57
77
  filtered[:name] = name
58
78
  end
59
79
 
60
80
  context.get_custom_attribute_names.each do |attribute|
61
- unless check_whole_attribute_private(attribute, private_attributes, redacted)
81
+ unless check_whole_attribute_private(attribute, private_attributes, redacted, anonymous && redact_anonymous)
62
82
  value = context.get_value(attribute)
63
83
  filtered[attribute] = redact_json_value(nil, attribute, value, private_attributes, redacted)
64
84
  end
@@ -75,10 +95,11 @@ module LaunchDarkly
75
95
  # @param attribute [Symbol]
76
96
  # @param private_attributes [Array<Reference>]
77
97
  # @param redacted [Array<Symbol>]
98
+ # @param redact_all [Boolean]
78
99
  # @return [Boolean]
79
100
  #
80
- private def check_whole_attribute_private(attribute, private_attributes, redacted)
81
- if @all_attributes_private
101
+ private def check_whole_attribute_private(attribute, private_attributes, redacted, redact_all)
102
+ if @all_attributes_private || redact_all
82
103
  redacted << attribute
83
104
  return true
84
105
  end
@@ -37,7 +37,7 @@ module LaunchDarkly
37
37
  @off_variation = data[:offVariation]
38
38
  check_variation_range(self, errors, @off_variation, "off variation")
39
39
  @prerequisites = (data[:prerequisites] || []).map do |prereq_data|
40
- Prerequisite.new(prereq_data, self, errors)
40
+ Prerequisite.new(prereq_data, self)
41
41
  end
42
42
  @targets = (data[:targets] || []).map do |target_data|
43
43
  Target.new(target_data, self, errors)
@@ -118,13 +118,12 @@ module LaunchDarkly
118
118
  end
119
119
 
120
120
  class Prerequisite
121
- def initialize(data, flag, errors_out = nil)
121
+ def initialize(data, flag)
122
122
  @data = data
123
123
  @key = data[:key]
124
124
  @variation = data[:variation]
125
125
  @failure_result = EvaluatorHelpers.evaluation_detail_for_off_variation(flag,
126
126
  EvaluationReason::prerequisite_failed(@key))
127
- check_variation_range(flag, errors_out, @variation, "prerequisite")
128
127
  end
129
128
 
130
129
  # @return [Hash]
@@ -1,3 +1,3 @@
1
1
  module LaunchDarkly
2
- VERSION = "8.2.0" # x-release-please-version
2
+ VERSION = "8.3.1" # x-release-please-version
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: launchdarkly-server-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.0
4
+ version: 8.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - LaunchDarkly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-22 00:00:00.000000000 Z
11
+ date: 2024-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb