police-labels 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 +12 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +9 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/lib/police-labels.rb +2 -0
- data/lib/police/labels.rb +11 -0
- data/lib/police/labels/unsafe_stream.rb +47 -0
- data/lib/police/labels/unsafe_string.rb +30 -0
- data/police-labels.gemspec +37 -0
- data/test/helper.rb +23 -0
- data/test/helpers/proxying_fixture.rb +45 -0
- data/test/labels/unsafe_stream_test.rb +18 -0
- metadata +65 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'police-dataflow', '>= 0.0.1', path: '../police-dataflow'
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem 'bundler', '>= 1.1.0'
|
7
|
+
gem 'jeweler', '>= 1.8.3'
|
8
|
+
gem 'minitest', '>= 2.11.2'
|
9
|
+
gem 'rdoc', '>= 3.12'
|
10
|
+
gem 'simplecov', '>= 0.6.1'
|
11
|
+
gem 'yard', '>= 0.7'
|
12
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../police-dataflow
|
3
|
+
specs:
|
4
|
+
police-dataflow (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
git (1.2.5)
|
10
|
+
jeweler (1.8.3)
|
11
|
+
bundler (~> 1.0)
|
12
|
+
git (>= 1.2.5)
|
13
|
+
rake
|
14
|
+
rdoc
|
15
|
+
json (1.6.5)
|
16
|
+
minitest (2.11.3)
|
17
|
+
multi_json (1.1.0)
|
18
|
+
rake (0.9.2.2)
|
19
|
+
rdoc (3.12)
|
20
|
+
json (~> 1.4)
|
21
|
+
simplecov (0.6.1)
|
22
|
+
multi_json (~> 1.0)
|
23
|
+
simplecov-html (~> 0.5.3)
|
24
|
+
simplecov-html (0.5.3)
|
25
|
+
yard (0.7.5)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
bundler (>= 1.1.0)
|
32
|
+
jeweler (>= 1.8.3)
|
33
|
+
minitest (>= 2.11.2)
|
34
|
+
police-dataflow (>= 0.0.1)!
|
35
|
+
rdoc (>= 3.12)
|
36
|
+
simplecov (>= 0.6.1)
|
37
|
+
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-labels"
|
18
|
+
gem.homepage = "http://github.com/csail/police"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Collection of label implementations for policed applications}
|
21
|
+
gem.description = %Q{Supplies labels impelementing safety and privacy policies}
|
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
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Police
|
2
|
+
|
3
|
+
module Labels
|
4
|
+
|
5
|
+
# Adds a label to any data read from a IO stream.
|
6
|
+
class UnsafeStream < Police::DataFlow::Label
|
7
|
+
# @param [Police::DataFlow::Label] unsafe_label the label that will be added
|
8
|
+
# to the stream's data
|
9
|
+
def initialize(unsafe_label)
|
10
|
+
@label = unsafe_label
|
11
|
+
end
|
12
|
+
|
13
|
+
# @see Police::DataFlow::Label#autoflow?
|
14
|
+
def self.autoflow?
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
# @see Police::DataFlow::Label#accepts?
|
19
|
+
def accepts?(data)
|
20
|
+
data.kind_of?(IO) || data.kind_of?(StringIO)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @see Police::DataFlow::Label#return_hook
|
24
|
+
def self.return_hook(method_name)
|
25
|
+
case method_name
|
26
|
+
when :read
|
27
|
+
:read
|
28
|
+
else
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# @see Police::DataFlow::Label#yield_args_hook
|
34
|
+
def self.yield_args_hook(method_name)
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
# Adds a label to the read's return value.
|
39
|
+
# @see IO#read
|
40
|
+
def read(return_value, receiver, *args)
|
41
|
+
Police::DataFlow.label return_value, @label
|
42
|
+
end
|
43
|
+
end # namespace Police::Labels::UnsafeStream
|
44
|
+
|
45
|
+
end # namespace Labels
|
46
|
+
|
47
|
+
end # namespace Police
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Police
|
2
|
+
|
3
|
+
module Labels
|
4
|
+
|
5
|
+
# Marks strings that are read from the outside environment with no sanitization.
|
6
|
+
class UnsafeString < Police::DataFlow::Label
|
7
|
+
# @see Police::DataFlow::Label#autoflow?
|
8
|
+
def self.autoflow?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
|
12
|
+
# @see Police::DataFlow::Label#accept?
|
13
|
+
def accept?(data)
|
14
|
+
data.kind_of? String
|
15
|
+
end
|
16
|
+
|
17
|
+
# @see Police::DataFlow::Label#return_hook
|
18
|
+
def self.return_hook(method_name)
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
# @see Police::DataFlow::Label#yield_args_hook
|
23
|
+
def self.yield_args_hook(method_name)
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
end # namepsace Police::Labels::UnsafeString
|
27
|
+
|
28
|
+
end # namespace Labels
|
29
|
+
|
30
|
+
end # namespace Police
|
@@ -0,0 +1,37 @@
|
|
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-labels"
|
8
|
+
s.version = "0.0.0"
|
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-18"
|
13
|
+
s.description = "Supplies labels impelementing safety and privacy policies"
|
14
|
+
s.email = "victor@costan.us"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"VERSION"
|
21
|
+
]
|
22
|
+
s.homepage = "http://github.com/csail/police"
|
23
|
+
s.licenses = ["MIT"]
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
s.rubygems_version = "1.8.17"
|
26
|
+
s.summary = "Collection of label implementations for policed applications"
|
27
|
+
|
28
|
+
if s.respond_to? :specification_version then
|
29
|
+
s.specification_version = 3
|
30
|
+
|
31
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
32
|
+
else
|
33
|
+
end
|
34
|
+
else
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
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-labels'
|
16
|
+
|
17
|
+
class MiniTest::Unit::TestCase
|
18
|
+
end
|
19
|
+
|
20
|
+
Dir[File.expand_path('helpers/**/*.rb', File.dirname(__FILE__))].
|
21
|
+
each { |h| require h }
|
22
|
+
|
23
|
+
MiniTest::Unit.autorun
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class ProxyingFixture
|
2
|
+
# Zero arguments.
|
3
|
+
def length; end
|
4
|
+
|
5
|
+
# One argument.
|
6
|
+
def ==(other)
|
7
|
+
'== proxied'
|
8
|
+
end
|
9
|
+
|
10
|
+
# Reserved method proxying test.
|
11
|
+
def !=(other)
|
12
|
+
'!= proxied'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Two arguments.
|
16
|
+
def add(arg1, arg2)
|
17
|
+
"#{arg1}, #{arg2}"
|
18
|
+
end
|
19
|
+
protected :add
|
20
|
+
|
21
|
+
# Variable args.
|
22
|
+
def route(*rest)
|
23
|
+
if block_given?
|
24
|
+
yield(*rest)
|
25
|
+
else
|
26
|
+
rest
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# One fixed + variable args.
|
31
|
+
def <=>(arg1, *rest); end
|
32
|
+
|
33
|
+
# Two fixed + variable args.
|
34
|
+
def log(arg1, arg2, *rest); end
|
35
|
+
private :log
|
36
|
+
|
37
|
+
# Magic methods: magic_* methods return their name and args
|
38
|
+
def method_missing(name, *args)
|
39
|
+
if name[0, 6] == 'magic_'
|
40
|
+
[name[6..-1]] + args
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end # class ProxyingFixture
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Police::Labels::UnsafeStream do
|
4
|
+
let(:unsafe_label) { Police::Labels::UnsafeString.new }
|
5
|
+
let(:label) { Police::Labels::UnsafeStream.new unsafe_label }
|
6
|
+
|
7
|
+
it 'accepts STDIN' do
|
8
|
+
label.accepts?(STDIN).must_equal true
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'does not accept strings' do
|
12
|
+
label.accepts?('Some string').must_equal false
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'accepts a StringIO' do
|
16
|
+
label.accepts?(StringIO.new('Some string')).must_equal true
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: police-labels
|
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: Supplies labels impelementing safety and privacy policies
|
15
|
+
email: victor@costan.us
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files:
|
19
|
+
- LICENSE.txt
|
20
|
+
- README.markdown
|
21
|
+
files:
|
22
|
+
- .document
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- LICENSE.txt
|
26
|
+
- README.markdown
|
27
|
+
- Rakefile
|
28
|
+
- VERSION
|
29
|
+
- lib/police-labels.rb
|
30
|
+
- lib/police/labels.rb
|
31
|
+
- lib/police/labels/unsafe_stream.rb
|
32
|
+
- lib/police/labels/unsafe_string.rb
|
33
|
+
- police-labels.gemspec
|
34
|
+
- test/helper.rb
|
35
|
+
- test/helpers/proxying_fixture.rb
|
36
|
+
- test/labels/unsafe_stream_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: -1318543965834563250
|
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: Collection of label implementations for policed applications
|
65
|
+
test_files: []
|