sbsm 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +6 -0
- data/lib/sbsm/app.rb +18 -3
- data/lib/sbsm/session.rb +39 -7
- data/lib/sbsm/session_store.rb +3 -3
- data/lib/sbsm/user.rb +1 -1
- data/lib/sbsm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c931f28d24233cb0c46c2f1e6341a8a451037918
|
4
|
+
data.tar.gz: abfdbcc5d3464f7ae2eeab161eaf02319f70e568
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7f94a54e9f0e73fd5ad64747720302448c12717665a94f8c769f041a987b8a86ef1ce9967ef9932f1a758aedfec4d30fea6a3d1bff94cd93b18d378469fc918
|
7
|
+
data.tar.gz: 57e179ccda3ea1eb5053992b71311f939aee63a72db164d761ff128ac13823d1d1c90140461454974399e00f1ddad4734cfc1533bbc145ea95ab82321a5a7b36
|
data/History.txt
CHANGED
data/lib/sbsm/app.rb
CHANGED
@@ -117,9 +117,24 @@ module SBSM
|
|
117
117
|
session = Thread.current.thread_variable_get(:session)
|
118
118
|
SBSM.debug "starting session_id #{session_id} session #{session.class} #{request.path}: cookies #{@cookie_name} are #{request.cookies} @cgi #{@cgi.class}"
|
119
119
|
res = session.process_rack(rack_request: request)
|
120
|
-
|
121
|
-
|
122
|
-
|
120
|
+
thru = session.get_passthru
|
121
|
+
if thru.size > 0
|
122
|
+
file_name = thru.first.untaint
|
123
|
+
response.set_header('Content-Type', MimeMagic.by_extension(File.extname(file_name)).type)
|
124
|
+
response.headers['Content-Disposition'] = "#{thru.last}; filename=#{File.basename(file_name)}"
|
125
|
+
response.headers['Content-Length'] = File.size(file_name).to_s
|
126
|
+
begin
|
127
|
+
response.write(File.open(file_name, File::RDONLY){|file| file.read})
|
128
|
+
rescue Errno::ENOENT, IOError => err
|
129
|
+
SBSM.error("#{err.message} #{thru.first}")
|
130
|
+
return [404, {}, []]
|
131
|
+
end
|
132
|
+
else
|
133
|
+
response.write res
|
134
|
+
response.headers['Content-Type'] ||= 'text/html; charset=utf-8'
|
135
|
+
response.headers.merge!(session.http_headers)
|
136
|
+
end
|
137
|
+
|
123
138
|
if (result = response.headers.find { |k,v| /status/i.match(k) })
|
124
139
|
response.status = result.last.to_i
|
125
140
|
response.headers.delete(result.first)
|
data/lib/sbsm/session.rb
CHANGED
@@ -36,7 +36,7 @@ require 'delegate'
|
|
36
36
|
module SBSM
|
37
37
|
class Session
|
38
38
|
|
39
|
-
attr_reader :user, :active_thread, :key, :cookie_input, :cookie_name,
|
39
|
+
attr_reader :user, :active_thread, :key, :cookie_input, :cookie_name, :post_content,
|
40
40
|
:server_name, :server_port, :request_params, :request_method, :request_origin,
|
41
41
|
:unsafe_input, :valid_input, :request_path, :request_post, :cgi, :attended_states
|
42
42
|
attr_accessor :validator, :trans_handler, :app
|
@@ -108,12 +108,12 @@ module SBSM
|
|
108
108
|
def initialize(app:,
|
109
109
|
trans_handler: nil,
|
110
110
|
validator: nil,
|
111
|
-
unknown_user:
|
111
|
+
unknown_user: SBSM::UnknownUser.new,
|
112
112
|
cookie_name: nil,
|
113
113
|
multi_threaded: false)
|
114
|
-
SBSM.info "initialize th #{trans_handler} validator #{validator} app #{app.class}"
|
114
|
+
SBSM.info "initialize th #{trans_handler} validator #{validator} app #{app.class} multi_threaded #{multi_threaded}"
|
115
115
|
@app = app
|
116
|
-
@unknown_user =
|
116
|
+
@unknown_user = unknown_user.is_a?(Class) ? unknown_user.new : unknown_user
|
117
117
|
@validator = validator if validator.is_a?(SBSM::Validator)
|
118
118
|
@validator ||= (validator && validator.new) || Validator.new
|
119
119
|
fail "invalid validator #{@validator}" unless @validator.is_a?(SBSM::Validator)
|
@@ -146,6 +146,8 @@ module SBSM
|
|
146
146
|
end
|
147
147
|
def unknown_user
|
148
148
|
@unknown_user || SBSM::UnknownUser.new
|
149
|
+
puts "unknown_user set to #{@unknown_user} class #{ @unknown_user.is_a?(Class)}"
|
150
|
+
@unknown_user = @unknown_user.new if @unknown_user.is_a?(Class)
|
149
151
|
end
|
150
152
|
def age(now=Time.now)
|
151
153
|
now - @mtime
|
@@ -203,7 +205,31 @@ module SBSM
|
|
203
205
|
end
|
204
206
|
def process_rack(rack_request:)
|
205
207
|
start = Time.now
|
208
|
+
@passthru = false
|
209
|
+
@disposition = false
|
206
210
|
@request_path ||= rack_request.path
|
211
|
+
@rack_request = rack_request
|
212
|
+
@post_content = nil
|
213
|
+
if rack_request.request_method.eql?('POST')
|
214
|
+
rack_request.params.each do |k, v|
|
215
|
+
# needed to test POST requests generated by curl (first parameter) or ARC (second parameter)
|
216
|
+
if /xml/i.match(k)
|
217
|
+
@post_content = "#{k} #{v}"
|
218
|
+
break
|
219
|
+
end
|
220
|
+
end
|
221
|
+
begin
|
222
|
+
# needed for request generated by https://github.com/wiztools/rest-client
|
223
|
+
rack_request.body.rewind # just to be sure
|
224
|
+
@post_content = rack_request.body.read
|
225
|
+
end unless @post_content
|
226
|
+
if @post_content
|
227
|
+
SBSM.debug "@post_content is #{@post_content}"
|
228
|
+
else
|
229
|
+
SBSM.debug "rack_request is #{rack_request}"
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
207
233
|
rack_request.params.each { |key, val| @cgi.params.store(key, val) }
|
208
234
|
@trans_handler.translate_uri(rack_request)
|
209
235
|
html = @mutex.synchronize do
|
@@ -381,7 +407,7 @@ module SBSM
|
|
381
407
|
end
|
382
408
|
def logout
|
383
409
|
__checkout
|
384
|
-
@user =
|
410
|
+
@user = @unknown_user
|
385
411
|
@active_state = @state = self::class::DEFAULT_STATE.new(self, @user)
|
386
412
|
SBSM.debug "logout #{request_path.inspect} setting @state #{@state.object_id} #{@state.class} remember #{persistent_user_input(:remember).inspect} #{@user.class}"
|
387
413
|
@state.init
|
@@ -430,8 +456,14 @@ module SBSM
|
|
430
456
|
def navigation
|
431
457
|
@user.navigation
|
432
458
|
end
|
433
|
-
|
434
|
-
|
459
|
+
def get_passthru
|
460
|
+
@passthru ? [@passthru, @disposition] : []
|
461
|
+
end
|
462
|
+
def passthru(path, disposition='attachment')
|
463
|
+
# the variable @passthru is set by a trusted source
|
464
|
+
@passthru = path.untaint
|
465
|
+
@disposition = disposition
|
466
|
+
''
|
435
467
|
end
|
436
468
|
def persistent_user_input(key)
|
437
469
|
if(value = user_input(key))
|
data/lib/sbsm/session_store.rb
CHANGED
@@ -55,7 +55,7 @@ module SBSM
|
|
55
55
|
session_class: nil,
|
56
56
|
validator: nil,
|
57
57
|
cookie_name: nil,
|
58
|
-
unknown_user:
|
58
|
+
unknown_user: UNKNOWN_USER.new,
|
59
59
|
multi_threaded: nil)
|
60
60
|
fail "You must specify an app!" unless app
|
61
61
|
@sessions = {}
|
@@ -69,8 +69,8 @@ module SBSM
|
|
69
69
|
@trans_handler ||= TransHandler.instance
|
70
70
|
@session_class = session_class
|
71
71
|
@session_class ||= SBSM::Session
|
72
|
-
@unknown_user = unknown_user
|
73
|
-
@unknown_user ||=
|
72
|
+
@unknown_user = unknown_user.is_a?(Class) ? unknown_user.new : unknown_user
|
73
|
+
@unknown_user ||= UnknownUser.new
|
74
74
|
@validator = validator
|
75
75
|
end
|
76
76
|
def cap_max_sessions(now = Time.now)
|
data/lib/sbsm/user.rb
CHANGED
data/lib/sbsm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|