From ff3e004ad992bd23d616d1f8ea76b61091758134 Mon Sep 17 00:00:00 2001 From: zhangjianjun_code <7844966+zhangjianjun_code@user.noreply.gitee.com> Date: Mon, 23 Nov 2020 12:38:29 +0800 Subject: [PATCH] Fix: When the data on gitee is synchronized to the local database, the affected branch is processed incorrectly --- controllers/hook.go | 2 +- taskhandler/createissue.go | 9 +++++++-- taskhandler/cve.go | 20 ++++++++++++++++---- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/controllers/hook.go b/controllers/hook.go index 493387d..112ad18 100644 --- a/controllers/hook.go +++ b/controllers/hook.go @@ -346,6 +346,7 @@ func closeIssueProc(issueHook *models.IssuePayload, issueTmp *models.IssueTempla } } +// Entry function for handling issue status func handleIssueStateChange(issueHook *models.IssuePayload) error { unFix := beego.AppConfig.String("labelUnFix") fixed := beego.AppConfig.String("labelFixed") @@ -447,7 +448,6 @@ func VerifyIssueAsPr(issueTmp *models.IssueTemplate, cveCenter models.VulnCenter issueFlagx := getPRRelatedBrandsAllIssue(token, owner, issueTmp.Repo, p.Number, issueTmp.IssueNum) if issueFlagx { branchMaps[brands] = issueFlagx - break } } } diff --git a/taskhandler/createissue.go b/taskhandler/createissue.go index d17d390..f8ab638 100644 --- a/taskhandler/createissue.go +++ b/taskhandler/createissue.go @@ -539,9 +539,9 @@ func CreateIssueComment(accessToken, owner, path, assignee string, return nil } -func CreateSecNoticeData(sec *models.SecurityNotice, iss models.VulnCenter, path, branchVersion string, opScore float64) { +func AddAffectBrands(branchVersion string) string { branchs := "" - if branchVersion != "" && len(branchVersion) > 0 { + if branchVersion != "" && len(branchVersion) > 1 { brandsGroup := strings.Split(branchVersion, ",") if len(brandsGroup) > 0 { for _, brand := range brandsGroup { @@ -569,6 +569,11 @@ func CreateSecNoticeData(sec *models.SecurityNotice, iss models.VulnCenter, path if branchs != "" && len(branchs) > 1 { branchs = branchs[:len(branchs)-1] } + return branchs +} + +func CreateSecNoticeData(sec *models.SecurityNotice, iss models.VulnCenter, path, branchVersion string, opScore float64) { + branchs := AddAffectBrands(branchVersion) sec.CveId = iss.CveId sec.CveNum = iss.CveNum opScoreLeve := openEulerScoreProc(opScore) diff --git a/taskhandler/cve.go b/taskhandler/cve.go index 90e0d1b..0501eb4 100644 --- a/taskhandler/cve.go +++ b/taskhandler/cve.go @@ -966,12 +966,18 @@ func InsertIssueCveGroups(cveData models.GiteOriginIssue, lop models.Loophole, c opScoreLeve = openEulerScoreProc(opScore) } sec.ReferenceLink = cveRef + cveData.CveNumber - sec.Introduction = "An update for " + lop.Components + " is now available for " + lop.InfProduct + "." + affectBrands := "" + if lop.InfVersion != "" && len(lop.InfVersion) > 1 { + affectBrands = AddAffectBrands(lop.InfVersion) + } else { + affectBrands = lop.InfProduct + } + sec.Introduction = "An update for " + lop.Components + " is now available for " + affectBrands + "." sec.Theme = sec.Introduction[:len(sec.Introduction)-1] + ";\n\n" + "openEuler Security has rated this" + " update as having a security impact of " + opScoreLeve + ". A Common Vunlnerability" + " Scoring System(CVSS)base score,which gives a detailed severity rating," + " is available for each vulnerability from the CVElink(s) in the References section." - sec.AffectProduct = lop.InfProduct + sec.AffectProduct = affectBrands var sc models.Score sc.CveNum = cveData.CveNumber nVDScore, nvdError := strconv.ParseFloat(lop.CvsScore, 64) @@ -1142,12 +1148,18 @@ func UpdateIssueCveGroups(cveData models.GiteOriginIssue, lop models.Loophole, c } else { opScoreLeve = openEulerScoreProc(opScore) } - sec.Introduction = "An update for " + lop.Components + " is now available for " + lop.InfProduct + "." + affectBrands := "" + if lop.InfVersion != "" && len(lop.InfVersion) > 1 { + affectBrands = AddAffectBrands(lop.InfVersion) + } else { + affectBrands = lop.InfProduct + } + sec.Introduction = "An update for " + lop.Components + " is now available for " + affectBrands + "." sec.Theme = sec.Introduction[:len(sec.Introduction)-1] + ";\n\n" + "openEuler Security has rated this" + " update as having a security impact of " + opScoreLeve + ". A Common Vunlnerability" + " Scoring System(CVSS)base score,which gives a detailed severity rating," + " is available for each vulnerability from the CVElink(s) in the References section." - sec.AffectProduct = lop.InfProduct + sec.AffectProduct = affectBrands nVDScore := 0.0 //var err error var score models.Score -- Gitee