Module: RailsAiBridge::Registry::MessageSanitizer
- Defined in:
- lib/rails_ai_bridge/registry/message_sanitizer.rb
Overview
Redacts URLs, SSH URIs, file paths, and credential fields from error messages before they are included in provider error results. Prevents raw transport errors from leaking endpoints, query strings, file paths, or credential values (tokens, passwords, API keys) into Doctor output.
Class Method Summary collapse
-
.sanitize(message) ⇒ String
Sanitized message with URLs, paths, and credentials redacted.
Class Method Details
.sanitize(message) ⇒ String
Returns sanitized message with URLs, paths, and credentials redacted.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rails_ai_bridge/registry/message_sanitizer.rb', line 12 def self.sanitize() .to_s .gsub(%r{[a-z][a-z0-9+.-]+://[^\s]+}i, '[redacted]') .gsub(/git@[^\s]+/, '[redacted]') .gsub(%r{(?<=\s|^|\(|'|"|`)/[A-Za-z0-9_.-]+(?:/[^\s]*)?}, '[redacted]') .gsub(/[A-Za-z]:\\[^\s]+/, '[redacted]') .gsub(/(?i:bearer\s+[^\s]+)/, '[redacted]') .gsub(/(?i:"(access_token|token|password|secret|api_key|apikey|authorization|auth_token)"\s*[:=]\s*"?[^",\s}]+)/, '[redacted]') .gsub(/(?i:(access_token|token|password|secret|api_key|apikey|authorization|auth_token)\s*[:=]\s*"?[^\s,}]+)/, '[redacted]') end |