github.com/khulnasoft-lab/tunnel-db@v0.0.0-20231117205118-74e1113bd007/pkg/vulnsrc/ubuntu/ubuntu_test.go (about)

     1  package ubuntu_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/khulnasoft-lab/tunnel-db/pkg/types"
     7  	"github.com/khulnasoft-lab/tunnel-db/pkg/vulnsrc/ubuntu"
     8  	"github.com/khulnasoft-lab/tunnel-db/pkg/vulnsrc/vulnerability"
     9  	"github.com/khulnasoft-lab/tunnel-db/pkg/vulnsrctest"
    10  )
    11  
    12  func TestVulnSrc_Update(t *testing.T) {
    13  	tests := []struct {
    14  		name       string
    15  		dir        string
    16  		wantValues []vulnsrctest.WantValues
    17  		noBuckets  [][]string
    18  		wantErr    string
    19  	}{
    20  		{
    21  			name: "happy path",
    22  			dir:  "testdata",
    23  			wantValues: []vulnsrctest.WantValues{
    24  				{
    25  					Key: []string{"data-source", "ubuntu 18.04"},
    26  					Value: types.DataSource{
    27  						ID:   vulnerability.Ubuntu,
    28  						Name: "Ubuntu CVE Tracker",
    29  						URL:  "https://git.launchpad.net/ubuntu-cve-tracker",
    30  					},
    31  				},
    32  				{
    33  					Key: []string{"advisory-detail", "CVE-2020-1234", "ubuntu 18.04", "xen"},
    34  					Value: types.Advisory{
    35  						FixedVersion: "1.2.3",
    36  					},
    37  				},
    38  				{
    39  					Key: []string{"vulnerability-detail", "CVE-2020-1234", "ubuntu"},
    40  					Value: types.VulnerabilityDetail{
    41  						Description: "Observable response discrepancy in some Intel(R) Processors may allow an authorized user to potentially enable information disclosure via local access.",
    42  						Severity:    2,
    43  						References:  []string{"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-0089"},
    44  					},
    45  				},
    46  			},
    47  			noBuckets: [][]string{
    48  				{"advisory-detail", "CVE-2020-1234", "ubuntu 20.04"},
    49  			},
    50  		},
    51  	}
    52  	for _, tt := range tests {
    53  		t.Run(tt.name, func(t *testing.T) {
    54  			vs := ubuntu.NewVulnSrc()
    55  			vulnsrctest.TestUpdate(t, vs, vulnsrctest.TestUpdateArgs{
    56  				Dir:        tt.dir,
    57  				WantValues: tt.wantValues,
    58  				WantErr:    tt.wantErr,
    59  			})
    60  		})
    61  	}
    62  }