| 13 | ) |
| 14 | |
| 15 | func TestWriter_Write(t *testing.T) { |
| 16 | testCases := []struct { |
| 17 | name string |
| 18 | scanners types.Scanners |
| 19 | tableModes []types.TableMode |
| 20 | results types.Results |
| 21 | wantOutput string |
| 22 | includeNonFailures bool |
| 23 | }{ |
| 24 | { |
| 25 | name: "vulnerability and custom resource", |
| 26 | scanners: types.Scanners{ |
| 27 | types.VulnerabilityScanner, |
| 28 | }, |
| 29 | tableModes: types.SupportedTableModes, |
| 30 | results: types.Results{ |
| 31 | { |
| 32 | Target: "test", |
| 33 | Type: ftypes.Jar, |
| 34 | Class: types.ClassLangPkg, |
| 35 | Packages: []ftypes.Package{ |
| 36 | { |
| 37 | Name: "foo", |
| 38 | Version: "1.2.3", |
| 39 | FilePath: "test.jar", |
| 40 | }, |
| 41 | }, |
| 42 | Vulnerabilities: []types.DetectedVulnerability{ |
| 43 | { |
| 44 | VulnerabilityID: "CVE-2020-0001", |
| 45 | PkgName: "foo", |
| 46 | InstalledVersion: "1.2.3", |
| 47 | PrimaryURL: "https://avd.aquasec.com/nvd/cve-2020-0001", |
| 48 | Status: dbTypes.StatusWillNotFix, |
| 49 | PkgPath: "test.jar", |
| 50 | Vulnerability: dbTypes.Vulnerability{ |
| 51 | Title: "foobar", |
| 52 | Description: "baz", |
| 53 | Severity: "HIGH", |
| 54 | }, |
| 55 | }, |
| 56 | }, |
| 57 | CustomResources: []ftypes.CustomResource{ |
| 58 | { |
| 59 | Type: "test", |
| 60 | Data: "test", |
| 61 | }, |
| 62 | }, |
| 63 | }, |
| 64 | }, |
| 65 | wantOutput: ` |
| 66 | Report Summary |
| 67 | |
| 68 | ┌──────────┬──────┬─────────────────┐ |
| 69 | │ Target │ Type │ Vulnerabilities │ |
| 70 | ├──────────┼──────┼─────────────────┤ |
| 71 | │ test.jar │ jar │ 1 │ |
| 72 | └──────────┴──────┴─────────────────┘ |