Skip to content

Commit 0124fe3

Browse files
authored
Merge pull request #28 from securenative/dev
Filter out unnecessary headers
2 parents 0193fd3 + 91e059c commit 0124fe3

File tree

8 files changed

+74
-65
lines changed

8 files changed

+74
-65
lines changed

Gemfile.lock

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
11
PATH
22
remote: .
33
specs:
4-
securenative (0.1.33)
4+
securenative (0.1.34)
55

66
GEM
77
remote: https://rubygems.org/
88
specs:
9-
actioncable (6.0.3.3)
10-
actionpack (= 6.0.3.3)
9+
actioncable (6.0.3.4)
10+
actionpack (= 6.0.3.4)
1111
nio4r (~> 2.0)
1212
websocket-driver (>= 0.6.1)
13-
actionmailbox (6.0.3.3)
14-
actionpack (= 6.0.3.3)
15-
activejob (= 6.0.3.3)
16-
activerecord (= 6.0.3.3)
17-
activestorage (= 6.0.3.3)
18-
activesupport (= 6.0.3.3)
13+
actionmailbox (6.0.3.4)
14+
actionpack (= 6.0.3.4)
15+
activejob (= 6.0.3.4)
16+
activerecord (= 6.0.3.4)
17+
activestorage (= 6.0.3.4)
18+
activesupport (= 6.0.3.4)
1919
mail (>= 2.7.1)
20-
actionmailer (6.0.3.3)
21-
actionpack (= 6.0.3.3)
22-
actionview (= 6.0.3.3)
23-
activejob (= 6.0.3.3)
20+
actionmailer (6.0.3.4)
21+
actionpack (= 6.0.3.4)
22+
actionview (= 6.0.3.4)
23+
activejob (= 6.0.3.4)
2424
mail (~> 2.5, >= 2.5.4)
2525
rails-dom-testing (~> 2.0)
26-
actionpack (6.0.3.3)
27-
actionview (= 6.0.3.3)
28-
activesupport (= 6.0.3.3)
26+
actionpack (6.0.3.4)
27+
actionview (= 6.0.3.4)
28+
activesupport (= 6.0.3.4)
2929
rack (~> 2.0, >= 2.0.8)
3030
rack-test (>= 0.6.3)
3131
rails-dom-testing (~> 2.0)
3232
rails-html-sanitizer (~> 1.0, >= 1.2.0)
33-
actiontext (6.0.3.3)
34-
actionpack (= 6.0.3.3)
35-
activerecord (= 6.0.3.3)
36-
activestorage (= 6.0.3.3)
37-
activesupport (= 6.0.3.3)
33+
actiontext (6.0.3.4)
34+
actionpack (= 6.0.3.4)
35+
activerecord (= 6.0.3.4)
36+
activestorage (= 6.0.3.4)
37+
activesupport (= 6.0.3.4)
3838
nokogiri (>= 1.8.5)
39-
actionview (6.0.3.3)
40-
activesupport (= 6.0.3.3)
39+
actionview (6.0.3.4)
40+
activesupport (= 6.0.3.4)
4141
builder (~> 3.1)
4242
erubi (~> 1.4)
4343
rails-dom-testing (~> 2.0)
4444
rails-html-sanitizer (~> 1.1, >= 1.2.0)
45-
activejob (6.0.3.3)
46-
activesupport (= 6.0.3.3)
45+
activejob (6.0.3.4)
46+
activesupport (= 6.0.3.4)
4747
globalid (>= 0.3.6)
48-
activemodel (6.0.3.3)
49-
activesupport (= 6.0.3.3)
50-
activerecord (6.0.3.3)
51-
activemodel (= 6.0.3.3)
52-
activesupport (= 6.0.3.3)
53-
activestorage (6.0.3.3)
54-
actionpack (= 6.0.3.3)
55-
activejob (= 6.0.3.3)
56-
activerecord (= 6.0.3.3)
48+
activemodel (6.0.3.4)
49+
activesupport (= 6.0.3.4)
50+
activerecord (6.0.3.4)
51+
activemodel (= 6.0.3.4)
52+
activesupport (= 6.0.3.4)
53+
activestorage (6.0.3.4)
54+
actionpack (= 6.0.3.4)
55+
activejob (= 6.0.3.4)
56+
activerecord (= 6.0.3.4)
5757
marcel (~> 0.3.1)
58-
activesupport (6.0.3.3)
58+
activesupport (6.0.3.4)
5959
concurrent-ruby (~> 1.0, >= 1.0.2)
6060
i18n (>= 0.7, < 2)
6161
minitest (~> 5.1)
@@ -64,7 +64,7 @@ GEM
6464
addressable (2.7.0)
6565
public_suffix (>= 2.0.2, < 5.0)
6666
builder (3.2.4)
67-
codecov (0.2.11)
67+
codecov (0.2.12)
6868
json
6969
simplecov
7070
concurrent-ruby (1.1.7)
@@ -177,29 +177,29 @@ GEM
177177
rack
178178
rack-test (1.1.0)
179179
rack (>= 1.0, < 3)
180-
rails (6.0.3.3)
181-
actioncable (= 6.0.3.3)
182-
actionmailbox (= 6.0.3.3)
183-
actionmailer (= 6.0.3.3)
184-
actionpack (= 6.0.3.3)
185-
actiontext (= 6.0.3.3)
186-
actionview (= 6.0.3.3)
187-
activejob (= 6.0.3.3)
188-
activemodel (= 6.0.3.3)
189-
activerecord (= 6.0.3.3)
190-
activestorage (= 6.0.3.3)
191-
activesupport (= 6.0.3.3)
180+
rails (6.0.3.4)
181+
actioncable (= 6.0.3.4)
182+
actionmailbox (= 6.0.3.4)
183+
actionmailer (= 6.0.3.4)
184+
actionpack (= 6.0.3.4)
185+
actiontext (= 6.0.3.4)
186+
actionview (= 6.0.3.4)
187+
activejob (= 6.0.3.4)
188+
activemodel (= 6.0.3.4)
189+
activerecord (= 6.0.3.4)
190+
activestorage (= 6.0.3.4)
191+
activesupport (= 6.0.3.4)
192192
bundler (>= 1.3.0)
193-
railties (= 6.0.3.3)
193+
railties (= 6.0.3.4)
194194
sprockets-rails (>= 2.0.0)
195195
rails-dom-testing (2.0.3)
196196
activesupport (>= 4.2.0)
197197
nokogiri (>= 1.6)
198198
rails-html-sanitizer (1.3.0)
199199
loofah (~> 2.3)
200-
railties (6.0.3.3)
201-
actionpack (= 6.0.3.3)
202-
activesupport (= 6.0.3.3)
200+
railties (6.0.3.4)
201+
actionpack (= 6.0.3.4)
202+
activesupport (= 6.0.3.4)
203203
method_source
204204
rake (>= 0.8.7)
205205
thor (>= 0.20.3, < 2.0)
@@ -242,7 +242,7 @@ GEM
242242
thread_safe (~> 0.1)
243243
url_mount (0.2.1)
244244
rack
245-
webmock (3.9.1)
245+
webmock (3.9.2)
246246
addressable (>= 2.3.6)
247247
crack (>= 0.3.2)
248248
hashdiff (>= 0.4.0, < 2.0.0)

