closeyourit-ruby 0.3.2 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e319cd48ab53d0933f14344dc8ea2ac503ed7537b8111789fd540cf6bc3d65f
4
- data.tar.gz: 2f7d6223045d8c9aea2ad4d1b9b6bac4cd1420cbc8abe2bd91622855cb45dfae
3
+ metadata.gz: 82202d393845e74a379b6470a2f5f1c9e093d70840669266fb86624edd326c48
4
+ data.tar.gz: 7a302acfe53c9e0eb866ba407e9133bb63681c3d365126abdbf55368527ab7e4
5
5
  SHA512:
6
- metadata.gz: 4d37a064316618dcbee1b2a82626f950dc62e20dc22db3f7b8c6d14373ae1d307a20570ead272959536a1a337cceb3a13375e87edb5c2af23c1eeceae14fbee1
7
- data.tar.gz: 937873c344d55dd765cedae07d1b7d05fb531012c22b616f4e22d6a8130fd26059a65cc8e949a1336b3ab97788d8e930118e451a13e1a51c2e4c6bccdcdb0efb
6
+ metadata.gz: b85ebd77af24ee4aaa41ab447ba434be2ac3892c0ba4c7b09cf5a39069aca91ddb649a179ef621d72c263449452dcb5942c82df5449cd17e37a3494c374b8ed0
7
+ data.tar.gz: 037b9982aad55978b4c124d0751da800983327d18d8786228d8bbd00233f913a0e6ef8dd7e741c06307f11ed425ba2e37b8eae9dc985fba7c2067a9cbafda7fa
@@ -4,6 +4,11 @@ module CloseYourIt
4
4
  # Compone Transport + BackgroundWorker: applica `before_send` e dispatcha
5
5
  # l'invio in modo fire-and-forget.
6
6
  class Client
7
+ # Tetto di log per singola richiesta a /logs. Il backend rifiuta un batch oltre questo limite
8
+ # (413 R413-LOG-002) scartando l'INTERA richiesta — e il buffer è già stato drenato → log persi.
9
+ # Deve restare ≤ del limite server (LOGS_MAX_BATCH backend = 1000). Vedi #flush_logs.
10
+ LOGS_MAX_BATCH = 1000
11
+
7
12
  def initialize(configuration)
8
13
  @configuration = configuration
9
14
  @transport = Transport.new(configuration)
@@ -25,7 +30,10 @@ module CloseYourIt
25
30
  end
26
31
 
27
32
  # Invia un batch di log come ARRAY a /logs (l'endpoint accetta singolo o array). before_send è
28
- # applicato a ciascun payload; quelli scartati (nil) non vengono inviati.
33
+ # applicato a ciascun payload; quelli scartati (nil) non vengono inviati. I payload oltre
34
+ # LOGS_MAX_BATCH sono spezzati in più POST sequenziali (un chunk = un POST), così un flush grande
35
+ # non viene rigettato in blocco dal backend e perso — vedi R3 / LOGS_MAX_BATCH. Un flush entro il
36
+ # limite resta un singolo POST.
29
37
  def flush_logs(events)
30
38
  return nil if events.nil? || events.empty?
31
39
 
@@ -34,7 +42,9 @@ module CloseYourIt
34
42
  return nil if payloads.empty?
35
43
 
36
44
  path = events.first.ingest_path(@configuration.project_id)
37
- @worker.perform { @transport.send_event(payloads, path: path) }
45
+ payloads.each_slice(LOGS_MAX_BATCH) do |chunk|
46
+ @worker.perform { @transport.send_event(chunk, path: path) }
47
+ end
38
48
  payloads
39
49
  end
40
50
 
@@ -76,13 +76,15 @@ module CloseYourIt
76
76
  end
77
77
 
78
78
  # Sottoinsieme non vuoto in forma evento Sentry (user/tags/extra/contexts/request),
79
- # fuso nel payload da ErrorEvent#to_h.
79
+ # fuso nel payload da ErrorEvent#to_h. tags/extra/contexts passano dallo Scrubber (denylist
80
+ # ricorsiva per chiave): il backend NON li ri-scruba (Errors::Ingest::Normalize li conserva
81
+ # verbatim), quindi questa è l'unica rete di sicurezza contro le chiavi sensibili lì — R2.
80
82
  def to_event_hash
81
83
  {
82
84
  "user" => serialize_user,
83
- "tags" => presence(@tags),
84
- "extra" => presence(@extra),
85
- "contexts" => presence(@contexts),
85
+ "tags" => scrub(presence(@tags)),
86
+ "extra" => scrub(presence(@extra)),
87
+ "contexts" => scrub(presence(@contexts)),
86
88
  "request" => @request,
87
89
  "breadcrumbs" => breadcrumbs_payload
88
90
  }.reject { |_key, value| value.nil? }
@@ -90,6 +92,15 @@ module CloseYourIt
90
92
 
91
93
  private
92
94
 
95
+ # Redige i valori delle chiavi sensibili preservando la struttura (es. contexts.runtime resta
96
+ # intatto, solo i valori sotto chiavi sensibili diventano [FILTERED]). Riusa lo Scrubber della
97
+ # configurazione, lo stesso percorso di breadcrumb.data e degli attributi di log.
98
+ def scrub(hash)
99
+ return hash if hash.nil?
100
+
101
+ Scrubber.new(CloseYourIt.configuration).filter_params(hash)
102
+ end
103
+
93
104
  # `user.id` sempre; email/ip_address/username solo con `send_pii` (il backend li strippa
94
105
  # comunque — difesa in profondità).
95
106
  def serialize_user
@@ -6,10 +6,14 @@ module CloseYourIt
6
6
  class Scrubber
7
7
  FILTERED = "[FILTERED]"
8
8
 
9
- # Token di chiavi sempre redatti (match per sottostringa, normalizzato).
9
+ # Token di chiavi sempre redatti (match per sottostringa, normalizzato). Allineato 1:1 al regex
10
+ # di backend e client Dart (parità client-side) — vedi Errors/Logs::Ingest::Normalize::SENSITIVE_KEY:
11
+ # /pass|secret|token|api[_-]?key|apikey|authorization|cookie|csrf|credit|card|cvv|ssn|iban/i
12
+ # `pass` copre password/passwd/pass_code/passkey/passphrase; `cookie` copre set-cookie;
13
+ # `credit`+`card` coprono credit_card. La lista letterale precedente ometteva i `pass*` bare → leak.
10
14
  DENYLIST = %w[
11
- password passwd secret token api_key apikey authorization
12
- cookie set-cookie csrf credit_card card cvv ssn iban
15
+ pass secret token api_key apikey authorization
16
+ cookie csrf credit card cvv ssn iban
13
17
  ].freeze
14
18
 
15
19
  STRING_LITERAL = /'(?:[^']|'')*'/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloseYourIt
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: closeyourit-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessio Bussolari