From 2d3f918bb19c662765a8d2c384a8a1fb231bfe13 Mon Sep 17 00:00:00 2001 From: luotianqi777 Date: Fri, 20 Sep 2024 11:28:56 +0800 Subject: [PATCH] fix: dsdx nil pointer panic --- opensca/sca/sbom/dsdx.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opensca/sca/sbom/dsdx.go b/opensca/sca/sbom/dsdx.go index dbc0e80..690f7dc 100644 --- a/opensca/sca/sbom/dsdx.go +++ b/opensca/sca/sbom/dsdx.go @@ -31,7 +31,7 @@ func ParseDsdxXml(f *model.File) *model.DepGraph { func parseDsdxDoc(f *model.File, doc *model.DsdxDocument) *model.DepGraph { - if doc == nil { + if doc == nil || len(doc.Components) == 0 { return nil } @@ -76,7 +76,7 @@ func parseDsdxDoc(f *model.File, doc *model.DsdxDocument) *model.DepGraph { // ReadDsdx 读取dsdx文件 func ReadDsdx(f *model.File) *model.DsdxDocument { - dsdx := &model.DsdxDocument{} + dsdx := &model.DsdxDocument{Dependencies: model.DsdxDependencies{}} // 记录依赖关系 dependencies := map[string][]string{}