closeyourit-ruby 0.11.0 → 0.12.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 +4 -4
- data/README.md +17 -9
- data/lib/closeyourit/configuration.rb +9 -1
- data/lib/closeyourit/events/slow_method_event.rb +4 -2
- data/lib/closeyourit/rails/railtie.rb +7 -0
- data/lib/closeyourit/scope.rb +3 -1
- data/lib/closeyourit/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8e0fc4eed9289e8fbb3ac2b93e6bcf71c950200b24483be93ca9b03cbb5edf5
|
|
4
|
+
data.tar.gz: bec0fc92de3a19b85caa500e41953726a1693ca8f757cd98022b8b5287e83f76
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f39ecd3584260bf7257fb8efc7fcf12222a2adec2fa2d1ba7ff3a59e368ae6c6e52921d5c83dda516c588946d718c4407aa934d6f495cfd9269621226fd58555
|
|
7
|
+
data.tar.gz: a634e8af76d32b12d1ffe210e73d3070c8059d15a55953caed9406d2c8db7fbeaac0f34bf800ee049bf9b4cdcb737d0239f3968978b970bb1175f42dfca3f0c5
|
data/README.md
CHANGED
|
@@ -52,7 +52,7 @@ In CloseYourIt, area **Member → Project → tokens**, crea un token: ottieni i
|
|
|
52
52
|
```ruby
|
|
53
53
|
# config/initializers/closeyourit.rb
|
|
54
54
|
CloseYourIt.init do |c|
|
|
55
|
-
c.endpoint_url = ENV["CLOSEYOURIT_ENDPOINT_URL"] # es. https://
|
|
55
|
+
c.endpoint_url = ENV["CLOSEYOURIT_ENDPOINT_URL"] # es. https://app.closeyour.it (host canonico)
|
|
56
56
|
c.token = ENV["CLOSEYOURIT_TOKEN"] # Bearer secret del Projects::Token
|
|
57
57
|
c.project_id = ENV["CLOSEYOURIT_PROJECT_ID"] # UUID del progetto su CloseYourIt
|
|
58
58
|
c.environment = Rails.env
|
|
@@ -62,9 +62,8 @@ end
|
|
|
62
62
|
**Senza `endpoint_url` / `token` / `project_id` la gemma è no-op** (nessun invio, nessun overhead). In
|
|
63
63
|
`production` un `endpoint_url` `http://` viene rifiutato (no-op + warning): il token viaggerebbe in chiaro.
|
|
64
64
|
|
|
65
|
-
> **Endpoint:** usa l'host canonico **`https://
|
|
66
|
-
>
|
|
67
|
-
> direttamente a www risparmia un hop per ogni evento.
|
|
65
|
+
> **Endpoint:** usa l'host canonico **`https://app.closeyour.it`**. Le installazioni già configurate su
|
|
66
|
+
> `https://www.closeyour.it` continuano a funzionare: l'ingest su `www` resta inoltrato all'app.
|
|
68
67
|
|
|
69
68
|
### Opzioni
|
|
70
69
|
|
|
@@ -84,7 +83,9 @@ end
|
|
|
84
83
|
| `slow_query_threshold_ms` | `100` | Soglia query lente |
|
|
85
84
|
| `excluded_query_patterns` | `solid_queue_`, `solid_cache_`, `solid_cable_` | Query da NON misurare come rallentamento — **Regexp** (pattern) o **String** (testo letterale). Vale solo per la misura: breadcrumb e profiling N+1 vedono tutto |
|
|
86
85
|
| `slow_method_threshold_ms` | `200` | Soglia metodi lenti |
|
|
86
|
+
| `capture_method_arguments` | `false` | Allega gli argomenti di `measure`/`monitor` ai `slow_method`. **Attenzione**: gli argomenti sono spesso dati personali; la gemma redige chiavi sensibili, credenziali e `scrub_message_patterns`, non il resto |
|
|
87
87
|
| `capture_request` | `true` | Cattura il contesto HTTP della richiesta (method/url/header allowlist) |
|
|
88
|
+
| `capture_request_body` | `true` | Allega i parametri del body (`request.data`) all'errore, scrubbati. Vale **solo con `send_pii = true`**: con la privacy spenta il body non parte mai |
|
|
88
89
|
| `request_header_allowlist` | `Accept`, `Content-Type`, `User-Agent`, `Referer` | Header inviati (mai Authorization/Cookie) |
|
|
89
90
|
| `breadcrumbs_enabled` | `true` | Cronologia (query offuscate + `add_breadcrumb`) allegata all'errore |
|
|
90
91
|
| `max_breadcrumbs` | `100` | Dimensione max del ring buffer breadcrumbs |
|
|
@@ -92,7 +93,7 @@ end
|
|
|
92
93
|
| `report_active_job_errors` | `true` | Cattura gli errori dei job ActiveJob/Solid Queue/Sidekiq |
|
|
93
94
|
| `send_pii` | `false` | Master switch PII |
|
|
94
95
|
| `obfuscate_sql` | `true` | Maschera i literal nello SQL |
|
|
95
|
-
| `filter_parameters` | `[]` | Chiavi extra da redarre (
|
|
96
|
+
| `filter_parameters` | `[]` | Chiavi extra da redarre, in aggiunta a `Rails.application.config.filter_parameters` (unite automaticamente dalla Railtie) |
|
|
96
97
|
| `scrub_message_patterns` | `[]` | Regexp **aggiuntive** da redarre da messaggi d'eccezione **e da `message` dei log**; le credenziali `Bearer`/`Basic`/`Token` sono già redatte di serie |
|
|
97
98
|
| `logs_enabled` | `true` | Master switch dello stream di log strutturato |
|
|
98
99
|
| `logs_min_level` | `:info` | Soglia minima: i log sotto (es. `debug`) non vengono inviati |
|
|
@@ -155,7 +156,9 @@ end
|
|
|
155
156
|
|
|
156
157
|
Un Rack middleware allega a ogni evento il contesto HTTP della richiesta: **method**, **url** (senza
|
|
157
158
|
query string) e gli **header dell'allowlist** (`request_header_allowlist`, mai Authorization/Cookie).
|
|
158
|
-
Query string e
|
|
159
|
+
Query string, IP e **parametri del body** (`request.data`, scrubbati, estratti solo quando scoppia
|
|
160
|
+
l'errore; `capture_request_body` li spegne) solo con `send_pii`. Lo scope è resettato a fine richiesta
|
|
161
|
+
(niente bleed tra request).
|
|
159
162
|
|
|
160
163
|
### Background job + errori handled (automatico, con Rails)
|
|
161
164
|
|
|
@@ -312,7 +315,10 @@ end
|
|
|
312
315
|
```
|
|
313
316
|
|
|
314
317
|
Viene inviato un `slow_method` solo se la durata supera `slow_method_threshold_ms`. **Gli argomenti
|
|
315
|
-
del metodo non vengono
|
|
318
|
+
del metodo non vengono inviati** (solo label, durata, file:riga) salvo `capture_method_arguments = true`:
|
|
319
|
+
in quel caso partono con `inspect` troncato, redatti per chiave sensibile (kwargs), credenziali
|
|
320
|
+
`Bearer`/`Basic`/`Token` e `scrub_message_patterns`. Tutto il resto arriva in chiaro: accendilo solo
|
|
321
|
+
su metodi che non ricevono dati personali.
|
|
316
322
|
|
|
317
323
|
## Performance issues (opt-in)
|
|
318
324
|
|
|
@@ -406,8 +412,10 @@ Privacy-by-default (`send_pii = false`). In sintesi:
|
|
|
406
412
|
(`Authorization: Bearer …`, `Basic …`, `Token …`) sono redatte **di serie**, senza configurazione:
|
|
407
413
|
chiave e schema restano leggibili, sparisce il valore → `Authorization: Bearer [FILTERED]`. Il resto
|
|
408
414
|
è redigibile con `scrub_message_patterns` / `before_send`.
|
|
409
|
-
- **
|
|
410
|
-
|
|
415
|
+
- **Solo con `send_pii`**: query string, IP, email/username dell'utente e parametri del body
|
|
416
|
+
(`capture_request_body`). Con la privacy spenta non partono, qualunque sia il resto della configurazione.
|
|
417
|
+
- **Mai inviati**: variabili locali dei frame, cookie/Authorization, token (che viaggia solo nell'header
|
|
418
|
+
su HTTPS). Gli argomenti dei metodi solo con `capture_method_arguments` (opt-in, vedi sopra).
|
|
411
419
|
|
|
412
420
|
> Rischio residuo: `exception.value` e i nomi tabella/colonna nello SQL possono contenere dati di
|
|
413
421
|
> dominio. Usa `before_send`/`scrub_message_patterns` per azzerarli. Dettaglio in [`PDR.md` §9](PDR.md).
|
|
@@ -94,7 +94,8 @@ module CloseYourIt
|
|
|
94
94
|
|
|
95
95
|
# Request body params in the event (`request.data`), extracted LAZILY only when the error
|
|
96
96
|
# happens, sanitized and scrubbed (denylist + filter_parameters). The backend scrubs again
|
|
97
|
-
# defensively. Uploads → placeholder, 64 KB cap.
|
|
97
|
+
# defensively. Uploads → placeholder, 64 KB cap. Gated by send_pii: with it OFF the body
|
|
98
|
+
# is never sent, whatever this flag says (CYRB-28).
|
|
98
99
|
@capture_request_body = true
|
|
99
100
|
|
|
100
101
|
# Breadcrumbs: history (obfuscated queries, custom events) attached to the error.
|
|
@@ -200,6 +201,13 @@ module CloseYourIt
|
|
|
200
201
|
@filter_parameters = Array(list)
|
|
201
202
|
end
|
|
202
203
|
|
|
204
|
+
# Adds the host app's `Rails.application.config.filter_parameters` (strings/symbols/regexps) to the
|
|
205
|
+
# gem list, without duplicates. Rails filter procs are dropped: they mutate values in place, while
|
|
206
|
+
# the Scrubber matches keys only (CYRB-28).
|
|
207
|
+
def merge_filter_parameters(list)
|
|
208
|
+
@filter_parameters |= Array(list).reject { |item| item.respond_to?(:call) }
|
|
209
|
+
end
|
|
210
|
+
|
|
203
211
|
# Destinations allowed to receive the W3C trace headers. String = exact host (case-insensitive
|
|
204
212
|
# match), Regexp = pattern (for subdomains/host families). Empty list = none.
|
|
205
213
|
def trace_propagation_allowlist=(list)
|
|
@@ -42,7 +42,9 @@ module CloseYourIt
|
|
|
42
42
|
private
|
|
43
43
|
|
|
44
44
|
# Arguments — ONLY with capture_method_arguments (opt-in). Positional by index; kwargs by name with
|
|
45
|
-
# sensitive key scrubbing (denylist password/token/…). Value = truncated inspect (JSON-safe)
|
|
45
|
+
# sensitive key scrubbing (denylist password/token/…). Value = truncated inspect (JSON-safe),
|
|
46
|
+
# passed through the message scrubber (auth schemes + scrub_message_patterns) like exception
|
|
47
|
+
# messages, so a token inside a positional argument never leaves the app (CYRB-28).
|
|
46
48
|
def arguments
|
|
47
49
|
return nil unless @configuration.capture_method_arguments
|
|
48
50
|
|
|
@@ -54,7 +56,7 @@ module CloseYourIt
|
|
|
54
56
|
end
|
|
55
57
|
|
|
56
58
|
def safe_value(value)
|
|
57
|
-
inspected = value.inspect.to_s
|
|
59
|
+
inspected = @scrubber.scrub_message(value.inspect.to_s)
|
|
58
60
|
inspected.length > 120 ? "#{inspected[0, 117]}…" : inspected
|
|
59
61
|
end
|
|
60
62
|
end
|
|
@@ -100,6 +100,13 @@ module CloseYourIt
|
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
+
# Keys the app declared sensitive via config.filter_parameters are scrubbed by the gem too.
|
|
104
|
+
# `after: :load_config_initializers`: CloseYourIt.init (config/initializers/closeyourit.rb)
|
|
105
|
+
# replaces the configuration, so an earlier merge would be lost (CYRB-28).
|
|
106
|
+
initializer "closeyourit.merge_rails_filter_parameters", after: :load_config_initializers do |app|
|
|
107
|
+
CloseYourIt.configuration.merge_filter_parameters(app.config.filter_parameters)
|
|
108
|
+
end
|
|
109
|
+
|
|
103
110
|
# Captures Sidekiq job errors + measures duration/wait via server middleware (only when Sidekiq
|
|
104
111
|
# is present). The middleware is effectively a no-op when monitor_jobs is OFF (the decision
|
|
105
112
|
# lives in JobPerformance#record).
|
data/lib/closeyourit/scope.rb
CHANGED
|
@@ -139,8 +139,10 @@ module CloseYourIt
|
|
|
139
139
|
data ? @request.merge("data" => data) : @request
|
|
140
140
|
end
|
|
141
141
|
|
|
142
|
+
# Body params are user input (PII): sent only with send_pii AND capture_request_body (CYRB-28).
|
|
142
143
|
def request_body_data
|
|
143
|
-
|
|
144
|
+
config = CloseYourIt.configuration
|
|
145
|
+
return nil unless config.send_pii && config.capture_request_body
|
|
144
146
|
return nil if @rack_env.nil?
|
|
145
147
|
|
|
146
148
|
Rails::RequestBody.extract(@rack_env)
|
data/lib/closeyourit/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.12.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alessio Bussolari
|
|
@@ -90,12 +90,12 @@ files:
|
|
|
90
90
|
- lib/closeyourit/transport.rb
|
|
91
91
|
- lib/closeyourit/usage_registry.rb
|
|
92
92
|
- lib/closeyourit/version.rb
|
|
93
|
-
homepage: https://github.com/bussolabs/closeyourit-ruby
|
|
93
|
+
homepage: https://github.com/bussolabs/closeyourit-ruby-community
|
|
94
94
|
licenses:
|
|
95
95
|
- MIT
|
|
96
96
|
metadata:
|
|
97
|
-
homepage_uri: https://github.com/bussolabs/closeyourit-ruby
|
|
98
|
-
source_code_uri: https://github.com/bussolabs/closeyourit-ruby
|
|
97
|
+
homepage_uri: https://github.com/bussolabs/closeyourit-ruby-community
|
|
98
|
+
source_code_uri: https://github.com/bussolabs/closeyourit-ruby-community
|
|
99
99
|
rdoc_options: []
|
|
100
100
|
require_paths:
|
|
101
101
|
- lib
|