rufus-treechecker 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-treechecker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 4
9
+ version: 1.0.4
5
10
  platform: ruby
6
11
  authors:
7
12
  - John Mettraux
@@ -9,40 +14,78 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2008-10-29 00:00:00 +09:00
17
+ date: 2010-12-22 00:00:00 +09:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: ruby_parser
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 0
30
+ - 5
31
+ version: 2.0.5
17
32
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
20
38
  requirements:
21
39
  - - ">="
22
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
23
43
  version: "0"
24
- version:
25
- description:
26
- email: john at openwfe dot org
44
+ type: :development
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 2
55
+ - 0
56
+ version: "2.0"
57
+ type: :development
58
+ version_requirements: *id003
59
+ description: "\n tests strings of Ruby code for unauthorized patterns (exit, eval, ...)\n "
60
+ email:
61
+ - jmettraux@gmail.com
27
62
  executables: []
28
63
 
29
64
  extensions: []
30
65
 
31
- extra_rdoc_files:
32
- - README.txt
66
+ extra_rdoc_files: []
67
+
33
68
  files:
34
- - lib/rufus
69
+ - Rakefile
70
+ - lib/rufus/tree_checker.rb
35
71
  - lib/rufus/treechecker.rb
72
+ - lib/rufus-tree_checker.rb
36
73
  - lib/rufus-treechecker.rb
74
+ - spec/high_spec.rb
75
+ - spec/low_spec.rb
76
+ - spec/misc_spec.rb
77
+ - spec/ruleset_spec.rb
78
+ - spec/spec_base.rb
37
79
  - test/bm.rb
38
- - test/ft_0_basic.rb
39
- - test/ft_1_old_treechecker.rb
40
- - test/ft_2_clone.rb
41
- - test/test.rb
42
- - test/testmixin.rb
80
+ - rufus-treechecker.gemspec
81
+ - CHANGELOG.txt
82
+ - CREDITS.txt
83
+ - LICENSE.txt
43
84
  - README.txt
44
85
  has_rdoc: true
45
- homepage: http://rufus.rubyforge.org/rufus-treechecker
86
+ homepage: http://rufus.rubyforge.org
87
+ licenses: []
88
+
46
89
  post_install_message:
47
90
  rdoc_options: []
48
91
 
@@ -52,20 +95,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
95
  requirements:
53
96
  - - ">="
54
97
  - !ruby/object:Gem::Version
98
+ segments:
99
+ - 0
55
100
  version: "0"
56
- version:
57
101
  required_rubygems_version: !ruby/object:Gem::Requirement
58
102
  requirements:
59
103
  - - ">="
60
104
  - !ruby/object:Gem::Version
105
+ segments:
106
+ - 0
61
107
  version: "0"
62
- version:
63
- requirements:
64
- - ruby_parser
108
+ requirements: []
109
+
65
110
  rubyforge_project: rufus
66
- rubygems_version: 1.2.0
111
+ rubygems_version: 1.3.6
67
112
  signing_key:
