Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: the tests will be failed, if there is scannercli #120

Open
afdesk opened this issue Oct 3, 2023 · 0 comments
Open

chore: the tests will be failed, if there is scannercli #120

afdesk opened this issue Oct 3, 2023 · 0 comments

Comments

@afdesk
Copy link
Contributor

afdesk commented Oct 3, 2023

the tests for some packages will be failed, when there is scannercli executable binary in the environment.
it seems it's a bug

--- FAIL: TestHandler (1.46s)
    --- FAIL: TestHandler/GET_/api/v1/metadata (1.46s)
        handler_test.go:36: 
            	Error Trace:	handler_test.go:36
            	Error:      	Not equal: 
            	            	expected: map[string]interface {}{"capabilities":[]interface {}{map[string]interface {}{"consumes_mime_types":[]interface {}{"application/vnd.oci.image.manifest.v1+json", "application/vnd.docker.distribution.manifest.v2+json"}, "produces_mime_types":[]interface {}{"application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0"}}}, "properties":map[string]interface {}{"env.SCANNER_AQUA_HOST":"http://csp-console-svc.aqua:8080", "env.SCANNER_AQUA_REGISTRY":"Harbor", "env.SCANNER_AQUA_REPORTS_DIR":"/var/lib/scanner/reports", "env.SCANNER_AQUA_USE_IMAGE_TAG":"true", "env.SCANNER_CLI_DIRECT_CC":"false", "env.SCANNER_CLI_NO_VERIFY":"false", "env.SCANNER_CLI_OVERRIDE_REGISTRY_CREDENTIALS":"false", "env.SCANNER_CLI_REGISTER_IMAGES":"Never", "env.SCANNER_CLI_SHOW_NEGLIGIBLE":"true", "harbor.scanner-adapter/scanner-type":"os-package-vulnerability", "org.label-schema.build-date":"20-04-1319T13:45:00", "org.label-schema.vcs":"https://github.com/aquasecurity/harbor-scanner-aqua", "org.label-schema.vcs-ref":"abc", "org.label-schema.version":"v0.0.5"}, "scanner":map[string]interface {}{"name":"Aqua Enterprise", "vendor":"Aqua Security", "version":"Unknown"}}
            	            	actual  : map[string]interface {}{"capabilities":[]interface {}{map[string]interface {}{"consumes_mime_types":[]interface {}{"application/vnd.oci.image.manifest.v1+json", "application/vnd.docker.distribution.manifest.v2+json"}, "produces_mime_types":[]interface {}{"application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0"}}}, "properties":map[string]interface {}{"env.SCANNER_AQUA_HOST":"http://csp-console-svc.aqua:8080", "env.SCANNER_AQUA_REGISTRY":"Harbor", "env.SCANNER_AQUA_REPORTS_DIR":"/var/lib/scanner/reports", "env.SCANNER_AQUA_USE_IMAGE_TAG":"true", "env.SCANNER_CLI_DIRECT_CC":"false", "env.SCANNER_CLI_NO_VERIFY":"false", "env.SCANNER_CLI_OVERRIDE_REGISTRY_CREDENTIALS":"false", "env.SCANNER_CLI_REGISTER_IMAGES":"Never", "env.SCANNER_CLI_SHOW_NEGLIGIBLE":"true", "harbor.scanner-adapter/scanner-type":"os-package-vulnerability", "org.label-schema.build-date":"20-04-1319T13:45:00", "org.label-schema.vcs":"https://github.com/aquasecurity/harbor-scanner-aqua", "org.label-schema.vcs-ref":"abc", "org.label-schema.version":"v0.0.5"}, "scanner":map[string]interface {}{"name":"Aqua Enterprise", "vendor":"Aqua Security", "version":"scannercli version 2022.4.424, compiled Sep 26 2023 16:46:15\n"}}
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -31,3 +31,3 @@
            	            	   (string) (len=6) "vendor": (string) (len=13) "Aqua Security",
            	            	-  (string) (len=7) "version": (string) (len=7) "Unknown"
            	            	+  (string) (len=7) "version": (string) (len=61) "scannercli version 2022.4.424, compiled Sep 26 2023 16:46:15\n"
            	            	  }
            	Test:       	TestHandler/GET_/api/v1/metadata
