Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
Brakeman
提交
f40686d8
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,发现更多精彩内容 >>
提交
f40686d8
编写于
2月 04, 2014
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle mix of string concatenation and interpolation
in SQL queries
上级
f4e79635
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
5 deletion
+19
-5
lib/brakeman/checks/check_sql.rb
lib/brakeman/checks/check_sql.rb
+10
-5
test/apps/rails3.1/app/models/user.rb
test/apps/rails3.1/app/models/user.rb
+9
-0
未找到文件。
lib/brakeman/checks/check_sql.rb
浏览文件 @
f40686d8
...
...
@@ -491,15 +491,20 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
target
=
exp
.
target
method
=
exp
.
method
arg
=
exp
.
first_arg
if
STRING_METHODS
.
include?
method
if
string?
target
check_string_arg
exp
.
first_
arg
elsif
string?
exp
.
first_
arg
check_string_arg
arg
elsif
string?
arg
check_string_arg
target
elsif
call?
target
check_for_string_building
target
elsif
node_type?
target
,
:string_interp
,
:dstr
or
node_type?
arg
,
:string_interp
,
:dstr
check_string_arg
target
and
check_string_arg
arg
end
else
nil
...
...
@@ -523,8 +528,8 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
def
string_building?
exp
return
false
unless
call?
exp
and
STRING_METHODS
.
include?
exp
.
method
string?
exp
.
target
or
string?
exp
.
first_arg
or
node_type?
exp
.
target
,
:str
,
:dstr
,
:string_interp
or
node_type?
exp
.
first_arg
,
:str
,
:dstr
,
:string_interp
or
string_building?
exp
.
target
or
string_building?
exp
.
first_arg
end
...
...
test/apps/rails3.1/app/models/user.rb
浏览文件 @
f40686d8
...
...
@@ -31,5 +31,14 @@ class User < ActiveRecord::Base
def
self
.
sql_stuff
condition
=
parent_id
.
blank?
?
" IS NULL"
:
" =
#{
parent_id
}
"
self
.
connection
.
select_values
(
"SELECT max(id) FROM content_pages WHERE parent_content_page_id
#{
condition
}
"
)[
0
].
to_i
# Should not warn
User
.
where
(
"
#{
table_name
}
.visibility = ?"
+
" OR (
#{
table_name
}
.visibility = ? AND
#{
table_name
}
.id IN ("
+
"SELECT DISTINCT a.id FROM
#{
table_name
}
a"
+
" INNER JOIN
#{
User
.
table_name
}
m ON m.id = mr.member_id AND m.user_id = ?"
+
" WHERE a.project_id IS NULL OR a.project_id = m.project_id))"
+
" OR
#{
table_name
}
.user_id = ?"
,
stuff
,
stuff
,
user
.
id
,
user
.
id
)
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录