68
- specification_version: 2
69
- summary: checking ruby code before eval()
70
- test_files:
71
- - test/test.rb
113
+ specification_version: 3
114
+ summary: tests strings of Ruby code for unauthorized patterns (exit, eval, ...)
115
+ test_files: []
116
+
data/test/ft_0_basic.rb DELETED
@@ -1,253 +0,0 @@
1
-
2
- #
3
- # Testing rufus-treechecker
4
- #
5
- # jmettraux at gmail.org
6
- #
7
- # Fri Aug 29 10:13:33 JST 2008
8
- #
9
-
10
- require 'testmixin'
11
-
12
-
13
- class BasicTest < Test::Unit::TestCase
14
- include TestMixin
15
-
16
-
17
- def test_0
18
-
19
- tc = Rufus::TreeChecker.new do
20
- exclude_vcall :abort
21
- exclude_fcall :abort
22
- exclude_call_to :abort
23
- exclude_fvcall :exit, :exit!
24
- exclude_call_to :exit
25
- exclude_call_to :exit!
26
- end
27
-
28
- assert_nok(tc, 'exit')
29
- assert_nok(tc, 'exit()')
30
- assert_nok(tc, 'exit!')
31
- assert_nok(tc, 'abort')
32
- assert_nok(tc, 'abort()')
33
- assert_nok(tc, 'Kernel.exit')
34
- assert_nok(tc, 'Kernel.exit()')
35
- assert_nok(tc, 'Kernel::exit')
36
- assert_nok(tc, 'Kernel::exit()')
37
- assert_nok(tc, '::Kernel.exit')
38
-
39
- assert_ok(tc, '1 + 1')
40
- end
41
-
42
- def test_0b_vm_exiting
43
-
44
- # TODO : implement me !
45
- end
46
-
47
- def test_1_global_vars
48
-
49
- tc = Rufus::TreeChecker.new do
50
- exclude_global_vars
51
- end
52
-
53
- assert_nok(tc, '$ENV')
54
- assert_nok(tc, '$ENV = {}')
55
- assert_nok(tc, "$ENV['HOME'] = 'away'")
56
- end
57
-
58
- def test_2_aliases
59
-
60
- tc = Rufus::TreeChecker.new do
61
- exclude_alias
62
- end
63
-
64
- assert_nok(tc, 'alias :a :b')
65
- end
66
-
67
- def test_3_exclude_calls_on
68
-
69
- tc = Rufus::TreeChecker.new do
70
- exclude_call_on File, FileUtils
71
- exclude_call_on IO
72
- end
73
- #puts tc.to_s
74
-
75
- assert_nok(tc, 'data = File.read("surf.txt")')
76
- assert_nok(tc, 'f = File.new("surf.txt")')
77
- assert_nok(tc, 'FileUtils.rm_f("bondzoi.txt")')
78
- assert_nok(tc, 'IO.foreach("testfile") {|x| print "GOT ", x }')
79
- end
80
-
81
- def test_4_exclude_def
82
-
83
- tc = Rufus::TreeChecker.new do
84
- exclude_def
85
- end
86
-
87
- assert_nok(tc, 'def drink; "water"; end')
88
- assert_nok(tc, 'class Toto; def drink; "water"; end; end')
89
- end
90
-
91
- def test_5_exclude_class_tinkering
92
-
93
- tc = Rufus::TreeChecker.new do
94
- exclude_class_tinkering
95
- end
96
-
97
- assert_nok(tc, 'class << instance; def length; 3; end; end')
98
- assert_nok(tc, 'class Toto; end')
99
- assert_nok(tc, 'class Alpha::Toto; end')
100
- end
101
-
102
- def test_5b_exclude_class_tinkering_with_exceptions
103
-
104
- tc = Rufus::TreeChecker.new do
105
- exclude_class_tinkering :except => [ String, Rufus::TreeChecker ]
106
- end
107
- #puts tc.to_s
108
-
109
- assert_nok(tc, 'class String; def length; 3; end; end')
110
-
111
- assert_ok(tc, 'class S2 < String; def length; 3; end; end')
112
- assert_ok(tc, 'class Toto < Rufus::TreeChecker; def length; 3; end; end')
113
-
114
- assert_nok(tc, 'class Toto; end')
115
- assert_nok(tc, 'class Alpha::Toto; end')
116
- end
117
-
118
- def test_6_exclude_module_tinkering
119
-
120
- tc = Rufus::TreeChecker.new do
121
- exclude_module_tinkering
122
- end
123
-
124
- assert_nok(tc, 'module Alpha; end')
125
- assert_nok(tc, 'module Momo::Alpha; end')
126
- end
127
-
128
- def test_7_exclude_eval
129
-
130
- tc = Rufus::TreeChecker.new do
131
- exclude_eval
132
- end
133
-
134
- assert_nok(tc, 'eval("code")')
135
- assert_nok(tc, 'Kernel.eval("code")')
136
- assert_nok(tc, 'toto.instance_eval("code")')
137
- assert_nok(tc, 'Toto.module_eval("code")')
138
- end
139
-
140
- def test_8_exclude_backquotes
141
-
142
- tc = Rufus::TreeChecker.new do
143
- exclude_backquotes
144
- end
145
-
146
- assert_nok(tc, '`kill -9 whatever`')
147
- end
148
-
149
- def test_9_exclude_raise_and_throw
150
-
151
- tc = Rufus::TreeChecker.new do
152
- exclude_raise
153
- end
154
-
155
- assert_nok(tc, 'raise')
156
- assert_nok(tc, 'raise "error"')
157
- assert_nok(tc, 'Kernel.raise')
158
- assert_nok(tc, 'Kernel.raise "error"')
159
- assert_ok(tc, 'Kernel.puts "error"')
160
- assert_nok(tc, 'throw')
161
- assert_nok(tc, 'throw :halt')
162
- end
163
-
164
- def test_10_exclude_public
165
-
166
- tc = Rufus::TreeChecker.new do
167
- exclude_fvccall :public
168
- exclude_fvccall :protected
169
- exclude_fvccall :private
170
- end
171
-
172
- assert_nok(tc, 'public')
173
- assert_nok(tc, 'public :surf')
174
- assert_nok(tc, 'class Toto; public :car; end')
175
- assert_nok(tc, 'private')
176
- assert_nok(tc, 'private :surf')
177
- assert_nok(tc, 'class Toto; private :car; end')
178
- end
179
-
180
- def test_11_is_not
181
-
182
- tc = Rufus::TreeChecker.new do
183
- exclude_head [ :block ]
184
- exclude_head [ :lasgn ]
185
- exclude_head [ :dasgn_curr ]
186
- end
187
-
188
- assert_nok(tc, 'a; b; c')
189
- assert_nok(tc, 'lambda { a; b; c }')
190
-
191
- assert_nok(tc, 'a = 2')
192
- assert_nok(tc, 'lambda { a = 2 }')
193
- end
194
-
195
- def test_12_at_root
196
-
197
- tc = Rufus::TreeChecker.new do
198
- at_root do
199
- exclude_head [ :block ]
200
- exclude_head [ :lasgn ]
201
- end
202
- end
203
-
204
- assert_nok(tc, 'a; b; c')
205
- assert_ok(tc, 'lambda { a; b; c }')
206
-
207
- assert_nok(tc, 'a = 2')
208
- assert_ok(tc, 'lambda { a = 2 }')
209
- end
210
-
211
- def test_12_rebinding
212
-
213
- tc = Rufus::TreeChecker.new do
214
- exclude_call_to :class
215
- exclude_rebinding Kernel, Rufus::TreeChecker
216
- end
217
-
218
- assert_nok(tc, 'k = Kernel')
219
- assert_nok(tc, 'k = ::Kernel')
220
- assert_nok(tc, 'c = Rufus::TreeChecker')
221
- assert_nok(tc, 'c = ::Rufus::TreeChecker')
222
- assert_nok(tc, 's = "".class')
223
- end
224
-
225
- def test_13_access_to
226
-
227
- tc = Rufus::TreeChecker.new do
228
- exclude_access_to File
229
- end
230
-
231
- #puts tc.to_s
232
-
233
- assert_nok(tc, 'f = File')
234
- assert_nok(tc, 'f = ::File')
235
- assert_nok(tc, 'File.read "hello.txt"')
236
- assert_nok(tc, '::File.read "hello.txt"')
237
- end
238
-
239
- #def test_X
240
- # tc = Rufus::TreeChecker.new do
241
- # end
242
- # #tc.ptree 'load "surf"'
243
- # tc.ptree 'class Toto; load "nada"; end'
244
- # tc.ptree 'class Toto; def m; load "nada"; end; end'
245
- # tc.ptree 'class << toto; def m; load "nada"; end; end'
246
- # #tc.ptree 'lambda { a; b; c }'
247
- # #tc.ptree 'lambda { a = c }'
248
- # #tc.ptree 'c = 0; a = c'
249
- # #tc.ptree 'c = a = 0'
250
- # tc.ptree 'a = 5 + 6; puts a'
251
- #end
252
- end
253
-
@@ -1,72 +0,0 @@
1
-
2
- #
3
- # Testing rufus-treechecker
4
- #
5
- # jmettraux at gmail.org
6
- #
7
- # Fri Aug 29 10:13:33 JST 2008
8
- #
9
-
10
- require 'testmixin'
11
-
12
- module Testy
13
- class Tasty
14
- end
15
- end
16
-
17
- class OldTreeCheckerTest < Test::Unit::TestCase
18
- include TestMixin
19
-
20
-
21
- def test_0
22
-
23
- tc = Rufus::TreeChecker.new do
24
- exclude_fvccall :abort
25
- exclude_fvccall :exit, :exit!
26
- exclude_fvccall :system
27
- exclude_eval
28
- exclude_alias
29
- exclude_global_vars
30
- exclude_call_on File, FileUtils
31
- exclude_class_tinkering :except => Testy::Tasty
32
- exclude_module_tinkering
33
-
34
- exclude_fvcall :public
35
- exclude_fvcall :protected
36
- exclude_fvcall :private
37
- exclude_fcall :load
38
- exclude_fcall :require
39
- end
40
-
41
- assert_nocompile tc, "def surf }"
42
-
43
- assert_ok tc, "puts 'toto'"
44
-
45
- assert_nok tc, "exit"
46
- assert_nok tc, "puts $BATEAU"
47
- assert_nok tc, "abort"
48
- assert_nok tc, "abort; puts 'ok'"
49
- assert_nok tc, "puts 'ok'; abort"
50
-
51
- assert_nok tc, "exit 0"
52
- assert_nok tc, "system('whatever')"
53
-
54
- assert_nok tc, "alias :a :b"
55
- assert_nok tc, "alias_method :a, :b"
56
-
57
- assert_nok tc, "File.open('x')"
58
- assert_nok tc, "FileUtils.rm('x')"
59
-
60
- assert_nok tc, "eval 'nada'"
61
- assert_nok tc, "M.module_eval 'nada'"
62
- assert_nok tc, "o.instance_eval 'nada'"
63
-
64
- assert_ok tc, "puts 'toto'"
65
-
66
- assert_ok tc, "class Toto < Testy::Tasty\nend"
67
- assert_nok tc, "class String\nend"
68
- assert_nok tc, "module Whatever\nend"
69
- assert_nok tc, "class << e\nend"
70
- end
71
- end
72
-
data/test/ft_2_clone.rb DELETED
@@ -1,32 +0,0 @@
1
-
2
- #
3
- # Testing rufus-treechecker
4
- #
5
- # jmettraux at gmail.org
6
- #
7
- # Tue Sep 2 14:28:01 JST 2008
8
- #
9
-
10
- require 'testmixin'
11
-
12
- class CloneTest < Test::Unit::TestCase
13
- include TestMixin
14
-
15
-
16
- def test_0
17
-
18
- tc0 = Rufus::TreeChecker.new do
19
- exclude_fvccall :abort
20
- end
21
-
22
- tc1 = tc0.clone
23
- tc1.add_rules do
24
- at_root do
25
- exclude_head [ :block ]
26
- end
27
- end
28
-
29
- assert_not_equal tc0.object_id, tc1.object_id
30
- end
31
- end
32
-
data/test/test.rb DELETED
@@ -1,5 +0,0 @@
1
-
2
- require 'ft_0_basic'
3
- require 'ft_1_old_treechecker'
4
- require 'ft_2_clone'
5
-
data/test/testmixin.rb DELETED
@@ -1,31 +0,0 @@
1
-
2
- #
3
- # Testing rufus-treechecker
4
- #
5
- # jmettraux at gmail.org
6
- #
7
- # Fri Aug 29 18:30:03 JST 2008
8
- #
9
-
10
- require 'test/unit'
11
- require 'rubygems'
12
- require 'rufus/treechecker'
13
-
14
-
15
- module TestMixin
16
-
17
- def assert_ok (tc, rubycode)
18
- tc.check(rubycode)
19
- end
20
- def assert_nok (tc, rubycode)
21
- assert_raise Rufus::SecurityError, tc.stree(rubycode) do
22
- tc.check(rubycode)
23
- end
24
- end
25
- def assert_nocompile (tc, rubycode)
26
- assert_raise Racc::ParseError do
27
- tc.check(rubycode)
28
- end
29
- end
30
- end
31
-