ApplyOptions applies options and returns the configured Options This automatically appends BaseAllowedHostnames to any user-provided hostnames
(opts ...Option)
| 130 | // ApplyOptions applies options and returns the configured Options |
| 131 | // This automatically appends BaseAllowedHostnames to any user-provided hostnames |
| 132 | func ApplyOptions(opts ...Option) *Options { |
| 133 | options := &Options{ |
| 134 | CommonEngineOptions: &CommonEngineOptions{ |
| 135 | AllowedHostnames: make([]string, 0), |
| 136 | IncludeRawData: false, |
| 137 | EnablePrint: false, |
| 138 | ControlPlaneConnection: nil, |
| 139 | }, |
| 140 | OperatingMode: 0, // Default restrictive mode |
| 141 | ExecutionTimeout: 0, |
| 142 | Logger: nil, |
| 143 | } |
| 144 | |
| 145 | for _, opt := range opts { |
| 146 | opt(options) |
| 147 | } |
| 148 | |
| 149 | // Append base allowed hostnames to user-provided ones |
| 150 | options.AllowedHostnames = append(options.AllowedHostnames, BaseAllowedHostnames...) |
| 151 | |
| 152 | return options |
| 153 | } |
| 154 | |
| 155 | type PolicyEngine interface { |
| 156 | // Verify verifies an input against a policy |