github.com/devseccon/trivy@v0.47.1-0.20231123133102-bd902a0bd996/pkg/types/target.go (about) 1 package types 2 3 import ( 4 "golang.org/x/exp/slices" 5 ) 6 7 // VulnType represents vulnerability type 8 type VulnType = string 9 10 // Scanner represents the type of security scanning 11 type Scanner string 12 13 // Scanners is a slice of scanners 14 type Scanners []Scanner 15 16 const ( 17 // VulnTypeUnknown is a vulnerability type of unknown 18 VulnTypeUnknown = VulnType("unknown") 19 20 // VulnTypeOS is a vulnerability type of OS packages 21 VulnTypeOS = VulnType("os") 22 23 // VulnTypeLibrary is a vulnerability type of programming language dependencies 24 VulnTypeLibrary = VulnType("library") 25 26 // UnknownScanner is the scanner of unknown 27 UnknownScanner = Scanner("unknown") 28 29 // NoneScanner is the scanner of none 30 NoneScanner = Scanner("none") 31 32 // VulnerabilityScanner is the scanner of vulnerabilities 33 VulnerabilityScanner = Scanner("vuln") 34 35 // MisconfigScanner is the scanner of misconfigurations 36 MisconfigScanner = Scanner("misconfig") 37 38 // SecretScanner is the scanner of secrets 39 SecretScanner = Scanner("secret") 40 41 // RBACScanner is the scanner of rbac assessment 42 RBACScanner = Scanner("rbac") 43 44 // LicenseScanner is the scanner of licenses 45 LicenseScanner = Scanner("license") 46 ) 47 48 var ( 49 VulnTypes = []string{ 50 VulnTypeOS, 51 VulnTypeLibrary, 52 } 53 54 AllScanners = Scanners{ 55 VulnerabilityScanner, 56 MisconfigScanner, 57 RBACScanner, 58 SecretScanner, 59 LicenseScanner, 60 NoneScanner, 61 } 62 63 // AllImageConfigScanners has a list of available scanners on container image config. 64 // The container image in container registries consists of manifest, config and layers. 65 // Trivy is also able to detect security issues on the image config. 66 AllImageConfigScanners = Scanners{ 67 MisconfigScanner, 68 SecretScanner, 69 NoneScanner, 70 } 71 ) 72 73 func (scanners Scanners) Enabled(s Scanner) bool { 74 return slices.Contains(scanners, s) 75 } 76 77 // AnyEnabled returns true if any of the passed scanners is included. 78 func (scanners Scanners) AnyEnabled(ss ...Scanner) bool { 79 for _, s := range ss { 80 if scanners.Enabled(s) { 81 return true 82 } 83 } 84 return false 85 }