FAIL
FAIL	github.com/aquasecurity/harbor-scanner-aqua/pkg/http/api/v1	1.479s
ok  	github.com/aquasecurity/harbor-scanner-aqua/pkg/redisx	0.021s
--- FAIL: TestTransformer_Transform (1.22s)
    transformer_test.go:56: 
        	Error Trace:	transformer_test.go:56
        	Error:      	Not equal: 
        	            	expected: harbor.ScanReport{GeneratedAt:time.Date(2023, time.October, 4, 1, 2, 37, 662176667, time.Local), Artifact:harbor.Artifact{Repository:"library/golang", Digest:"", Tag:"1.12.4", MimeType:""}, Scanner:harbor.Scanner{Name:"Aqua Enterprise", Vendor:"Aqua Security", Version:"Unknown"}, Severity:6, Vulnerabilities:[]harbor.VulnerabilityItem{harbor.VulnerabilityItem{ID:"CVE-0001-0020", Pkg:"openssl", Version:"2.8.3", FixVersion:"", Severity:5, Description:"", Links:[]string{"http://nvd?id=CVE-0001-0020"}}, harbor.VulnerabilityItem{ID:"CVE-3045-2011", Pkg:"openssl", Version:"2.8.3", FixVersion:"", Severity:3, Description:"", Links:[]string(nil)}, harbor.VulnerabilityItem{ID:"CVE-9900-1100", Pkg:"/app/main.rb", Version:"", FixVersion:"", Severity:6, Description:"", Links:[]string(nil)}}}
        	            	actual  : harbor.ScanReport{GeneratedAt:time.Date(2023, time.October, 4, 1, 2, 37, 662176667, time.Local), Artifact:harbor.Artifact{Repository:"library/golang", Digest:"", Tag:"1.12.4", MimeType:""}, Scanner:harbor.Scanner{Name:"Aqua Enterprise", Vendor:"Aqua Security", Version:"scannercli version 2022.4.424, compiled Sep 26 2023 16:46:15\n"}, Severity:6, Vulnerabilities:[]harbor.VulnerabilityItem{harbor.VulnerabilityItem{ID:"CVE-0001-0020", Pkg:"openssl", Version:"2.8.3", FixVersion:"", Severity:5, Description:"", Links:[]string{"http://nvd?id=CVE-0001-0020"}}, harbor.VulnerabilityItem{ID:"CVE-3045-2011", Pkg:"openssl", Version:"2.8.3", FixVersion:"", Severity:3, Description:"", Links:[]string(nil)}, harbor.VulnerabilityItem{ID:"CVE-9900-1100", Pkg:"/app/main.rb", Version:"", FixVersion:"", Severity:6, Description:"", Links:[]string(nil)}}}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -23,3 +23,3 @@
        	            	   Vendor: (string) (len=13) "Aqua Security",
        	            	-  Version: (string) (len=7) "Unknown"
        	            	+  Version: (string) (len=61) "scannercli version 2022.4.424, compiled Sep 26 2023 16:46:15\n"
        	            	  },
        	Test:       	TestTransformer_Transform
FAIL
FAIL	github.com/aquasecurity/harbor-scanner-aqua/pkg/scanner	1.225s

after rename scannercli to scannercli111:

$ go clean --testcache
$ go test ./...
?   	github.com/aquasecurity/harbor-scanner-aqua/cmd/scanner-adapter	[no test files]
ok  	github.com/aquasecurity/harbor-scanner-aqua/pkg	0.012s [no tests to run]
ok  	github.com/aquasecurity/harbor-scanner-aqua/pkg/aqua	0.009s
?   	github.com/aquasecurity/harbor-scanner-aqua/pkg/ext	[no test files]
ok  	github.com/aquasecurity/harbor-scanner-aqua/pkg/etc	0.016s
ok  	github.com/aquasecurity/harbor-scanner-aqua/pkg/harbor	0.007s
ok  	github.com/aquasecurity/harbor-scanner-aqua/pkg/http/api	0.012s
?   	github.com/aquasecurity/harbor-scanner-aqua/pkg/job	[no test files]
?   	github.com/aquasecurity/harbor-scanner-aqua/pkg/persistence/redis	[no test files]
?   	github.com/aquasecurity/harbor-scanner-aqua/pkg/persistence	[no test files]
?   	github.com/aquasecurity/harbor-scanner-aqua/pkg/persistence/mock	[no test files]
ok  	github.com/aquasecurity/harbor-scanner-aqua/pkg/http/api/v1	0.021s
ok  	github.com/aquasecurity/harbor-scanner-aqua/pkg/redisx	0.008s
ok  	github.com/aquasecurity/harbor-scanner-aqua/pkg/scanner	0.007s
ok  	github.com/aquasecurity/harbor-scanner-aqua/pkg/work	0.004s [no tests to run]
@afdesk afdesk closed this as completed Oct 3, 2023
@afdesk afdesk reopened this Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant