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