police-rack 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +9 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/lib/police-rack.rb +2 -0
- data/lib/police/rack.rb +11 -0
- data/lib/police/rack/middleware.rb +28 -0
- data/police-rack.gemspec +50 -0
- data/test/helper.rb +26 -0
- data/test/helpers/app_fixture.rb +23 -0
- data/test/rack/middleware_test.rb +12 -0
- metadata +65 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'police-dataflow', '>= 0.0.1', path: '../police-dataflow'
|
4
|
+
gem 'police-labels', '>= 0.0.1', path: '../police-labels'
|
5
|
+
gem 'rack', '>= 1.4.1'
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'bundler', '>= 1.1.0'
|
9
|
+
gem 'jeweler', '>= 1.8.3'
|
10
|
+
gem 'minitest', '>= 2.11.2'
|
11
|
+
gem 'rack-test', '>= 0.6.1'
|
12
|
+
gem 'rdoc', '>= 3.12'
|
13
|
+
gem 'simplecov', '>= 0.6.1'
|
14
|
+
gem 'yard', '>= 0.7'
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../police-dataflow
|
3
|
+
specs:
|
4
|
+
police-dataflow (0.0.1)
|
5
|
+
|
6
|
+
PATH
|
7
|
+
remote: ../police-labels
|
8
|
+
specs:
|
9
|
+
police-labels (0.0.1)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: http://rubygems.org/
|
13
|
+
specs:
|
14
|
+
git (1.2.5)
|
15
|
+
jeweler (1.8.3)
|
16
|
+
bundler (~> 1.0)
|
17
|
+
git (>= 1.2.5)
|
18
|
+
rake
|
19
|
+
rdoc
|
20
|
+
json (1.6.6)
|
21
|
+
minitest (2.11.4)
|
22
|
+
multi_json (1.2.0)
|
23
|
+
rack (1.4.1)
|
24
|
+
rack-test (0.6.1)
|
25
|
+
rack (>= 1.0)
|
26
|
+
rake (0.9.2.2)
|
27
|
+
rdoc (3.12)
|
28
|
+
json (~> 1.4)
|
29
|
+
simplecov (0.6.1)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
simplecov-html (~> 0.5.3)
|
32
|
+
simplecov-html (0.5.3)
|
33
|
+
yard (0.7.5)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
bundler (>= 1.1.0)
|
40
|
+
jeweler (>= 1.8.3)
|
41
|
+
minitest (>= 2.11.2)
|
42
|
+
police-dataflow (>= 0.0.1)!
|
43
|
+
police-labels (>= 0.0.1)!
|
44
|
+
rack (>= 1.4.1)
|
45
|
+
rack-test (>= 0.6.1)
|
46
|
+
rdoc (>= 3.12)
|
47
|
+
simplecov (>= 0.6.1)
|
48
|
+
yard (>= 0.7)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Massachusetts Institute of Technology
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "police-rack"
|
18
|
+
gem.homepage = "http://github.com/csail/police"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Rack middleware that integrates police}
|
21
|
+
gem.description = %Q{Labels HTTP input with police labels and provides hooks for filtering the application output}
|
22
|
+
gem.email = "victor@costan.us"
|
23
|
+
gem.authors = ["Victor Costan"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/*_test.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'yard'
|
38
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/lib/police-rack.rb
ADDED
data/lib/police/rack.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
module Police
|
2
|
+
|
3
|
+
# Rack middleware that labels HTTP input and filters the application output.
|
4
|
+
module Rack
|
5
|
+
end # namespace Police::Rack
|
6
|
+
|
7
|
+
end # namespace Police
|
8
|
+
|
9
|
+
require 'police/dataflow'
|
10
|
+
require 'police/labels'
|
11
|
+
require 'police/rack/middleware.rb'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Police
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
|
5
|
+
# Rack middleware that labels the HTTP input with UnsafeString.
|
6
|
+
class Middleware
|
7
|
+
def initialize(app, options = {})
|
8
|
+
@app = app
|
9
|
+
@unsafe_string = Police::Labels::UnsafeString.new
|
10
|
+
@unsafe_stream = Police::Labels::UnsafeStream.new @unsafe_string
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
label_env env
|
15
|
+
@app.call env
|
16
|
+
# TODO(pwnall): filter output
|
17
|
+
end
|
18
|
+
|
19
|
+
def label_env(env)
|
20
|
+
env['rack.input'] = Police::DataFlow.label env['rack.input'], @unsafe_stream
|
21
|
+
env['QUERY_STRING'] = Police::DataFlow.label env['QUERY_STRING'],
|
22
|
+
@unsafe_string
|
23
|
+
end
|
24
|
+
end # class Police::Rack::Middleware
|
25
|
+
|
26
|
+
end # class Police::Rack
|
27
|
+
|
28
|
+
end # class Police
|
data/police-rack.gemspec
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "police-rack"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Victor Costan"]
|
12
|
+
s.date = "2012-03-28"
|
13
|
+
s.description = "Labels HTTP input with police labels and provides hooks for filtering the application output"
|
14
|
+
s.email = "victor@costan.us"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.markdown",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/police-rack.rb",
|
28
|
+
"lib/police/rack.rb",
|
29
|
+
"lib/police/rack/middleware.rb",
|
30
|
+
"police-rack.gemspec",
|
31
|
+
"test/helper.rb",
|
32
|
+
"test/helpers/app_fixture.rb",
|
33
|
+
"test/rack/middleware_test.rb"
|
34
|
+
]
|
35
|
+
s.homepage = "http://github.com/csail/police"
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = "1.8.21"
|
39
|
+
s.summary = "Rack middleware that integrates police"
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
else
|
46
|
+
end
|
47
|
+
else
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'minitest/unit'
|
11
|
+
require 'minitest/spec'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
15
|
+
require 'police-rack'
|
16
|
+
|
17
|
+
require 'rack/test'
|
18
|
+
ENV['RACK_ENV'] = 'test'
|
19
|
+
class MiniTest::Unit::TestCase
|
20
|
+
include Rack::Test::Methods
|
21
|
+
end
|
22
|
+
|
23
|
+
Dir[File.expand_path('helpers/**/*.rb', File.dirname(__FILE__))].
|
24
|
+
each { |h| require h }
|
25
|
+
|
26
|
+
MiniTest::Unit.autorun
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class AppFixture
|
2
|
+
def call(env)
|
3
|
+
[200, {'Content-Type' => 'text/html'}, [""]]
|
4
|
+
end
|
5
|
+
|
6
|
+
def render(env)
|
7
|
+
<<END_HTML
|
8
|
+
<!doctype html>
|
9
|
+
<html>
|
10
|
+
<body>
|
11
|
+
<p>Hello #{env['rack.params']['name']}</p>
|
12
|
+
</boy>
|
13
|
+
</html>
|
14
|
+
END_HTML
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.app
|
18
|
+
Rack::Builder.new do
|
19
|
+
use Police::Rack::Middleware
|
20
|
+
run AppFixture.new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: police-rack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Victor Costan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-28 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Labels HTTP input with police labels and provides hooks for filtering
|
15
|
+
the application output
|
16
|
+
email: victor@costan.us
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files:
|
20
|
+
- LICENSE.txt
|
21
|
+
- README.markdown
|
22
|
+
files:
|
23
|
+
- .document
|
24
|
+
- Gemfile
|
25
|
+
- Gemfile.lock
|
26
|
+
- LICENSE.txt
|
27
|
+
- README.markdown
|
28
|
+
- Rakefile
|
29
|
+
- VERSION
|
30
|
+
- lib/police-rack.rb
|
31
|
+
- lib/police/rack.rb
|
32
|
+
- lib/police/rack/middleware.rb
|
33
|
+
- police-rack.gemspec
|
34
|
+
- test/helper.rb
|
35
|
+
- test/helpers/app_fixture.rb
|
36
|
+
- test/rack/middleware_test.rb
|
37
|
+
homepage: http://github.com/csail/police
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
hash: 114598452855662796
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.8.21
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: Rack middleware that integrates police
|
65
|
+
test_files: []
|