mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-05-07 06:02:09 +08:00
fix(webconsole): baremteasl ipmi sol instance_name hide password (#23549)
This commit is contained in:
@@ -31,6 +31,7 @@ const (
|
||||
type ICommand interface {
|
||||
GetProtocol() string
|
||||
GetCommand() *exec.Cmd
|
||||
GetSafeCommandString() string
|
||||
Cleanup() error
|
||||
Scan(d byte, send func(msg string))
|
||||
GetClientSession() *mcclient.ClientSession
|
||||
@@ -66,6 +67,10 @@ func (c BaseCommand) GetCommand() *exec.Cmd {
|
||||
return exec.Command(c.name, c.args...)
|
||||
}
|
||||
|
||||
func (c BaseCommand) GetSafeCommandString() string {
|
||||
return c.GetCommand().String()
|
||||
}
|
||||
|
||||
func (c BaseCommand) Scan(byte, func(msg string)) {
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/log"
|
||||
|
||||
@@ -73,6 +74,20 @@ func (c *IpmitoolSol) GetCommand() *exec.Cmd {
|
||||
return c.BaseCommand.GetCommand()
|
||||
}
|
||||
|
||||
func (c *IpmitoolSol) GetSafeCommandString() string {
|
||||
cmd := []string{c.BaseCommand.name}
|
||||
i := 0
|
||||
for i < len(c.BaseCommand.args) {
|
||||
cmd = append(cmd, c.BaseCommand.args[i])
|
||||
if c.BaseCommand.args[i] == "-P" {
|
||||
cmd = append(cmd, "******")
|
||||
i += 1
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
return strings.Join(cmd, " ")
|
||||
}
|
||||
|
||||
func (c IpmitoolSol) GetProtocol() string {
|
||||
return PROTOCOL_TTY
|
||||
}
|
||||
|
||||
@@ -98,6 +98,10 @@ func (info *RemoteConsoleInfo) GetCommand() *exec.Cmd {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (info *RemoteConsoleInfo) GetSafeCommandString() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Cleanup implements ISessionData interface
|
||||
func (info *RemoteConsoleInfo) Cleanup() error {
|
||||
return nil
|
||||
|
||||
@@ -83,6 +83,10 @@ func (info *RemoteRDPConsoleInfo) GetCommand() *exec.Cmd {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (info *RemoteRDPConsoleInfo) GetSafeCommandString() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (info *RemoteRDPConsoleInfo) Cleanup() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ func (s *RandomSessionData) GetDisplayInfo(ctx context.Context) (*SDisplayInfo,
|
||||
}
|
||||
dispInfo := SDisplayInfo{}
|
||||
dispInfo.WaterMark = fetchWaterMark(userInfo)
|
||||
dispInfo.InstanceName = s.GetCommand().String()
|
||||
dispInfo.InstanceName = s.GetSafeCommandString()
|
||||
return &dispInfo, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,10 @@ func (s *SSshSession) GetCommand() *exec.Cmd {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SSshSession) GetSafeCommandString() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (s *SSshSession) IsNeedLogin() (bool, error) {
|
||||
if len(s.Username) > 0 && len(s.Password) > 0 {
|
||||
config := &ssh.ClientConfig{
|
||||
|
||||
Reference in New Issue
Block a user