Skip to content
  • zzak's avatar
    357bb383
    Add inspect to ActiveStorage::Service, ActiveStorage::Service::Registry, and... · 357bb383
    zzak authored
    Add inspect to ActiveStorage::Service, ActiveStorage::Service::Registry, and ActiveStorage::Service::Configurator
    
    This was inspired by #50405.
    
    If you accidentally pretty print `ActiveStorage::Blob.services` and
    have the entire config which may contain secrets persit in logs or
    elsewhere.
    
    Or in Ruby 3.2 and older, raising an exception on those objects, e.g.
    `ActiveStorage::Blob.services[:local]` instead of `fetch`.
    
    Before:
    
    ```ruby
    pp ActiveStorage::Blob.services
      #<ActiveStorage::Service::Registry:0x00007f2a68469d28
        @configurations={
          :s3 => {
            :service=>"S3",
            :access_key_id=>"test_key",
            :secret_access_key=>"test_secret",
            :region=>"us-east-1",
            :bucket=>"rails-test"
          },
          :gcs => { :service=>"GCS", :credentials=> "secret-hash" }
        }
        @services={}>
    ```
    
    After
    
    ```ruby
      #<ActiveStorage::Service::Registry configurations=[:s3, :gcs]>
    ```
    357bb383
    Add inspect to ActiveStorage::Service, ActiveStorage::Service::Registry, and...
    zzak authored
    Add inspect to ActiveStorage::Service, ActiveStorage::Service::Registry, and ActiveStorage::Service::Configurator
    
    This was inspired by #50405.
    
    If you accidentally pretty print `ActiveStorage::Blob.services` and
    have the entire config which may contain secrets persit in logs or
    elsewhere.
    
    Or in Ruby 3.2 and older, raising an exception on those objects, e.g.
    `ActiveStorage::Blob.services[:local]` instead of `fetch`.
    
    Before:
    
    ```ruby
    pp ActiveStorage::Blob.services
      #<ActiveStorage::Service::Registry:0x00007f2a68469d28
        @configurations={
          :s3 => {
            :service=>"S3",
            :access_key_id=>"test_key",
            :secret_access_key=>"test_secret",
            :region=>"us-east-1",
            :bucket=>"rails-test"
          },
          :gcs => { :service=>"GCS", :credentials=> "secret-hash" }
        }
        @services={}>
    ```
    
    After
    
    ```ruby
      #<ActiveStorage::Service::Registry configurations=[:s3, :gcs]>
    ```
Loading