Fix 'reference' info nil pointer dereference. (#4005) (#4006)

* Fix 'reference' info nil pointer dereference. (#4005)

* test path update

* test fixes

---------

Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
This commit is contained in:
lu4nx 2023-07-30 15:32:50 +08:00 committed by GitHub
parent 03bdd24fb9
commit 5ab39fca25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -18,9 +18,9 @@ var templatesPathTestCases = []TestCaseInfo{
//cwd
{Path: "./dns/cname-fingerprint.yaml", TestCase: &cwdTemplateTest{}},
//relative path
{Path: "dns/cname-fingerprint.yaml", TestCase: &relativePathTemplateTest{}},
{Path: "dns/dns-saas-service-detection.yaml", TestCase: &relativePathTemplateTest{}},
//absolute path
{Path: fmt.Sprintf("%v/dns/cname-fingerprint.yaml", getTemplatePath()), TestCase: &absolutePathTemplateTest{}},
{Path: fmt.Sprintf("%v/dns/dns-saas-service-detection.yaml", getTemplatePath()), TestCase: &absolutePathTemplateTest{}},
}
type cwdTemplateTest struct{}

View File

@ -113,7 +113,7 @@ func CreateReportDescription(event *output.ResultEvent, formatter ResultFormatte
}
reference := event.Info.Reference
if !reference.IsEmpty() {
if reference != nil && !reference.IsEmpty() {
builder.WriteString("\nReferences: \n")
referenceSlice := reference.ToSlice()