diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-02-20 10:36:52 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-02-20 10:36:52 -0500 |
commit | 4cbd88b2387f12b9052033fc05445e2c6b54ab96 (patch) | |
tree | 9dbf95b13d58e6b77d3c417ead8821b418b18fe9 /dbstore/dbstore_test.go | |
parent | bcfce83f66a04154ad54769b4bf8de21fd425c3f (diff) | |
download | cvez-4cbd88b2387f12b9052033fc05445e2c6b54ab96.tar.bz2 cvez-4cbd88b2387f12b9052033fc05445e2c6b54ab96.zip |
dbstore: add AddCveFeeds(), fix bugs, fix TestAddCveFeed
Diffstat (limited to 'dbstore/dbstore_test.go')
-rw-r--r-- | dbstore/dbstore_test.go | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/dbstore/dbstore_test.go b/dbstore/dbstore_test.go index 2dcadfa..e6e901e 100644 --- a/dbstore/dbstore_test.go +++ b/dbstore/dbstore_test.go @@ -1006,13 +1006,43 @@ func TestAddCveFeed(t *testing.T) { } } +func getTestCveId(t *testing.T, s string) nvd_feed.CveId { + r, err := nvd_feed.NewCveId(s) + if err != nil { + // raise test error + t.Error(err) + } + return r +} + func TestCveSearch(t *testing.T) { ctx := context.Background() - tests := []string { - "cisco anyconnect ipc dll mobility secure", - } -// [{"nvd_cve_id":"CVE-2021-1366","rank":-36.4874758136269,"description":"A vulnerability in the interprocess communication (IPC) channel of Cisco AnyConnect Secure Mobility Client for Windows could allow an authenticated, local attacker to perform a DLL hijacking attack on an affected device if the VPN Posture (HostScan) Module is installed on the AnyConnect client. This vulnerability is due to insufficient validation of resources that are loaded by the application at run time. An attacker could exploit this vulnerability by sending a crafted IPC message to the AnyConnect process. A successful exploit could allow the attacker to execute arbitrary code on the affected machine with SYSTEM privileges. To exploit this vulnerability, the attacker needs valid credentials on the Windows system."},{"nvd_cve_id":"CVE-2021-1567","rank":-34.6220092956805,"description":"A vulnerability in the DLL loading mechanism of Cisco AnyConnect Secure Mobility Client for Windows could allow an authenticated, local attacker to perform a DLL hijacking attack on an affected device if the VPN Posture (HostScan) Module is installed on the AnyConnect client. This vulnerability is due to a race condition in the signature verification process for DLL files that are loaded on an affected device. An attacker could exploit this vulnerability by sending a series of crafted interprocess communication (IPC) messages to the AnyConnect process. A successful exploit could allow the attacker to execute arbitrary code on the affected device with SYSTEM privileges. To exploit this vulnerability, the attacker must have valid credentials on the Windows system."}] + tests := []struct { + val string + exp []CveSearchRow + } {{ + val: "cisco anyconnect ipc dll mobility secure", + exp: []CveSearchRow { + CveSearchRow { + Id: 9315, + CveId: getTestCveId(t, "CVE-2021-1366"), + Description: "A vulnerability in the interprocess communication (IPC) channel of Cisco AnyConnect Secure Mobility Client for Windows could allow an authenticated, local attacker to perform a DLL hijacking attack on an affected device if the VPN Posture (HostScan) Module is installed on the AnyConnect client. This vulnerability is due to insufficient validation of resources that are loaded by the application at run time. An attacker could exploit this vulnerability by sending a crafted IPC message to the AnyConnect process. A successful exploit could allow the attacker to execute arbitrary code on the affected machine with SYSTEM privileges. To exploit this vulnerability, the attacker needs valid credentials on the Windows system.", + V3BaseScore: nvd_feed.Score(uint8(78)), + V3Severity: nvd_feed.SeverityHigh, + Rank: -36.487476, + }, + + CveSearchRow { + Id: 9495, + CveId: getTestCveId(t, "CVE-2021-1567"), + Description: "A vulnerability in the DLL loading mechanism of Cisco AnyConnect Secure Mobility Client for Windows could allow an authenticated, local attacker to perform a DLL hijacking attack on an affected device if the VPN Posture (HostScan) Module is installed on the AnyConnect client. This vulnerability is due to a race condition in the signature verification process for DLL files that are loaded on an affected device. An attacker could exploit this vulnerability by sending a series of crafted interprocess communication (IPC) messages to the AnyConnect process. A successful exploit could allow the attacker to execute arbitrary code on the affected device with SYSTEM privileges. To exploit this vulnerability, the attacker must have valid credentials on the Windows system.", + V3BaseScore: nvd_feed.Score(uint8(67)), + V3Severity: nvd_feed.SeverityMedium, + Rank: -34.62201, + }, + }, + }} // open test db db, err := Open("testdata/cvesearch-test.db") @@ -1023,12 +1053,12 @@ func TestCveSearch(t *testing.T) { // run tests for _, test := range(tests) { - t.Run(test, func(t *testing.T) { - rows, err := db.CveSearch(ctx, test) + t.Run(test.val, func(t *testing.T) { + got, err := db.CveSearch(ctx, test.val) if err != nil { t.Error(err) - } else { - t.Errorf("success: got %v", rows) + } else if !reflect.DeepEqual(got, test.exp) { + t.Errorf("got \"%v\", exp \"%v\"", got, test.exp) } }) } |