-
Notifications
You must be signed in to change notification settings - Fork 47
feat(policies): allow gate=false to override org-wide blocking #2777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3f3b4eb
1d98137
6dae9a3
5ed8770
147515a
bb8f055
b2ca7e1
075655e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ modules: | |
| except: | ||
| - EXTENSION_NO_DELETE | ||
| - FIELD_SAME_DEFAULT | ||
| - FIELD_SAME_CARDINALITY | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure we want to disable this globally but instead you coudl add an annotation in your specific case?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that breaking change detection doesn't support inline comment ignores.
Also exceptions are only per file/directory level. Given that we control the gRPC clients/servers that use these messages and that the Also
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, unfortunately |
||
| - path: app/controlplane/internal/conf | ||
| lint: | ||
| use: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,7 @@ type PolicyVerifier struct { | |
| client v13.AttestationServiceClient | ||
| grpcConn *grpc.ClientConn | ||
| allowedHostnames []string | ||
| defaultGate bool | ||
| includeRawData bool | ||
| enablePrint bool | ||
| evalPhase EvalPhase | ||
|
|
@@ -87,6 +88,7 @@ var _ Verifier = (*PolicyVerifier)(nil) | |
|
|
||
| type PolicyVerifierOptions struct { | ||
| AllowedHostnames []string | ||
| DefaultGate bool | ||
| IncludeRawData bool | ||
| EnablePrint bool | ||
| GRPCConn *grpc.ClientConn | ||
|
|
@@ -101,6 +103,12 @@ func WithAllowedHostnames(hostnames ...string) PolicyVerifierOption { | |
| } | ||
| } | ||
|
|
||
| func WithDefaultGate(defaultGate bool) PolicyVerifierOption { | ||
| return func(o *PolicyVerifierOptions) { | ||
| o.DefaultGate = defaultGate | ||
| } | ||
| } | ||
|
|
||
| func WithIncludeRawData(include bool) PolicyVerifierOption { | ||
| return func(o *PolicyVerifierOptions) { | ||
| o.IncludeRawData = include | ||
|
|
@@ -137,6 +145,7 @@ func NewPolicyVerifier(policies *v1.Policies, client v13.AttestationServiceClien | |
| logger: logger, | ||
| grpcConn: options.GRPCConn, | ||
| allowedHostnames: options.AllowedHostnames, | ||
| defaultGate: options.DefaultGate, | ||
| includeRawData: options.IncludeRawData, | ||
| enablePrint: options.EnablePrint, | ||
| evalPhase: options.EvalPhase, | ||
|
|
@@ -336,10 +345,22 @@ func (pv *PolicyVerifier) evaluatePolicyAttachment(ctx context.Context, attachme | |
| SkipReasons: reasons, | ||
| Requirements: attachment.Requirements, | ||
| RawResults: engineRawResultsToAPIRawResults(rawResults), | ||
| Gate: attachment.GetGate(), | ||
| Gate: policyAttachmentGate(attachment, pv.defaultGate), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, so before the default gate was outside the context of policy verifier and now you are bringing both in?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, The efective gate is now resolved inside
|
||
| }, nil | ||
| } | ||
|
|
||
| func policyAttachmentGate(attachment *v1.PolicyAttachment, defaultGate bool) bool { | ||
| if attachment == nil { | ||
| return defaultGate | ||
| } | ||
|
|
||
| if attachment.Gate != nil { | ||
| return attachment.GetGate() | ||
| } | ||
|
|
||
| return defaultGate | ||
| } | ||
|
|
||
| // ComputeArguments takes a list of arguments, and matches it against the expected inputs. It also applies a set of interpolations if needed. | ||
| func ComputeArguments(name string, inputs []*v1.PolicyInput, args map[string]string, bindings map[string]string, logger *zerolog.Logger) (map[string]string, error) { | ||
| result := make(map[string]string) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.