Merge pull request #1944 from ywk253100/170406_ping_target

Do not return password of target
This commit is contained in:
Daniel Jiang 2017-04-07 11:35:07 +08:00 committed by GitHub
commit 4dddd5e9b4

View File

@ -147,17 +147,7 @@ func (t *TargetAPI) Get() {
t.CustomAbort(http.StatusNotFound, http.StatusText(http.StatusNotFound))
}
// The reason why the password is returned is that when user just wants to
// modify other fields of target he does not need to input the password again.
// The security issue can be fixed by enable https.
if len(target.Password) != 0 {
pwd, err := utils.ReversibleDecrypt(target.Password, t.secretKey)
if err != nil {
log.Errorf("failed to decrypt password: %v", err)
t.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
target.Password = pwd
}
target.Password = ""
t.Data["json"] = target
t.ServeJSON()
@ -173,16 +163,7 @@ func (t *TargetAPI) List() {
}
for _, target := range targets {
if len(target.Password) == 0 {
continue
}
str, err := utils.ReversibleDecrypt(target.Password, t.secretKey)
if err != nil {
log.Errorf("failed to decrypt password: %v", err)
t.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
target.Password = str
target.Password = ""
}
t.Data["json"] = targets