Skip to content

Commit

Permalink
fix: 修复SecurityResult部分字段被序列化为null导致上报错误
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlkl committed Jul 13, 2023
1 parent 0d90f1e commit 119bc23
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion standard-adapter/pkg/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (e StandardAdapterExecutor) readToolOutput(f string) (*object.ToolOutput, e
}

for i := range output.Result.SecurityResults {
r := output.Result.SecurityResults[i]
r := &output.Result.SecurityResults[i]
if r.PkgVersions == nil {
r.PkgVersions = []string{}
}
Expand Down
14 changes: 14 additions & 0 deletions standard-adapter/pkg/adapter_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package pkg

import (
"fmt"
"testing"
)

func TestReadToolOutput(t *testing.T) {
output, err := StandardAdapterExecutor{}.readToolOutput("testdata/output.json")
if err != nil {
fmt.Println(err.Error())
}
fmt.Println(output.Result.SecurityResults)
}
35 changes: 35 additions & 0 deletions standard-adapter/pkg/testdata/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"status": "SUCCESS",
"err": null,
"taskId": "test",
"result": {
"securityResults": [
{
"vulId": "CVE-2020-1971 ",
"cveId": "CVE-2020-1971 ",
"path": "/path/to",
"pkgName": "openssl/openssl",
"effectedVersion": " <1.1.1i ",
"des": "test",
"references": [
" https://github.com/openssl/openssl/commit/b33c48b75aaf33c93aeda42d7138616b9e6a64cb "
],
"cvss": 5.9,
"severity": "medium"
},
{
"vulId": "CVE-2014-0076 ",
"cveId": "CVE-2014-0076 ",
"path": "/path/to",
"pkgName": "openssl/openssl",
"effectedVersion": " 1.0.0l ",
"des": "test",
"references": [
" https://github.com/openssl/openssl/commit/f9b6c0ba4c02497782f801e3c45688f3efaac55c "
],
"cvss": 1.9,
"severity": "low"
}
]
}
}

0 comments on commit 119bc23

Please sign in to comment.