From d98dbf54e948fb22bdc5dcf19067ddc9c62d10f7 Mon Sep 17 00:00:00 2001 From: yangwei999 <348134071@qq.com> Date: Sat, 28 Oct 2023 16:25:04 +0800 Subject: [PATCH 1/2] use log of beego --- .../cve-ddd/adapter/hotpatch.go | 8 ++++---- cve-vulner-manager/cve-ddd/app/hotpatch.go | 20 +++++++++---------- .../infrastructure/bulletinimpl/impl.go | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cve-vulner-manager/cve-ddd/adapter/hotpatch.go b/cve-vulner-manager/cve-ddd/adapter/hotpatch.go index 8766c32..20b7805 100644 --- a/cve-vulner-manager/cve-ddd/adapter/hotpatch.go +++ b/cve-vulner-manager/cve-ddd/adapter/hotpatch.go @@ -10,8 +10,8 @@ import ( "time" "github.com/astaxie/beego" + "github.com/astaxie/beego/logs" "github.com/opensourceways/server-common-lib/utils" - "github.com/sirupsen/logrus" "cvevulner/cve-ddd/app" "cvevulner/cve-ddd/infrastructure/bulletinimpl" @@ -57,7 +57,7 @@ type Issue struct { func (h *hotPatch) Process() { issues, err := h.getIssues() if err != nil { - logrus.Errorf("get hot patch issue error: %s", err.Error()) + logs.Error("get hot patch issue error: %s", err.Error()) return } @@ -66,7 +66,7 @@ func (h *hotPatch) Process() { for _, v := range issues { pat, err := h.toPatchIssue(v.Body) if err != nil { - logrus.Errorf("issue number %s toPatchIssue error: %s", v.Number, err.Error()) + logs.Error("issue number %s toPatchIssue error: %s", v.Number, err.Error()) continue } pat.HotIssueNum = v.Number @@ -75,7 +75,7 @@ func (h *hotPatch) Process() { } if err := h.service.GenerateBulletins(patches); err != nil { - logrus.Errorf("generate bulletins error %s", err.Error()) + logs.Error("generate bulletins error %s", err.Error()) } } diff --git a/cve-vulner-manager/cve-ddd/app/hotpatch.go b/cve-vulner-manager/cve-ddd/app/hotpatch.go index 7069a28..3791f8f 100644 --- a/cve-vulner-manager/cve-ddd/app/hotpatch.go +++ b/cve-vulner-manager/cve-ddd/app/hotpatch.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/sirupsen/logrus" + "github.com/astaxie/beego/logs" "cvevulner/cve-ddd/domain" "cvevulner/cve-ddd/domain/bulletin" @@ -63,11 +63,11 @@ func (h *hotPatchService) GenerateBulletins(cmds []CmdToGenerateBulletins) error AffectedVersion: cmd.Branch, }) if err != nil { - logrus.Errorf("find cve %s, error %s", cmd.CveNum, err.Error()) + logs.Error("find cve %s, error %s", cmd.CveNum, err.Error()) return err } if len(cves) == 0 { - logrus.Errorf("find cve %s nil", cmd.CveNum) + logs.Error("find cve %s nil", cmd.CveNum) continue } // all cves have the same hot issue number @@ -84,14 +84,14 @@ func (h *hotPatchService) GenerateBulletins(cmds []CmdToGenerateBulletins) error xmlData, err := h.bulletin.Generate(&b) if err != nil { - logrus.Errorf("component: %s, to xml error: %s", b.Component, err.Error()) + logs.Error("component: %s, to xml error: %s", b.Component, err.Error()) continue } fileName := fmt.Sprintf("cvrf-%s.xml", b.Identification) if err := h.obs.UploadToDynamicDir(fileName, xmlData); err != nil { - logrus.Errorf("component: %s, upload to obs error: %s", b.Component, err.Error()) + logs.Error("component: %s, upload to obs error: %s", b.Component, err.Error()) continue } @@ -102,7 +102,7 @@ func (h *hotPatchService) GenerateBulletins(cmds []CmdToGenerateBulletins) error } if err := h.repository.SaveIssueNum(cmd.HotIssueNum); err != nil { - logrus.Errorf("save issue num %s error %s", cmd.HotIssueNum, err.Error()) + logs.Error("save issue num %s error %s", cmd.HotIssueNum, err.Error()) } } @@ -139,13 +139,13 @@ func (h *hotPatchService) uploadUpdateInfo(cves domain.Cves) error { for version, v := range cves.GroupByVersion() { bytes, err := h.updateInfo.Generate(v) if err != nil { - logrus.Errorf("generate updateinfo of %s error %s", version, err.Error()) + logs.Error("generate updateinfo of %s error %s", version, err.Error()) continue } fileName := fmt.Sprintf("%s_updateinfo.xlsx", version) if err := h.obs.UploadUpdateInfo(fileName, bytes); err != nil { - logrus.Errorf("version: %s, upload to obs error: %s", version, err.Error()) + logs.Error("version: %s, upload to obs error: %s", version, err.Error()) continue } @@ -178,7 +178,7 @@ func (h *hotPatchService) appendHotPatchToFiles(files []string) { func (h *hotPatchService) updateFileByContent(file, newContent string) { oldContent, err := h.obs.DownloadFromDynamicDir(file) if err != nil { - logrus.Errorf("download %s error: %s", file, err.Error()) + logs.Error("download %s error: %s", file, err.Error()) return } @@ -186,6 +186,6 @@ func (h *hotPatchService) updateFileByContent(file, newContent string) { oldContent = append(oldContent, newContent...) if err = h.obs.UploadToDynamicDir(file, oldContent); err != nil { - logrus.Errorf("upload %s error: %s", file, err.Error()) + logs.Error("upload %s error: %s", file, err.Error()) } } diff --git a/cve-vulner-manager/cve-ddd/infrastructure/bulletinimpl/impl.go b/cve-vulner-manager/cve-ddd/infrastructure/bulletinimpl/impl.go index d2c96c3..7a70890 100644 --- a/cve-vulner-manager/cve-ddd/infrastructure/bulletinimpl/impl.go +++ b/cve-vulner-manager/cve-ddd/infrastructure/bulletinimpl/impl.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "github.com/sirupsen/logrus" + "github.com/astaxie/beego/logs" "cvevulner/cve-ddd/domain" "cvevulner/cve-ddd/domain/dp" @@ -258,7 +258,7 @@ func (impl bulletinImpl) HotPatchTree(sb *domain.SecurityBulletin) HotPatchTree } if _, ok := archs[arch]; !ok { - logrus.Errorf("arch %s is unlegal", arch) + logs.Error("arch %s is unlegal", arch) continue } -- Gitee From dea88654ab379da2dd1d8409b766f0508723c79f Mon Sep 17 00:00:00 2001 From: yangwei999 <348134071@qq.com> Date: Wed, 8 Nov 2023 10:28:08 +0800 Subject: [PATCH 2/2] add 2203 sp3 --- cve-vulner-manager/conf/product_app.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cve-vulner-manager/conf/product_app.conf b/cve-vulner-manager/conf/product_app.conf index 8293b1c..cab1f8c 100644 --- a/cve-vulner-manager/conf/product_app.conf +++ b/cve-vulner-manager/conf/product_app.conf @@ -179,7 +179,7 @@ cve_number_t = 2018 # Create an issue's repo whitelist;1: open; 2: close issue_whitelist = 2 # List of affected branches: openEuler-20.03-LTS,openEuler-20.03-LTS-SP1 -affected_branchs = "openEuler-20.03-LTS-SP1,openEuler-20.03-LTS-SP3,openEuler-20.03-LTS-SP4,openEuler-22.03-LTS,openEuler-22.03-LTS-SP1,openEuler-22.03-LTS-SP2" +affected_branchs = "openEuler-20.03-LTS-SP1,openEuler-20.03-LTS-SP3,openEuler-20.03-LTS-SP4,openEuler-22.03-LTS,openEuler-22.03-LTS-SP1,openEuler-22.03-LTS-SP2,openEuler-22.03-LTS-SP3" abandoned_branchs = "openEuler-20.03-LTS,openEuler-21.03,openEuler-21.09,openEuler-20.09" # Close the highest privilege of issue:1:open;2:close close_issue_privilege = 2 -- Gitee