* update trivy, fanal. unsupport image scanning * Update models/library.go Co-authored-by: Teppei Fukuda <teppei@elab.ic.i.u-tokyo.ac.jp> * add -no-progress flag to report/tui cmd * Display trivy vuln info to tui/report * add detection method to vulninfo detected by trivy * fix(uuid): change uuid lib to go-uuid #929 (#969) * update trivy, fanal. unsupport image scanning * Update models/library.go Co-authored-by: Teppei Fukuda <teppei@elab.ic.i.u-tokyo.ac.jp> * add -no-progress flag to report/tui cmd * Display trivy vuln info to tui/report * add detection method to vulninfo detected by trivy * unique ref links in TUI * download trivy DB only when lock file is specified in config.toml Co-authored-by: Teppei Fukuda <teppei@elab.ic.i.u-tokyo.ac.jp>
		
			
				
	
	
		
			45 lines
		
	
	
		
			982 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			982 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package config
 | 
						|
 | 
						|
import (
 | 
						|
	"testing"
 | 
						|
)
 | 
						|
 | 
						|
func TestToCpeURI(t *testing.T) {
 | 
						|
	var tests = []struct {
 | 
						|
		in       string
 | 
						|
		expected string
 | 
						|
		err      bool
 | 
						|
	}{
 | 
						|
		{
 | 
						|
			in:       "",
 | 
						|
			expected: "",
 | 
						|
			err:      true,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			in:       "cpe:/a:microsoft:internet_explorer:10",
 | 
						|
			expected: "cpe:/a:microsoft:internet_explorer:10",
 | 
						|
			err:      false,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			in:       "cpe:2.3:a:microsoft:internet_explorer:10:*:*:*:*:*:*:*",
 | 
						|
			expected: "cpe:/a:microsoft:internet_explorer:10",
 | 
						|
			err:      false,
 | 
						|
		},
 | 
						|
	}
 | 
						|
 | 
						|
	for i, tt := range tests {
 | 
						|
		actual, err := toCpeURI(tt.in)
 | 
						|
		if err != nil && !tt.err {
 | 
						|
			t.Errorf("[%d] unexpected error occurred, in: %s act: %s, exp: %s",
 | 
						|
				i, tt.in, actual, tt.expected)
 | 
						|
		} else if err == nil && tt.err {
 | 
						|
			t.Errorf("[%d] expected error is not occurred, in: %s act: %s, exp: %s",
 | 
						|
				i, tt.in, actual, tt.expected)
 | 
						|
		}
 | 
						|
		if actual != tt.expected {
 | 
						|
			t.Errorf("[%d] in: %s, actual: %s, expected: %s",
 | 
						|
				i, tt.in, actual, tt.expected)
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 |