lhc 15.0.0 → 15.0.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/lib/lhc/scrubbers/headers_scrubber.rb +14 -2
 - data/lib/lhc/version.rb +1 -1
 - data/spec/request/scrubbed_headers_spec.rb +18 -16
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: d9747364f9001f462e35cdc26b209f078daac57834bb4c1a801866f29abc2ba7
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e03286ea873459b7093baef6c47807edb4a1543889e887bf0d708c0144b6a087
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: bc2238780fe87969d1dea621d44960febb3a19e7b650a5e6ce7939f942e47acd01a825e64c39ab4fb4dbeb5636aef1e0819b3f874b95c22461cee4d63ad44368
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: cc5a2707f9772cc79a3caa3aa96b3c0ffe1a0984fa06446e48a61a9c08240145d772b35b993f11ec24c278367c9db4d2bf35dafee1aa444818323e2aab3c99b6
         
     | 
| 
         @@ -25,14 +25,26 @@ class LHC::HeadersScrubber < LHC::Scrubber 
     | 
|
| 
       25 
25 
     | 
    
         
             
              end
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
              def scrub_basic_authentication_headers!
         
     | 
| 
       28 
     | 
    
         
            -
                return if  
     | 
| 
      
 28 
     | 
    
         
            +
                return if !scrub_basic_authentication_headers?
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                scrubbed['Authorization'].gsub!(auth_options[:basic][:base_64_encoded_credentials], SCRUB_DISPLAY)
         
     | 
| 
       31 
31 
     | 
    
         
             
              end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
              def scrub_bearer_authentication_headers!
         
     | 
| 
       34 
     | 
    
         
            -
                return if  
     | 
| 
      
 34 
     | 
    
         
            +
                return if !scrub_bearer_authentication_headers?
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         
             
                scrubbed['Authorization'].gsub!(auth_options[:bearer_token], SCRUB_DISPLAY)
         
     | 
| 
       37 
37 
     | 
    
         
             
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              def scrub_basic_authentication_headers?
         
     | 
| 
      
 40 
     | 
    
         
            +
                auth_options[:basic].present? &&
         
     | 
| 
      
 41 
     | 
    
         
            +
                  scrubbed['Authorization'].present? &&
         
     | 
| 
      
 42 
     | 
    
         
            +
                  scrubbed['Authorization'].include?(auth_options[:basic][:base_64_encoded_credentials])
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              def scrub_bearer_authentication_headers?
         
     | 
| 
      
 46 
     | 
    
         
            +
                auth_options[:bearer].present? &&
         
     | 
| 
      
 47 
     | 
    
         
            +
                  scrubbed['Authorization'].present? &&
         
     | 
| 
      
 48 
     | 
    
         
            +
                  scrubbed['Authorization'].include?(auth_options[:bearer_token])
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
       38 
50 
     | 
    
         
             
            end
         
     | 
    
        data/lib/lhc/version.rb
    CHANGED
    
    
| 
         @@ -59,19 +59,20 @@ describe LHC::Request do 
     | 
|
| 
       59 
59 
     | 
    
         
             
                  let(:authorization_header) { { 'Authorization' => "Bearer #{bearer_token}" } }
         
     | 
| 
       60 
60 
     | 
    
         
             
                  let(:auth) { { bearer: -> { bearer_token } } }
         
     | 
| 
       61 
61 
     | 
    
         | 
| 
       62 
     | 
    
         
            -
                  it ' 
     | 
| 
      
 62 
     | 
    
         
            +
                  it 'scrubs only the bearer token' do
         
     | 
| 
       63 
63 
     | 
    
         
             
                    expect(request.scrubbed_headers).to include('Authorization' => "Bearer #{LHC::Scrubber::SCRUB_DISPLAY}")
         
     | 
| 
       64 
64 
     | 
    
         
             
                    expect(request.headers).to include(authorization_header)
         
     | 
| 
       65 
65 
     | 
    
         
             
                  end
         
     | 
| 
       66 
66 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
                   
     | 
| 
       68 
     | 
    
         
            -
                     
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                     
     | 
| 
      
 67 
     | 
    
         
            +
                  it 'scrubs whole "Authorization" header' do
         
     | 
| 
      
 68 
     | 
    
         
            +
                    LHC.config.scrubs[:headers] << 'Authorization'
         
     | 
| 
      
 69 
     | 
    
         
            +
                    expect(request.scrubbed_headers).to include('Authorization' => LHC::Scrubber::SCRUB_DISPLAY)
         
     | 
| 
      
 70 
     | 
    
         
            +
                    expect(request.headers).to include(authorization_header)
         
     | 
| 
      
 71 
     | 
    
         
            +
                  end
         
     | 
| 
       71 
72 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                     
     | 
| 
      
 73 
     | 
    
         
            +
                  it 'scrubs nothing' do
         
     | 
| 
      
 74 
     | 
    
         
            +
                    LHC.config.scrubs = {}
         
     | 
| 
      
 75 
     | 
    
         
            +
                    expect(request.scrubbed_headers).to include(authorization_header)
         
     | 
| 
       75 
76 
     | 
    
         
             
                  end
         
     | 
| 
       76 
77 
     | 
    
         
             
                end
         
     | 
| 
       77 
78 
     | 
    
         | 
| 
         @@ -82,19 +83,20 @@ describe LHC::Request do 
     | 
|
| 
       82 
83 
     | 
    
         
             
                  let(:authorization_header) { { 'Authorization' => "Basic #{credentials_base_64_codiert}" } }
         
     | 
| 
       83 
84 
     | 
    
         
             
                  let(:auth) { { basic: { username: username, password: password } } }
         
     | 
| 
       84 
85 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
                  it ' 
     | 
| 
      
 86 
     | 
    
         
            +
                  it 'scrubs only credentials' do
         
     | 
| 
       86 
87 
     | 
    
         
             
                    expect(request.scrubbed_headers).to include('Authorization' => "Basic #{LHC::Scrubber::SCRUB_DISPLAY}")
         
     | 
| 
       87 
88 
     | 
    
         
             
                    expect(request.headers).to include(authorization_header)
         
     | 
| 
       88 
89 
     | 
    
         
             
                  end
         
     | 
| 
       89 
90 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
                   
     | 
| 
       91 
     | 
    
         
            -
                     
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
                     
     | 
| 
      
 91 
     | 
    
         
            +
                  it 'scrubs whole "Authorization" header' do
         
     | 
| 
      
 92 
     | 
    
         
            +
                    LHC.config.scrubs[:headers] << 'Authorization'
         
     | 
| 
      
 93 
     | 
    
         
            +
                    expect(request.scrubbed_headers).to include('Authorization' => LHC::Scrubber::SCRUB_DISPLAY)
         
     | 
| 
      
 94 
     | 
    
         
            +
                    expect(request.headers).to include(authorization_header)
         
     | 
| 
      
 95 
     | 
    
         
            +
                  end
         
     | 
| 
       94 
96 
     | 
    
         | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
                     
     | 
| 
      
 97 
     | 
    
         
            +
                  it 'scrubs nothing' do
         
     | 
| 
      
 98 
     | 
    
         
            +
                    LHC.config.scrubs = {}
         
     | 
| 
      
 99 
     | 
    
         
            +
                    expect(request.scrubbed_headers).to include(authorization_header)
         
     | 
| 
       98 
100 
     | 
    
         
             
                  end
         
     | 
| 
       99 
101 
     | 
    
         
             
                end
         
     | 
| 
       100 
102 
     | 
    
         
             
              end
         
     |