File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
ruby/test/security/CWE-770 Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ class UserController < ActionController ::Base
2
+ def bad_examples
3
+ limit = params [ :limit ] . to_i
4
+
5
+ # repeat a simple operation for the number of limit specified using upto()
6
+ 1 . upto ( days ) do |i |
7
+ put "a repeatable operation"
8
+ end
9
+
10
+ # repeat a simple operation for the number of limit specified using times()
11
+ limit . times do
12
+ put "a repeatable operation"
13
+ end
14
+
15
+ # repeat a simple operation for the number of limit specified using downto()
16
+ limit . downto ( 1 ) do |i |
17
+ put "a repeatable operation"
18
+ end
19
+
20
+ end
21
+ end
Original file line number Diff line number Diff line change
1
+ class UserController < ActionController ::Base
2
+ def good_example
3
+ limit = params [ :limit ] . to_i
4
+
5
+ # limit the limit between 1 and 1000
6
+ if not ( limit => 1 && limit < 1000 )
7
+ limit = 10
8
+ end
9
+
10
+
11
+ # repeat a simple operation for the number of limit specified using upto()
12
+ 1 . upto ( days ) do |i |
13
+ put "a repeatable operation"
14
+ end
15
+
16
+ end
17
+ end
You can’t perform that action at this time.
0 commit comments