зеркало из https://github.com/golang/vuln.git
internal/vulncheck: avoid recomputing if module is known
This also makes the code cleaner. Change-Id: Ia59ed7dbf6487ee1ddcb67ffb05bd57668268e62 Reviewed-on: https://go-review.googlesource.com/c/vuln/+/594217 Reviewed-by: Maceo Thompson <maceothompson@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Родитель
03a0c2f3be
Коммит
afa91f17c8
|
@ -220,12 +220,10 @@ func matchesPlatformComponent(s string, ps []string) bool {
|
|||
// it figures the module from package importPath. It returns the module
|
||||
// whose path is the longest prefix of importPath.
|
||||
func (aff affectingVulns) moduleVulns(module, importPath string) *ModVulns {
|
||||
unknown := func(module string) bool {
|
||||
return module == "" || module == internal.UnknownModulePath
|
||||
}
|
||||
moduleKnown := module != "" && module != internal.UnknownModulePath
|
||||
|
||||
isStd := IsStdPackage(importPath)
|
||||
var mostSpecificMod *ModVulns // for the case where unknown(module)
|
||||
var mostSpecificMod *ModVulns // for the case where !moduleKnown
|
||||
for _, mod := range aff {
|
||||
md := mod
|
||||
if isStd && mod.Module.Path == internal.GoStdModulePath {
|
||||
|
@ -234,7 +232,7 @@ func (aff affectingVulns) moduleVulns(module, importPath string) *ModVulns {
|
|||
return md
|
||||
}
|
||||
|
||||
if !unknown(module) {
|
||||
if moduleKnown {
|
||||
if mod.Module.Path == module {
|
||||
// If we know exactly which module we need,
|
||||
// return its vulnerabilities.
|
||||
|
|
Загрузка…
Ссылка в новой задаче