From 7e7eec391f6b72ba91a8cfefa5e30d27e52c95ab Mon Sep 17 00:00:00 2001 From: huyongfeng <74482671+itxiaohu001@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:04:22 +0800 Subject: [PATCH] bugfix (#36) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 使用本地漏洞库时报空指针错误 * Update vuln samples in readme * Update vuln samples in readme Co-authored-by: huyongfeng --- .github/README.md | 3 +-- README.md | 3 +-- util/vuln/local.go | 8 +++++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/README.md b/.github/README.md index fe0ceba2..2467622c 100644 --- a/.github/README.md +++ b/.github/README.md @@ -113,8 +113,7 @@ opensca-cli -db db.json -path ${project_path} "release_date": "2021-12-10", "security_level_id": 1, "exploit_level_id": 1 - }, - {} + } ] ``` diff --git a/README.md b/README.md index 16c22ac9..688688b7 100644 --- a/README.md +++ b/README.md @@ -112,8 +112,7 @@ opensca-cli -db db.json -path ${project_path} "release_date": "2021-12-10", "security_level_id": 1, "exploit_level_id": 1 - }, - {} + } ] ``` diff --git a/util/vuln/local.go b/util/vuln/local.go index 90d62f80..68ce53ad 100644 --- a/util/vuln/local.go +++ b/util/vuln/local.go @@ -36,8 +36,14 @@ func loadVulnDB() { } else { // 解析本地漏洞 db := []vulnInfo{} - json.Unmarshal(data, &db) + err := json.Unmarshal(data, &db) + if err != nil { + logs.Error(err) + } for _, info := range db { + if info.Vuln == nil { + continue + } // 有中文描述则省略英文描述 if info.Description != "" { info.DescriptionEn = ""