Skip to content

Commit

Permalink
perf: update login for security
Browse files Browse the repository at this point in the history
  • Loading branch information
waynedream authored Dec 24, 2024
1 parent 117be63 commit a0f7dd6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions inputs/rocketmq_offset/rocketmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,19 @@ type Instance struct {
}

func (ins *Instance) Login() (string, error) {
loginURL := fmt.Sprintf("%s/login/login.do?username=%s&password=%s", consoleSchema+ins.RocketMQConsoleIPAndPort, ins.Username, ins.Password)
req, err := http.NewRequest("POST", loginURL, nil)
if err != nil {
return "", err
}
loginURL := fmt.Sprintf("%s/login/login.do", consoleSchema + ins.RocketMQConsoleIPAndPort)
data := url.Values{}

Check failure on line 59 in inputs/rocketmq_offset/rocketmq.go

View workflow job for this annotation

GitHub Actions / Code Analysis

undefined: url

Check failure on line 59 in inputs/rocketmq_offset/rocketmq.go

View workflow job for this annotation

GitHub Actions / Go Build Check

undefined: url
data.Set("username", ins.Username)
data.Set("password", ins.Password)

res, err := http.DefaultClient.Do(req)
req, err := http.NewRequest("POST", loginURL, strings.NewReader(data.Encode()))
if err != nil {
return "", err
}
defer res.Body.Close()

// 设置Content-Type头
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

// 获取 set-cookie 头
cookies := res.Header.Get("Set-Cookie")

Check failure on line 72 in inputs/rocketmq_offset/rocketmq.go

View workflow job for this annotation

GitHub Actions / Code Analysis

undefined: res

Check failure on line 72 in inputs/rocketmq_offset/rocketmq.go

View workflow job for this annotation

GitHub Actions / Go Build Check

undefined: res
if cookies == "" {
Expand Down

0 comments on commit a0f7dd6

Please sign in to comment.