Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
brakeman
提交
6607a32e
B
brakeman
项目概览
CoCo_Code_Op2
/
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,发现更多精彩内容 >>
提交
6607a32e
编写于
6月 14, 2013
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add more methods to check for command injection
closes #206 finally
上级
47746fee
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
116 addition
and
2 deletion
+116
-2
lib/brakeman/checks/check_execute.rb
lib/brakeman/checks/check_execute.rb
+4
-1
test/apps/rails3/app/controllers/home_controller.rb
test/apps/rails3/app/controllers/home_controller.rb
+12
-0
test/tests/rails3.rb
test/tests/rails3.rb
+100
-1
未找到文件。
lib/brakeman/checks/check_execute.rb
浏览文件 @
6607a32e
...
...
@@ -19,7 +19,10 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
check_for_backticks
tracker
Brakeman
.
debug
"Finding other system calls"
calls
=
tracker
.
find_call
:targets
=>
[
:IO
,
:Open3
,
:Kernel
,
nil
],
:methods
=>
[
:exec
,
:popen
,
:popen3
,
:syscall
,
:system
]
calls
=
tracker
.
find_call
:targets
=>
[
:IO
,
:Open3
,
:Kernel
,
:'POSIX::Spawn'
,
:Process
,
nil
],
:methods
=>
[
:capture2
,
:capture2e
,
:capture3
,
:exec
,
:pipeline
,
:pipeline_r
,
:pipeline_rw
,
:pipeline_start
,
:pipeline_w
,
:popen
,
:popen2
,
:popen2e
,
:popen3
,
:spawn
,
:syscall
,
:system
]
Brakeman
.
debug
"Processing system calls"
calls
.
each
do
|
result
|
...
...
test/apps/rails3/app/controllers/home_controller.rb
浏览文件 @
6607a32e
...
...
@@ -142,6 +142,18 @@ class HomeController < ApplicationController
Account
.
new
(
params
.
only
(
:name
,
email
))
end
def
test_more_ways_to_execute
Open3
.
capture2
"ls
#{
params
[
:dir
]
}
"
Open3
.
capture2e
"ls
#{
params
[
:dir
]
}
"
Open3
.
capture3
"ls
#{
params
[
:dir
]
}
"
Open3
.
pipeline
"sort"
,
"uniq"
,
:in
=>
params
[
:file
]
Open3
.
pipeline_r
"sort
#{
params
[
:file
]
}
"
,
"uniq"
Open3
.
pipeline_rw
params
[
:cmd
],
"sort -g"
Open3
.
pipeline_start
*
params
[
:cmds
]
spawn
"some_cool_command
#{
params
[
:opts
]
}
"
POSIX
::
Spawn
::
spawn
params
[
:cmd
]
end
private
def
filter_it
...
...
test/tests/rails3.rb
浏览文件 @
6607a32e
...
...
@@ -16,7 +16,7 @@ class Rails3Tests < Test::Unit::TestCase
:controller
=>
1
,
:model
=>
8
,
:template
=>
38
,
:warning
=>
54
:warning
=>
63
}
if
RUBY_PLATFORM
==
'java'
...
...
@@ -92,6 +92,105 @@ class Rails3Tests < Test::Unit::TestCase
:file
=>
/other_controller\.rb/
end
def
test_command_injection_capture2
assert_warning
:type
=>
:warning
,
:warning_code
=>
14
,
:fingerprint
=>
"744cb371d69e757edd75bf6d58c610e3e813ff2b75b353c4c89c67274e4a35bb"
,
:warning_type
=>
"Command Injection"
,
:line
=>
146
,
:message
=>
/^Possible\ command\ injection/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/home_controller.rb"
end
def
test_command_injection_capture2e
assert_warning
:type
=>
:warning
,
:warning_code
=>
14
,
:fingerprint
=>
"521c0a714d14ae878305ce737a2bdd5897dcea154c0622b14806ed6e6c60f526"
,
:warning_type
=>
"Command Injection"
,
:line
=>
147
,
:message
=>
/^Possible\ command\ injection/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/home_controller.rb"
end
def
test_command_injection_capture3
assert_warning
:type
=>
:warning
,
:warning_code
=>
14
,
:fingerprint
=>
"b75a4b21f55912860d675ac300de862f6b2050688b32f745ea8944832e5e699f"
,
:warning_type
=>
"Command Injection"
,
:line
=>
148
,
:message
=>
/^Possible\ command\ injection/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/home_controller.rb"
end
def
test_command_injection_pipeline
assert_warning
:type
=>
:warning
,
:warning_code
=>
14
,
:fingerprint
=>
"a72b42173ccbc912f022e73a37afc57b8099a529a9f28ebd9e3e771ad384b81c"
,
:warning_type
=>
"Command Injection"
,
:line
=>
149
,
:message
=>
/^Possible\ command\ injection/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/home_controller.rb"
end
def
test_command_injection_pipeline_r
assert_warning
:type
=>
:warning
,
:warning_code
=>
14
,
:fingerprint
=>
"987aad17f377a6101d5bd3e1611ae3716b276f319c3f91b69efd93717d993ea7"
,
:warning_type
=>
"Command Injection"
,
:line
=>
150
,
:message
=>
/^Possible\ command\ injection/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/home_controller.rb"
end
def
test_command_injection_pipeline_rw
assert_warning
:type
=>
:warning
,
:warning_code
=>
14
,
:fingerprint
=>
"02485597e19623e805dfa48a797f6f453d854f87ea03e51330494bf671bf5f68"
,
:warning_type
=>
"Command Injection"
,
:line
=>
151
,
:message
=>
/^Possible\ command\ injection/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/home_controller.rb"
end
def
test_command_injection_pipeline_start
assert_warning
:type
=>
:warning
,
:warning_code
=>
14
,
:fingerprint
=>
"c38ddfa0340fcaaa2a626de722a7784a0448fce01b58601c9c159113d1ce6e5f"
,
:warning_type
=>
"Command Injection"
,
:line
=>
152
,
:message
=>
/^Possible\ command\ injection/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/home_controller.rb"
end
def
test_command_injection_spawn
assert_warning
:type
=>
:warning
,
:warning_code
=>
14
,
:fingerprint
=>
"6b25cb3fa42bb234319ddf690a164eda038b6f000e501fbfa872fb5fa627609b"
,
:warning_type
=>
"Command Injection"
,
:line
=>
153
,
:message
=>
/^Possible\ command\ injection/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/home_controller.rb"
end
def
test_command_injection_posix_spawn
assert_warning
:type
=>
:warning
,
:warning_code
=>
14
,
:fingerprint
=>
"678ea7e0c73c91df335247b2470678dd23dfe66f049add9c783e3de4fb6e5046"
,
:warning_type
=>
"Command Injection"
,
:line
=>
154
,
:message
=>
/^Possible\ command\ injection/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/home_controller.rb"
end
def
test_file_access_concatenation
assert_warning
:type
=>
:warning
,
:warning_type
=>
"File Access"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录