Skip to content

Commit 4d76d7e

Browse files
committed
Merge pull request #13 from stackify/SF-3435
SF-3435: Mask HTTP Authorization and Cookie header
2 parents 464f2bc + ea44108 commit 4d76d7e

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore built gem files
11+
/*.gem
12+
13+
# Ignore the default SQLite database.
14+
/db/*.sqlite3
15+
/db/*.sqlite3-journal
16+
17+
# Ignore all logfiles and tempfiles.
18+
/log/*.log
19+
/tmp
20+
21+
# Ignore IntelliJ files
22+
/.idea
23+
*.iml

Gemfile.lock

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
PATH
22
remote: .
33
specs:
4-
stackify-api-ruby (1.0.3)
4+
stackify-api-ruby (1.0.7)
55
faraday (>= 0.8)
66

77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
faraday (0.9.0)
10+
faraday (0.9.1)
1111
multipart-post (>= 1.2, < 3)
1212
multipart-post (2.0.0)
1313
rake (0.9.6)
@@ -19,3 +19,6 @@ DEPENDENCIES
1919
bundler (~> 1.6)
2020
rake (~> 0)
2121
stackify-api-ruby!
22+
23+
BUNDLED WITH
24+
1.10.6

lib/stackify/env_details.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ class EnvDetails
66
include Singleton
77
attr_reader :request_details
88

9+
@@masked_headers = %w(HTTP_AUTHORIZATION HTTP_COOKIE)
10+
@@masked_value = 'X-MASKED-X'
11+
12+
913
def initialize
1014
rails_info = defined?(Rails) ? Rails::Info.properties.to_h : nil
1115
@info = rails_info || { 'Application root' => Dir.pwd, 'Environment' => 'development'}
@@ -77,7 +81,8 @@ def cookies env
7781
end
7882

7983
def headers env
80-
env.reject{ |k| !(k.start_with?'HTTP_') }
84+
headers = env.reject{ |k| !(k.start_with?'HTTP_') }
85+
headers.each_key { | key | headers[key] = @@masked_value if @@masked_headers.include?(key) }
8186
end
8287

8388
def server_variables env

0 commit comments

Comments
 (0)