From 4759b6c767abfb2675c8948bcc1a0e287617601c Mon Sep 17 00:00:00 2001 From: Spiegel Date: Tue, 31 Jan 2023 19:57:35 +0900 Subject: [PATCH] Drop v2/base package for issue #26 --- v2/base/base.go | 57 ----- v2/base/base_test.go | 573 ------------------------------------------- v2/base/severity.go | 8 - v2/cvss.go | 28 --- 4 files changed, 666 deletions(-) delete mode 100644 v2/base/base.go delete mode 100644 v2/base/base_test.go delete mode 100644 v2/base/severity.go delete mode 100644 v2/cvss.go diff --git a/v2/base/base.go b/v2/base/base.go deleted file mode 100644 index b01b66a..0000000 --- a/v2/base/base.go +++ /dev/null @@ -1,57 +0,0 @@ -package base - -import "github.com/goark/go-cvss/v2/metric" - -// Metrics is Base Metrics for CVSSv2 -// -// Deprecated: migrated github.com/goark/go-cvss/v2/metric package -type Metrics struct { - *metric.Environmental -} - -// NewMetrics returns Metrics instance -// -// Deprecated: migrated github.com/goark/go-cvss/v2/metric package -func NewMetrics() *Metrics { - return &Metrics{metric.NewEnvironmental()} -} - -// Decode returns Metrics instance by CVSSv2 vector -// -// Deprecated: migrated github.com/goark/go-cvss/v2/metric package -func Decode(vector string) (*Metrics, error) { - m := NewMetrics() - _, err := m.Decode(vector) - return m, err -} - -// Score returns score of Base metrics -// -// Deprecated: migrated github.com/goark/go-cvss/v2/metric package -func (m *Metrics) Score() float64 { - return m.Base.Score() -} - -// TemporalScore returns score of Temporal metrics -// -// Deprecated: migrated github.com/goark/go-cvss/v2/metric package -func (m *Metrics) TemporalScore() float64 { - return m.Temporal.Score() -} - -// EnvironmentalScore returns score of Environmental metrics -// -// Deprecated: migrated github.com/goark/go-cvss/v2/metric package -func (m *Metrics) EnvironmentalScore() float64 { - return m.Environmental.Score() -} - -// GetSeverity returns severity by score of Base metrics -// -// Deprecated: migrated github.com/goark/go-cvss/v2/metric package -func (m *Metrics) GetSeverity() Severity { - return Severity(m.Base.Severity()) -} - -/* Copyright 2022 luxifer */ -/* Contributed by Spiegel, 2023 */ diff --git a/v2/base/base_test.go b/v2/base/base_test.go deleted file mode 100644 index 085dc3f..0000000 --- a/v2/base/base_test.go +++ /dev/null @@ -1,573 +0,0 @@ -package base - -import ( - "errors" - "testing" - - "github.com/goark/go-cvss/cvsserr" -) - -func TestValidation(t *testing.T) { - testCases := []struct { - vec string - err error - }{ - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/RC:", err: cvsserr.ErrInvalidVector}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/:", err: cvsserr.ErrInvalidVector}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/:X", err: cvsserr.ErrInvalidVector}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/RC:0", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:0/RC:ND", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:0/RL:ND/RC:ND", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:0/E:U/RL:ND/RC:ND", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:H/Au:M/C:C/I:0/A:C/E:U/RL:ND/RC:ND", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:H/Au:M/C:0/I:N/A:C/E:U/RL:ND/RC:ND", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:H/Au:0/C:C/I:N/A:C/E:U/RL:ND/RC:ND", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:0/Au:M/C:C/I:N/A:C/E:U/RL:ND/RC:ND", err: cvsserr.ErrInvalidValue}, - {vec: "AV:0/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/RC:ND", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/RC:ND/CDP:H/TD:H/CR:M/IR:M/AR:0", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/RC:ND/CDP:H/TD:H/CR:M/IR:0/AR:H", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/RC:ND/CDP:H/TD:H/CR:0/IR:M/AR:H", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/RC:ND/CDP:H/TD:0/CR:M/IR:M/AR:H", err: cvsserr.ErrInvalidValue}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/RC:ND/CDP:0/TD:H/CR:M/IR:M/AR:H", err: cvsserr.ErrInvalidValue}, - {vec: "av:n/ac:l/au:n/c:n/i:n/a:c/e:u/rl:nd/rc:nd/cdp:h/td:h/cr:m/ir:m/ar:h", err: cvsserr.ErrNotSupportMetric}, - {vec: "AV:N/AC:L/AU:N/C:N/I:N/A:C/E:U/RL:ND/RC:ND/CDP:H/TD:H/CR:M/IR:M/AR:H", err: cvsserr.ErrNotSupportMetric}, - {vec: "AV:N/AC:L/Au:N/C:N/I:N/A:C", err: nil}, - {vec: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/RC:ND", err: nil}, - } - - for _, tc := range testCases { - _, err := Decode(tc.vec) - if !errors.Is(err, tc.err) { - t.Errorf("Decode(%s) = \"%+v\", want \"%v\".", tc.vec, err, tc.err) - } - } -} - -func TestScore(t *testing.T) { - tests := []struct { - name string - vector string - want float64 - }{ - { - name: "CVE-2002-0392", - vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C", - want: 7.8, - }, - { - name: "CVE-2003-0818", - vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C", - want: 10.0, - }, - { - name: "CVE-2003-0062", - vector: "AV:L/AC:H/Au:N/C:C/I:C/A:C", - want: 6.2, - }, - { - name: "test", - vector: "AV:N/AC:H/Au:M/C:C/I:N/A:C/E:U/RL:ND/RC:ND", - want: 6.2, - }, - { - name: "test2", - vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C", - want: 7.8, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - m, err := Decode(tt.vector) - - if err != nil { - t.Error(err) - } - - if got := m.Score(); got != tt.want { - t.Errorf("Metrics.Score() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestEnvScore(t *testing.T) { - tests := []struct { - name string - vector string - base float64 - temp float64 - env float64 - }{ - { - name: "CVE-2002-0392", - vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:F/RL:OF/RC:C/CDP:H/TD:H/CR:M/IR:M/AR:H", - base: 7.8, - temp: 6.4, - env: 9.2, - }, - { - name: "CVE-2003-0818", - vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C/E:F/RL:OF/RC:C/CDP:H/TD:H/CR:M/IR:M/AR:L", - base: 10.0, - temp: 8.3, - env: 9.0, - }, - { - name: "CVE-2003-0062", - vector: "AV:L/AC:H/Au:N/C:C/I:C/A:C/E:POC/RL:OF/RC:C/CDP:H/TD:H/CR:M/IR:M/AR:M", - base: 6.2, - temp: 4.9, - env: 7.5, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - m, err := Decode(tt.vector) - if err != nil { - t.Error(err) - } else { - if got := m.Score(); got != tt.base { - t.Errorf("Metrics.Score() = %v, want %v", got, tt.base) - } - if got := m.TemporalScore(); got != tt.temp { - t.Errorf("Metrics.TemporalScore() = %v, want %v", got, tt.env) - } - if got := m.EnvironmentalScore(); got != tt.env { - t.Errorf("Metrics.EnvironmentalScore() = %v, want %v", got, tt.temp) - } - } - - }) - } -} - -func TestDecode(t *testing.T) { - tests := []struct { - name string - vector string - }{ - - {name: "CVE-2019-18322", vector: "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2017-0145", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2018-7842", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2018-6821", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2020-11898", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2018-7779", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2019-18283", vector: "AV:N/AC:L/Au:S/C:C/I:C/A:C"}, - - {name: "CVE-2019-6812", vector: "AV:L/AC:M/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2020-6988", vector: "AV:A/AC:L/Au:N/C:N/I:P/A:P"}, - {name: "CVE-2019-12264", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - {name: "CVE-2018-7762", vector: "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2018-11466", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2017-12741", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2020-10040", vector: "AV:A/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2012-4703", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2017-11780", vector: "AV:N/AC:L/Au:N/C:C/I:N/A:N"}, - - {name: "CVE-2019-18335", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2018-11451", vector: "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2014-0781", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N"}, - {name: "CVE-2018-7064", vector: "AV:A/AC:M/Au:S/C:P/I:P/A:P"}, - - {name: "CVE-2018-11452", vector: "AV:L/AC:M/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2020-6990", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2019-0169", vector: "AV:N/AC:M/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2017-0280", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2020-7502", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P/E:POC/RL:OF/RC:C"}, - {name: "CVE-2014-0224", vector: "AV:N/AC:L/Au:S/C:N/I:P/A:N"}, - - {name: "CVE-2019-6807", vector: "AV:N/AC:L/Au:S/C:P/I:P/A:P"}, - {name: "CVE-2018-14795", vector: "AV:N/AC:M/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2019-10939", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N"}, - - {name: "CVE-2018-18065", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2018-16556", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2017-0147", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2016-0868", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:P/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2018-11457", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - - {name: "CVE-2018-7851", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2019-13946", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:C"}, - {name: "CVE-2014-3888", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N"}, - {name: "CVE-2015-6488", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2014-0754", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2011-4861", vector: "AV:A/AC:M/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2018-0175", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2019-18331", vector: "AV:L/AC:M/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2017-8461", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2018-0158", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2017-0275", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - {name: "CVE-2019-10953", vector: "AV:A/AC:L/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2018-0167", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2018-7244", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2019-12263", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2019-10920", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2017-6017", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2015-6492", vector: "AV:N/AC:L/Au:S/C:P/I:P/A:P"}, - - {name: "CVE-2019-18330", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2012-1815", vector: "AV:L/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2019-10931", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2017-14462", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2011-3389", vector: "AV:A/AC:L/Au:N/C:N/I:N/A:P"}, - {name: "CVE-2018-7758", vector: "AV:N/AC:L/Au:N/C:N/I:P/A:P"}, - - {name: "CVE-2019-18323", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2020-10044", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2019-13940", vector: "AV:A/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2017-2680", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2019-6816", vector: "AV:N/AC:L/Au:N/C:N/I:P/A:C"}, - - {name: "CVE-2018-7852", vector: "AV:N/AC:H/Au:N/C:N/I:P/A:P/E:U/RL:OF/RC:C"}, - - {name: "CVE-2018-0473", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:N"}, - {name: "CVE-2019-6572", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2012-6437", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - {name: "CVE-2018-7759", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2019-6852", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P/E:POC/RL:OF/RC:C"}, - {name: "CVE-2015-5698", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:C/E:POC/RL:OF/RC:C"}, - {name: "CVE-2014-2250", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2018-0472", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N"}, - - {name: "CVE-2019-13103", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2017-0279", vector: "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2017-0143", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - - {name: "CVE-2018-16196", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2019-12260", vector: "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2012-6440", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2018-7856", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2018-7809", vector: "AV:A/AC:L/Au:N/C:N/I:P/A:N"}, - - {name: "CVE-2019-13942", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - - {name: "CVE-2019-18217", vector: "AV:N/AC:L/Au:S/C:N/I:N/A:P"}, - {name: "CVE-2013-2761", vector: "AV:N/AC:L/Au:S/C:P/I:P/A:P"}, - - {name: "CVE-2019-6813", vector: "AV:L/AC:L/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2014-0300", vector: "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2017-0176", vector: "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2017-0146", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2018-7845", vector: "AV:N/AC:M/Au:N/C:C/I:N/A:N"}, - - {name: "CVE-2020-11897", vector: "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2019-18314", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - {name: "CVE-2019-6574", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - {name: "CVE-2012-1816", vector: "AV:N/AC:L/Au:N/C:N/I:P/A:N"}, - - {name: "CVE-2019-18284", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2018-5390", vector: "AV:N/AC:H/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2013-0169", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2019-18336", vector: "AV:N/AC:M/Au:N/C:N/I:N/A:P"}, - {name: "CVE-2017-0273", vector: "AV:N/AC:M/Au:N/C:N/I:N/A:P/E:U/RL:OF/RC:C"}, - - {name: "CVE-2019-18302", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2019-12256", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2016-7113", vector: "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2014-0301", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2016-9159", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2017-0274", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2018-7242", vector: "AV:L/AC:H/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2017-5176", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2018-13816", vector: "AV:N/AC:M/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2012-4690", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2016-5645", vector: "AV:N/AC:L/Au:N/C:N/I:P/A:N"}, - - {name: "CVE-2017-14470", vector: "AV:N/AC:H/Au:N/C:P/I:P/A:C"}, - {name: "CVE-2013-4651", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2018-7848", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2018-11460", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2018-7833", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2018-19282", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2020-11914", vector: "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2017-0272", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2015-7937", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - - {name: "CVE-2017-12089", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2012-6436", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2019-18292", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:P/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2019-6850", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - - {name: "CVE-2019-6806", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2018-13810", vector: "AV:N/AC:M/Au:S/C:N/I:P/A:N"}, - {name: "CVE-2018-19615", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:P"}, - {name: "CVE-2017-6030", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2018-14797", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2018-13814", vector: "AV:N/AC:M/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2020-7575", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2019-11478", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2012-0929", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2020-6980", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:C/E:POC/RL:OF/RC:C"}, - {name: "CVE-2014-2251", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:U/RC:C"}, - - {name: "CVE-2019-19301", vector: "AV:N/AC:M/Au:S/C:N/I:P/A:N"}, - {name: "CVE-2019-6577", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2019-18289", vector: "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2018-16563", vector: "AV:N/AC:M/Au:N/C:N/I:N/A:P"}, - - {name: "CVE-2020-11909", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2016-6329", vector: "AV:A/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2020-11911", vector: "AV:N/AC:M/Au:S/C:P/I:N/A:N"}, - - {name: "CVE-2019-18306", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2020-11905", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - - {name: "CVE-2019-18298", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2016-7112", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2019-18297", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2019-6833", vector: "AV:N/AC:M/Au:S/C:N/I:N/A:P"}, - - {name: "CVE-2019-6851", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2019-13926", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2017-14464", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:P/E:POC/RL:OF/RC:C"}, - {name: "CVE-2014-2249", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2018-7843", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2015-1049", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - {name: "CVE-2016-2200", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:C"}, - {name: "CVE-2014-0782", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N"}, - {name: "CVE-2012-1814", vector: "AV:A/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2018-4833", vector: "AV:A/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - {name: "CVE-2014-2252", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2017-16740", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2019-19281", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2018-7800", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2012-6435", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2019-18300", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:N"}, - {name: "CVE-2017-6026", vector: "AV:L/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2014-2349", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2018-15377", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:N/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2019-18304", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2018-13808", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - {name: "CVE-2019-6568", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2009-3739", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2019-10919", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2018-7804", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2019-18311", vector: "AV:N/AC:M/Au:S/C:P/I:P/A:P"}, - {name: "CVE-2016-8561", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - - {name: "CVE-2018-3657", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2020-7525", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2012-6438", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2019-6848", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2020-11901", vector: "AV:N/AC:H/Au:N/C:N/I:C/A:N"}, - {name: "CVE-2014-0317", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2016-8672", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - - {name: "CVE-2017-12088", vector: "AV:L/AC:L/Au:N/C:C/I:N/A:C"}, - - {name: "CVE-2019-18334", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2016-4784", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N"}, - - {name: "CVE-2018-11458", vector: "AV:A/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2018-4843", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2018-11463", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2018-19616", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2016-8673", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2017-6868", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2017-0267", vector: "AV:N/AC:L/Au:N/C:N/I:P/A:P"}, - {name: "CVE-2012-1818", vector: "AV:N/AC:L/Au:S/C:P/I:N/A:N"}, - {name: "CVE-2018-7781", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2019-6858", vector: "AV:N/AC:L/Au:S/C:P/I:P/A:C"}, - {name: "CVE-2013-3633", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - - {name: "CVE-2020-10042", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2017-0271", vector: "AV:A/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2018-13809", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2012-6442", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:C"}, - - {name: "CVE-2019-6828", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C/E:F/RL:OF/RC:C"}, - {name: "CVE-2013-0659", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2019-13925", vector: "AV:N/AC:L/Au:S/C:N/I:N/A:C"}, - {name: "CVE-2014-8479", vector: "AV:L/AC:M/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2014-0755", vector: "AV:A/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2019-18303", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2019-6832", vector: "AV:L/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2018-13813", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2018-7083", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2017-14467", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2018-7834", vector: "AV:N/AC:L/Au:N/C:P/I:C/A:C/E:POC/RL:OF/RC:C"}, - {name: "CVE-2015-8214", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2017-7902", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2019-18288", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2018-5391", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2018-0174", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2018-4842", vector: "AV:N/AC:L/Au:N/C:N/I:P/A:P"}, - {name: "CVE-2018-7245", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2018-13812", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2020-10043", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2019-18328", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2012-1817", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2020-11914", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2019-6856", vector: "AV:N/AC:M/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - {name: "CVE-2014-5074", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2019-18301", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - {name: "CVE-2018-10592", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - - {name: "CVE-2019-18320", vector: "AV:A/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2018-14793", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2018-7853", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2019-12261", vector: "AV:N/AC:M/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2016-7090", vector: "AV:N/AC:L/Au:N/C:P/I:N/A:N/E:H/RL:OF/RC:C"}, - {name: "CVE-2014-0160", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:P/E:POC/RL:OF/RC:C"}, - {name: "CVE-2014-2908", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - - {name: "CVE-2019-5909", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N"}, - - {name: "CVE-2018-7830", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P"}, - - {name: "CVE-2018-0470", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:C"}, - - {name: "CVE-2019-18290", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:F/RL:OF/RC:C"}, - - {name: "CVE-2017-12093", vector: "AV:N/AC:H/Au:N/C:N/I:P/A:N/E:U/RL:OF/RC:C"}, - - {name: "CVE-2020-10045", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C"}, - {name: "CVE-2017-9312", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2020-5608", vector: "AV:N/AC:L/Au:S/C:P/I:N/A:N"}, - - {name: "CVE-2018-15373", vector: "AV:N/AC:L/Au:N/C:C/I:C/A:C"}, - - {name: "CVE-2018-16557", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2020-11913", vector: "AV:A/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C"}, - - {name: "CVE-2018-7821", vector: "AV:A/AC:L/Au:N/C:P/I:P/A:P"}, - {name: "CVE-2019-12257", vector: "AV:A/AC:L/Au:N/C:P/I:N/A:N"}, - {name: "CVE-2018-14526", vector: "AV:L/AC:L/Au:N/C:P/I:P/A:P"}, - - {name: "CVE-2018-7846", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:TF/RC:C"}, - - {name: "CVE-2020-7477", vector: "AV:N/AC:L/Au:S/C:N/I:N/A:P"}, - - {name: "CVE-2019-13933", vector: "AV:N/AC:M/Au:N/C:P/I:P/A:C"}, - - {name: "CVE-2018-4848", vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N"}, - - {name: "CVE-2020-7592", vector: "AV:N/AC:L/Au:N/C:P/I:P/A:C"}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - _, err := Decode(tt.vector) - - if err != nil { - t.Error(err) - } - }) - } -} - -func TestEncode(t *testing.T) { - tests := []struct { - name string - vector string - outp string - }{ - {name: "CVE-2020-7477", vector: "AV:N/AC:L/Au:S/C:N/I:N/A:P", outp: "AV:N/AC:L/Au:S/C:N/I:N/A:P"}, - {name: "CVE-2018-7846-1", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:TF/RC:C", outp: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:TF/RC:C"}, - {name: "CVE-2018-7846-2", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:ND/RL:ND/RC:ND", outp: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:ND/RL:ND/RC:ND"}, - {name: "CVE-2018-7846-3", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC", outp: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:ND/RC:ND"}, - {name: "CVE-2018-7846-4", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/RL:TF", outp: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:ND/RL:TF/RC:ND"}, - {name: "CVE-2018-7846-5", vector: "AV:N/AC:L/Au:N/C:N/I:N/A:C/RC:C", outp: "AV:N/AC:L/Au:N/C:N/I:N/A:C/E:ND/RL:ND/RC:C"}, - {name: "Issue #23-1", vector: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:N/TD:H/CR:M/IR:M/AR:M", outp: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:N/TD:H/CR:M/IR:M/AR:M"}, - {name: "Issue #23-2", vector: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:ND/TD:ND/CR:M/IR:ND/AR:ND", outp: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:ND/TD:ND/CR:M/IR:ND/AR:ND"}, - {name: "Issue #23-3", vector: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:N/TD:H/CR:M/IR:M", outp: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:N/TD:H/CR:M/IR:M/AR:ND"}, - {name: "Issue #23-4", vector: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:N/TD:H/CR:M/AR:M", outp: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:N/TD:H/CR:M/IR:ND/AR:M"}, - {name: "Issue #23-5", vector: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:N/TD:H/IR:M/AR:M", outp: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:N/TD:H/CR:ND/IR:M/AR:M"}, - {name: "Issue #23-6", vector: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:N/CR:M/IR:M/AR:M", outp: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:N/TD:ND/CR:M/IR:M/AR:M"}, - {name: "Issue #23-7", vector: "AV:L/AC:M/Au:S/C:N/I:N/A:P/TD:H/CR:M/IR:M/AR:M", outp: "AV:L/AC:M/Au:S/C:N/I:N/A:P/CDP:ND/TD:H/CR:M/IR:M/AR:M"}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - m, err := Decode(tt.vector) - if err != nil { - t.Error(err) - } else if m.String() != tt.outp { - t.Errorf("String() = %v, want %v.", m.String(), tt.outp) - } - }) - } -} - -/* Copyright 2022 luxifer */ -/* Contributed by Spiegel, 2023 */ diff --git a/v2/base/severity.go b/v2/base/severity.go deleted file mode 100644 index 5ca2a7f..0000000 --- a/v2/base/severity.go +++ /dev/null @@ -1,8 +0,0 @@ -package base - -import "github.com/goark/go-cvss/v2/metric" - -// Severity is severity for Base Metrics -type Severity = metric.Severity - -/* Copyright 2022 luxifer */ diff --git a/v2/cvss.go b/v2/cvss.go deleted file mode 100644 index 6022800..0000000 --- a/v2/cvss.go +++ /dev/null @@ -1,28 +0,0 @@ -package v2 - -import ( - "github.com/goark/go-cvss/v2/metric" -) - -// CVSS is type of CVSS -type CVSS struct { - Base *metric.Base -} - -// New returns CVSS instance -func New() *CVSS { - return &CVSS{metric.NewBase()} -} - -// ImportBaseVector imports CVSSv2.0 base metrics vector -func (c *CVSS) ImportBaseVector(v string) error { - m, err := c.Base.Decode(v) - if err != nil { - return err - } - c.Base = m - return nil -} - -/* Copyright 2022 luxifer */ -/* Contributed by Spiegel, 2023 */