Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
64cdabc8
提交
64cdabc8
authored
10月 10, 2018
作者:
chenminjian
提交者:
Steven Allen
10月 24, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: stop apply command exposing private key over HTTP API
License: MIT Signed-off-by:
chenminjian
<
727180553@qq.com
>
上级
2e3cbe3e
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
43 行增加
和
5 行删除
+43
-5
config.go
core/commands/config.go
+33
-5
t0021-config.sh
test/sharness/t0021-config.sh
+10
-0
没有找到文件。
core/commands/config.go
浏览文件 @
64cdabc8
...
...
@@ -23,8 +23,8 @@ import (
// ConfigUpdateOutput is config profile apply command's output
type
ConfigUpdateOutput
struct
{
Old
config
.
Config
New
config
.
Config
Old
Cfg
map
[
string
]
interface
{}
New
Cfg
map
[
string
]
interface
{}
}
type
ConfigField
struct
{
...
...
@@ -359,9 +359,22 @@ var configProfileApplyCmd = &cmds.Command{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
}
oldCfgMap
,
err
:=
scrubPrivKey
(
oldCfg
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
}
newCfgMap
,
err
:=
scrubPrivKey
(
newCfg
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
}
res
.
SetOutput
(
&
ConfigUpdateOutput
{
Old
:
*
oldCfg
,
New
:
*
newCfg
,
Old
Cfg
:
oldCfgMap
,
New
Cfg
:
newCfgMap
,
})
},
Marshalers
:
cmds
.
MarshalerMap
{
...
...
@@ -380,7 +393,7 @@ var configProfileApplyCmd = &cmds.Command{
return
nil
,
e
.
TypeErr
(
apply
,
v
)
}
diff
:=
jsondiff
.
Compare
(
apply
.
Old
,
apply
.
New
)
diff
:=
jsondiff
.
Compare
(
apply
.
Old
Cfg
,
apply
.
NewCfg
)
buf
:=
jsondiff
.
Format
(
diff
)
return
strings
.
NewReader
(
string
(
buf
)),
nil
...
...
@@ -404,6 +417,21 @@ func buildProfileHelp() string {
return
out
}
// scrubPrivKey scrubs private key for security reasons.
func
scrubPrivKey
(
cfg
*
config
.
Config
)
(
map
[
string
]
interface
{},
error
)
{
cfgMap
,
err
:=
config
.
ToMap
(
cfg
)
if
err
!=
nil
{
return
nil
,
err
}
err
=
scrubValue
(
cfgMap
,
[]
string
{
config
.
IdentityTag
,
config
.
PrivKeyTag
})
if
err
!=
nil
{
return
nil
,
err
}
return
cfgMap
,
nil
}
// transformConfig returns old config and new config instead of difference between they,
// because apply command can provide stable API through this way.
// If dryRun is true, repo's config should not be updated and persisted
...
...
test/sharness/t0021-config.sh
浏览文件 @
64cdabc8
...
...
@@ -262,6 +262,16 @@ test_config_cmd() {
test `grep "DisableNatPortMap" diff_info | wc -l` = 2
'
test_expect_success
"'ipfs config profile apply test --dry-run' doesn't include privkey"
'
ipfs config profile apply test --dry-run > show_config &&
test_expect_code 1 grep PrivKey show_config
'
test_expect_success
"'ipfs config profile apply test' doesn't include privkey"
'
ipfs config profile apply test > show_config &&
test_expect_code 1 grep PrivKey show_config
'
# won't work as it changes datastore definition, which makes ipfs not launch
# without converting first
# test_profile_apply_revert badgerds
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论