lib/securenative/frameworks/hanami.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ def self.get_method(request)
3535

3636
def self.get_headers(request)
3737
begin
38-
# Note: At the moment we're filtering out everything but user-agent since ruby's payload is way too big
39-
{ 'user-agent' => request.env['HTTP_USER_AGENT'] }
38+
headers = []
39+
request.headers.env.select { |k, _| k.in?(ActionDispatch::Http::Headers::CGI_VARIABLES) || k =~ /^HTTP_/ }.each { |header|
40+
headers.append(header[0].downcase.gsub("http_", "").gsub("_", "-"))
41+
}
42+
return headers
4043
rescue StandardError
4144
nil
4245
end

lib/securenative/frameworks/rails.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def self.get_method(request)
3737

3838
def self.get_headers(request)
3939
begin
40-
# Note: At the moment we're filtering out everything but user-agent since ruby's payload is way too big
41-
{'user-agent' => request.env['HTTP_USER_AGENT']}
40+
headers = []
41+
request.headers.env.select { |k, _| k.in?(ActionDispatch::Http::Headers::CGI_VARIABLES) || k =~ /^HTTP_/ }.each { |header|
42+
headers.append(header[0].downcase.gsub("http_", "").gsub("_", "-"))
43+
}
44+
return headers
4245
rescue StandardError
4346
nil
4447
end

lib/securenative/frameworks/sinatra.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ def self.get_method(request)
3535

3636
def self.get_headers(request)
3737
begin
38-
# Note: At the moment we're filtering out everything but user-agent since ruby's payload is way too big
39-
{'user-agent' => request.env['HTTP_USER_AGENT']}
38+
headers = []
39+
request.headers.env.select { |k, _| k.in?(ActionDispatch::Http::Headers::CGI_VARIABLES) || k =~ /^HTTP_/ }.each { |header|
40+
headers.append(header[0].downcase.gsub("http_", "").gsub("_", "-"))
41+
}
42+
return headers
4043
rescue StandardError
4144
nil
4245
end

lib/securenative/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module SecureNative
4-
VERSION = '0.1.33'
4+
VERSION = '0.1.34'
55
end

spec/securenative/spec_api_manager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
5656
'Authorization' => 'YOUR_API_KEY',
5757
'Content-Type' => 'application/json',
58-
'Sn-Version' => '0.1.33',
58+
'Sn-Version' => '0.1.34',
5959
'User-Agent' => 'SecureNative-ruby'
6060
}
6161
).to_return(status: 200, body: '', headers: {})

spec/securenative/spec_event_manager.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def initialize
2929
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
3030
'Authorization' => 'YOUR_API_KEY',
3131
'Content-Type' => 'application/json',
32-
'Sn-Version' => '0.1.33',
32+
'Sn-Version' => '0.1.34',
3333
'User-Agent' => 'SecureNative-ruby'
3434
})
3535
.to_return(status: 200, body: '', headers: {})
@@ -53,7 +53,7 @@ def initialize
5353
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
5454
'Authorization' => 'YOUR_API_KEY',
5555
'Content-Type' => 'application/json',
56-
'Sn-Version' => '0.1.33',
56+
'Sn-Version' => '0.1.34',
5757
'User-Agent' => 'SecureNative-ruby'
5858
})
5959
.to_return(status: 401, body: '', headers: {})
@@ -74,7 +74,7 @@ def initialize
7474
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
7575
'Authorization' => 'YOUR_API_KEY',
7676
'Content-Type' => 'application/json',
77-
'Sn-Version' => '0.1.33',
77+
'Sn-Version' => '0.1.34',
7878
'User-Agent' => 'SecureNative-ruby'
7979
})
8080
.to_return(status: 500, body: '', headers: {})

spec/securenative/spec_http_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
1616
'Authorization' => 'YOUR_API_KEY',
1717
'Content-Type' => 'application/json',
18-
'Sn-Version' => '0.1.33',
18+
'Sn-Version' => '0.1.34',
1919
'User-Agent' => 'SecureNative-ruby'
2020
}).to_return(status: 200, body: '', headers: {})
2121

0 commit comments

Comments
 (0)