github.com/aquasecurity/trivy-iac@v0.8.1-0.20240127024015-3d8e412cf0ab/pkg/scanners/terraform/executor/option.go (about) 1 package executor 2 3 import ( 4 "io" 5 6 "github.com/aquasecurity/defsec/pkg/debug" 7 "github.com/aquasecurity/defsec/pkg/framework" 8 "github.com/aquasecurity/defsec/pkg/rego" 9 "github.com/aquasecurity/defsec/pkg/scan" 10 "github.com/aquasecurity/defsec/pkg/state" 11 ) 12 13 type Option func(s *Executor) 14 15 func OptionWithFrameworks(frameworks ...framework.Framework) Option { 16 return func(s *Executor) { 17 s.frameworks = frameworks 18 } 19 } 20 21 func OptionWithAlternativeIDProvider(f func(string) []string) Option { 22 return func(s *Executor) { 23 s.alternativeIDProviderFunc = f 24 } 25 } 26 27 func OptionWithResultsFilter(f func(scan.Results) scan.Results) Option { 28 return func(s *Executor) { 29 s.resultsFilters = append(s.resultsFilters, f) 30 } 31 } 32 33 func OptionWithSeverityOverrides(overrides map[string]string) Option { 34 return func(s *Executor) { 35 s.severityOverrides = overrides 36 } 37 } 38 39 func OptionWithDebugWriter(w io.Writer) Option { 40 return func(s *Executor) { 41 s.debug = debug.New(w, "terraform", "executor") 42 } 43 } 44 45 func OptionNoIgnores() Option { 46 return func(s *Executor) { 47 s.enableIgnores = false 48 } 49 } 50 51 func OptionExcludeRules(ruleIDs []string) Option { 52 return func(s *Executor) { 53 s.excludedRuleIDs = ruleIDs 54 } 55 } 56 57 func OptionExcludeIgnores(ruleIDs []string) Option { 58 return func(s *Executor) { 59 s.excludeIgnoresIDs = ruleIDs 60 } 61 } 62 63 func OptionIncludeRules(ruleIDs []string) Option { 64 return func(s *Executor) { 65 s.includedRuleIDs = ruleIDs 66 } 67 } 68 69 func OptionStopOnErrors(stop bool) Option { 70 return func(s *Executor) { 71 s.ignoreCheckErrors = !stop 72 } 73 } 74 75 func OptionWithWorkspaceName(workspaceName string) Option { 76 return func(s *Executor) { 77 s.workspaceName = workspaceName 78 } 79 } 80 81 func OptionWithSingleThread(single bool) Option { 82 return func(s *Executor) { 83 s.useSingleThread = single 84 } 85 } 86 87 func OptionWithRegoScanner(s *rego.Scanner) Option { 88 return func(e *Executor) { 89 e.regoScanner = s 90 } 91 } 92 93 func OptionWithStateFunc(f ...func(*state.State)) Option { 94 return func(e *Executor) { 95 e.stateFuncs = f 96 } 97 } 98 99 func OptionWithRegoOnly(regoOnly bool) Option { 100 return func(e *Executor) { 101 e.regoOnly = regoOnly 102 } 103 }