Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
Brakeman
提交
eb08c600
B
Brakeman
项目概览
李少辉-开发者
/
Brakeman
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
Brakeman
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
eb08c600
编写于
12月 07, 2012
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use process_call_args and Sexp#each_arg
上级
4ef580b9
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
46 addition
and
24 deletion
+46
-24
lib/brakeman/checks/base_check.rb
lib/brakeman/checks/base_check.rb
+1
-1
lib/brakeman/checks/check_cross_site_scripting.rb
lib/brakeman/checks/check_cross_site_scripting.rb
+1
-2
lib/brakeman/checks/check_mail_to.rb
lib/brakeman/checks/check_mail_to.rb
+1
-1
lib/brakeman/checks/check_mass_assignment.rb
lib/brakeman/checks/check_mass_assignment.rb
+27
-13
lib/brakeman/checks/check_send.rb
lib/brakeman/checks/check_send.rb
+1
-1
lib/brakeman/processors/haml_template_processor.rb
lib/brakeman/processors/haml_template_processor.rb
+1
-2
lib/brakeman/processors/lib/find_all_calls.rb
lib/brakeman/processors/lib/find_all_calls.rb
+1
-1
lib/brakeman/processors/lib/find_call.rb
lib/brakeman/processors/lib/find_call.rb
+1
-1
lib/brakeman/processors/lib/processor_helper.rb
lib/brakeman/processors/lib/processor_helper.rb
+10
-0
lib/brakeman/processors/lib/rails3_route_processor.rb
lib/brakeman/processors/lib/rails3_route_processor.rb
+2
-2
未找到文件。
lib/brakeman/checks/base_check.rb
浏览文件 @
eb08c600
...
...
@@ -61,7 +61,7 @@ class Brakeman::BaseCheck < Brakeman::SexpProcessor
#Process calls and check if they include user input
def
process_call
exp
process
exp
.
target
if
sexp?
exp
.
target
process_
all
exp
.
args
process_
call_args
exp
target
=
exp
.
target
...
...
lib/brakeman/checks/check_cross_site_scripting.rb
浏览文件 @
eb08c600
...
...
@@ -231,7 +231,6 @@ class Brakeman::CheckCrossSiteScripting < Brakeman::BaseCheck
end
method
=
exp
.
method
args
=
exp
.
arglist
#Ignore safe items
if
(
target
.
nil?
and
(
@ignore_methods
.
include?
method
or
method
.
to_s
=~
IGNORE_LIKE
))
or
...
...
@@ -252,7 +251,7 @@ class Brakeman::CheckCrossSiteScripting < Brakeman::BaseCheck
elsif
@inspect_arguments
and
params?
exp
@matched
=
Match
.
new
(
:params
,
exp
)
elsif
@inspect_arguments
process
args
process
_call_args
exp
end
end
...
...
lib/brakeman/checks/check_mail_to.rb
浏览文件 @
eb08c600
...
...
@@ -34,7 +34,7 @@ class Brakeman::CheckMailTo < Brakeman::BaseCheck
Brakeman
.
debug
"Checking calls to mail_to for javascript encoding"
tracker
.
find_call
(
:target
=>
false
,
:method
=>
:mail_to
).
each
do
|
result
|
result
[
:call
].
arglist
.
each
do
|
arg
|
result
[
:call
].
each_arg
do
|
arg
|
if
hash
?
arg
if
option
=
hash_access
(
arg
,
:
encode
)
return
result
if
symbol?
option
and
option
.
value
==
:javascript
...
...
lib/brakeman/checks/check_mass_assignment.rb
浏览文件 @
eb08c600
...
...
@@ -78,13 +78,14 @@ class Brakeman::CheckMassAssignment < Brakeman::BaseCheck
#Want to ignore calls to Model.new that have no arguments
def
check_call
call
args
=
process_all!
call
.
args
process_call_args
call
first_arg
=
call
.
first_arg
if
args
.
empty
?
#empty new()
if
first_arg
.
nil
?
#empty new()
false
elsif
hash
?
args
.
first
and
not
include_user_input?
args
.
first
elsif
hash
?
first_arg
and
not
include_user_input?
first_arg
false
elsif
all_literal
s?
args
elsif
all_literal
_args?
call
false
else
true
...
...
@@ -93,17 +94,30 @@ class Brakeman::CheckMassAssignment < Brakeman::BaseCheck
LITERALS
=
Set
[
:lit
,
:true
,
:false
,
:nil
,
:
string
]
def
all_literals?
args
args
.
all?
do
|
arg
|
if
sexp?
arg
if
arg
.
node_type
==
:hash
all_literals?
arg
else
LITERALS
.
include?
arg
.
node_type
end
def
all_literal_args?
exp
if
call?
exp
exp
.
each_arg
do
|
arg
|
return
false
unless
literal?
arg
end
true
else
exp
.
all?
do
|
arg
|
literal?
arg
end
end
end
def
literal?
exp
if
sexp?
exp
if
exp
.
node_type
==
:hash
all_literal_args?
exp
else
tru
e
LITERALS
.
include?
exp
.
node_typ
e
end
else
true
end
end
end
lib/brakeman/checks/check_send.rb
浏览文件 @
eb08c600
...
...
@@ -16,7 +16,7 @@ class Brakeman::CheckSend < Brakeman::BaseCheck
end
def
process_result
result
args
=
process_all!
result
[
:call
].
args
process_call_args
result
[
:call
]
target
=
process
result
[
:call
].
target
if
input
=
has_immediate_user_input?
(
result
[
:call
].
first_arg
)
...
...
lib/brakeman/processors/haml_template_processor.rb
浏览文件 @
eb08c600
...
...
@@ -36,8 +36,7 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor
when
:options
,
:buffer
exp
when
:open_tag
process
(
exp
.
arglist
)
exp
process_call_args
exp
else
arg
=
exp
.
first_arg
...
...
lib/brakeman/processors/lib/find_all_calls.rb
浏览文件 @
eb08c600
...
...
@@ -46,7 +46,7 @@ class Brakeman::FindAllCalls < Brakeman::BaseProcessor
end
method
=
exp
.
method
process_
all
exp
.
args
process_
call_args
exp
call
=
{
:target
=>
target
,
:method
=>
method
,
:call
=>
exp
,
:nested
=>
@in_target
,
:chain
=>
get_chain
(
exp
)
}
...
...
lib/brakeman/processors/lib/find_call.rb
浏览文件 @
eb08c600
...
...
@@ -84,7 +84,7 @@ class Brakeman::FindCall < Brakeman::BaseProcessor
target
=
get_target
exp
.
target
method
=
exp
.
method
process_
all
exp
.
args
process_
call_args
exp
if
match
(
@find_targets
,
target
)
and
match
(
@find_methods
,
method
)
...
...
lib/brakeman/processors/lib/processor_helper.rb
浏览文件 @
eb08c600
...
...
@@ -19,6 +19,16 @@ module Brakeman::ProcessorHelper
exp
end
#Process the arguments of a method call. Does not store results.
#
#This method is used because Sexp#args and Sexp#arglist create new objects.
def
process_call_args
exp
exp
.
each_arg
do
|
a
|
process
a
if
sexp?
a
end
exp
end
#Sets the current module.
def
process_module
exp
module_name
=
class_name
(
exp
.
class_name
).
to_s
...
...
lib/brakeman/processors/lib/rails3_route_processor.rb
浏览文件 @
eb08c600
...
...
@@ -200,7 +200,7 @@ class Brakeman::Rails3RoutesProcessor < Brakeman::BaseProcessor
#handle hash
add_resources_routes
elsif
exp
.
args
.
all?
{
|
s
|
symbol?
s
}
exp
.
args
.
each
do
|
s
|
exp
.
each_arg
do
|
s
|
self
.
current_controller
=
s
.
value
add_resources_routes
end
...
...
@@ -212,7 +212,7 @@ class Brakeman::Rails3RoutesProcessor < Brakeman::BaseProcessor
def
process_resource
exp
#Does resource even take more than one controller name?
exp
.
args
.
each
do
|
s
|
exp
.
each_arg
do
|
s
|
if
symbol?
s
self
.
current_controller
=
pluralize
(
s
.
value
.
to_s
)
add_resource_routes
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录