From e45d817ef249bf574a761dda75a20aec64ca77e3 Mon Sep 17 00:00:00 2001 From: zhangjianjun_code <7844966+zhangjianjun_code@user.noreply.gitee.com> Date: Mon, 8 Feb 2021 16:09:59 +0800 Subject: [PATCH 1/4] Add log location problem --- controllers/hook.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/hook.go b/controllers/hook.go index 1554bb2..b365883 100644 --- a/controllers/hook.go +++ b/controllers/hook.go @@ -133,9 +133,13 @@ func (c *HookEventControllers) handleNoteDate() { return } hookPwd := beego.AppConfig.String("hook::hookpwd") + logs.Info("hookNote.Password: ", hookNote.Password, ", hookPwd: ", hookPwd) hookNote.Password = util.TrimString(hookNote.Password) + hookPwd = util.TrimString(hookPwd) + logs.Info("hookNote.Password: ", hookNote.Password, ", hookPwd: ", hookPwd, + ",hookNote.Action: ", hookNote.Action, ",hookNote.NoteableType", hookNote.NoteableType) if hookNote.Action == "comment" && hookNote.NoteableType == "Issue" && hookNote.Password == hookPwd { - //logs.Info(string(c.Ctx.Input.RequestBody)) + logs.Info(string(c.Ctx.Input.RequestBody)) //handle issue comment go handleIssueComment(hookNote) } -- Gitee From a5b0acc77a7aa05d7ff5a6e914ff9f1121c0eac2 Mon Sep 17 00:00:00 2001 From: zhangjianjun_code <7844966+zhangjianjun_code@user.noreply.gitee.com> Date: Mon, 8 Feb 2021 16:30:14 +0800 Subject: [PATCH 2/4] Add log location problem --- conf/product_app.conf | 3 ++- controllers/hook.go | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/conf/product_app.conf b/conf/product_app.conf index 588397f..94e9358 100644 --- a/conf/product_app.conf +++ b/conf/product_app.conf @@ -102,7 +102,8 @@ owner_openuler= openeuler [hook] -hookpwd = "${HOOK_PWD||***}" +#hookpwd = "${HOOK_PWD||***}" +hookpwd = YpYGtwO0Wiv3mQFy9GIMOq1clP28l0uzhyv8Fiwrm7Ly hookurl = https://api.openeuler.org/cve-manager/v1/issue/hook/event hook_timeout = 600 # 1 create, 2 Not create diff --git a/controllers/hook.go b/controllers/hook.go index b365883..2fb29c4 100644 --- a/controllers/hook.go +++ b/controllers/hook.go @@ -133,11 +133,8 @@ func (c *HookEventControllers) handleNoteDate() { return } hookPwd := beego.AppConfig.String("hook::hookpwd") - logs.Info("hookNote.Password: ", hookNote.Password, ", hookPwd: ", hookPwd) hookNote.Password = util.TrimString(hookNote.Password) hookPwd = util.TrimString(hookPwd) - logs.Info("hookNote.Password: ", hookNote.Password, ", hookPwd: ", hookPwd, - ",hookNote.Action: ", hookNote.Action, ",hookNote.NoteableType", hookNote.NoteableType) if hookNote.Action == "comment" && hookNote.NoteableType == "Issue" && hookNote.Password == hookPwd { logs.Info(string(c.Ctx.Input.RequestBody)) //handle issue comment -- Gitee From 7362fddd88c8df264b4266d4386d78679420133f Mon Sep 17 00:00:00 2001 From: zhangjianjun_code <7844966+zhangjianjun_code@user.noreply.gitee.com> Date: Mon, 8 Feb 2021 16:56:44 +0800 Subject: [PATCH 3/4] done --- conf/product_app.conf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/product_app.conf b/conf/product_app.conf index 94e9358..588397f 100644 --- a/conf/product_app.conf +++ b/conf/product_app.conf @@ -102,8 +102,7 @@ owner_openuler= openeuler [hook] -#hookpwd = "${HOOK_PWD||***}" -hookpwd = YpYGtwO0Wiv3mQFy9GIMOq1clP28l0uzhyv8Fiwrm7Ly +hookpwd = "${HOOK_PWD||***}" hookurl = https://api.openeuler.org/cve-manager/v1/issue/hook/event hook_timeout = 600 # 1 create, 2 Not create -- Gitee From bc077677a0f14c47df2d963ed8019f2e99961632 Mon Sep 17 00:00:00 2001 From: zhangjianjun_code <7844966+zhangjianjun_code@user.noreply.gitee.com> Date: Tue, 9 Feb 2021 10:33:28 +0800 Subject: [PATCH 4/4] Add log location problem --- common/common.go | 11 +++++++---- controllers/hook.go | 4 +++- go.mod | 1 + task/issuestatistics.go | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/common/common.go b/common/common.go index 52bd155..a6742f4 100644 --- a/common/common.go +++ b/common/common.go @@ -425,13 +425,16 @@ func TimeConverStr(timeStr string) string { func GetSpecialDate(beforeDate int) string { year, month, date := time.Now().Date() thisMonth := time.Date(year, month, beforeDate, 0, 0, 0, 0, time.Local) - startDate := "" + var startDate time.Time + var curTime string if date > beforeDate { - startDate = thisMonth.AddDate(0, 0, 0).Format(DATE_FORMAT) + startDate = thisMonth.AddDate(0, 0, 0) } else { - startDate = thisMonth.AddDate(0, -1, 0).Format(DATE_FORMAT) + startDate = thisMonth.AddDate(0, -1, 0) } - return startDate + h, _ := time.ParseDuration("-1h") + curTime = startDate.Add(8 * h).Format(DATE_FORMAT) + return curTime } func CreateDir(Dir string) error{ diff --git a/controllers/hook.go b/controllers/hook.go index 2fb29c4..e08963f 100644 --- a/controllers/hook.go +++ b/controllers/hook.go @@ -92,7 +92,6 @@ func (c *HookEventControllers) Post() { eventType := c.Ctx.Request.Header.Get(XGIteeEventType) c.Ctx.ResponseWriter.WriteHeader(200) c.Ctx.WriteString("Event received: " + eventType) - logs.Info("Event received: ", eventType) switch eventType { case NoteHookType: //handle comment hook data c.handleNoteDate() @@ -126,6 +125,7 @@ func (c *HookEventControllers) isLegitimateHookEvent() (ok bool) { } func (c *HookEventControllers) handleNoteDate() { + logs.Info(string(c.Ctx.Input.RequestBody)) var hookNote models.CommentPayload err := json.Unmarshal(c.Ctx.Input.RequestBody, &hookNote) if err != nil { @@ -134,6 +134,8 @@ func (c *HookEventControllers) handleNoteDate() { } hookPwd := beego.AppConfig.String("hook::hookpwd") hookNote.Password = util.TrimString(hookNote.Password) + logs.Info("hookNote.Password: ", hookNote.Password, ",hookPwd: ", hookPwd, + ", hookNote.Action: ", hookNote.Action, ",hookNote.NoteableType: ", hookNote.NoteableType) hookPwd = util.TrimString(hookPwd) if hookNote.Action == "comment" && hookNote.NoteableType == "Issue" && hookNote.Password == hookPwd { logs.Info(string(c.Ctx.Input.RequestBody)) diff --git a/go.mod b/go.mod index 20e1f35..879795c 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module cvevulner go 1.14 require ( + gitee.com/openeuler/go-gitee v0.0.0-20210201095646-fd9179920723 github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.0 github.com/astaxie/beego v1.12.3 github.com/beego/bee v1.12.3 // indirect diff --git a/task/issuestatistics.go b/task/issuestatistics.go index 6a3da43..34da85b 100644 --- a/task/issuestatistics.go +++ b/task/issuestatistics.go @@ -14,7 +14,7 @@ func IssueStatistics() error { // The number of days the issue counts the mailing list beforeDate, beErr := beego.AppConfig.Int("cve::cve_statistics_date") if beErr != nil { - beforeDate = 30 + beforeDate = 20 } prnum, prErr := beego.AppConfig.Int("crontab::prcnum") if prErr != nil { -- Gitee