Skip to content
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

Rewrite policy resolver #1465

Merged
merged 18 commits into from
Nov 15, 2024
2 changes: 1 addition & 1 deletion internal/datalakes/inmemory/policyhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func (db *Db) entityGraphExecutionChecksum(ctx context.Context, mrn string) (str
}
}

return policy.BundleExecutionChecksum(policyObj, framework), nil
return policy.BundleExecutionChecksum(ctx, policyObj, framework), nil
}

// EntityGraphContentChecksum retrieves the content checksum for a given entity.
Expand Down
8 changes: 6 additions & 2 deletions policy/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (l *BundleLoader) BundleFromPaths(paths ...string) (*Bundle, error) {

// BundleExecutionChecksum creates a combined execution checksum from a policy
// and framework. Either may be nil.
func BundleExecutionChecksum(policy *Policy, framework *Framework) string {
func BundleExecutionChecksum(ctx context.Context, policy *Policy, framework *Framework) string {
res := checksums.New
if policy != nil {
res = res.Add(policy.GraphExecutionChecksum)
Expand All @@ -102,7 +102,11 @@ func BundleExecutionChecksum(policy *Policy, framework *Framework) string {
// So far the checksum only includes the policy and the framework
// It does not change if any of the jobs changes, only if the policy or the framework changes
// To update the resolved policy, when we change how it is generated, change the incoporated version of the resolver
res = res.Add(RESOLVER_VERSION)
if IsNextGenResolver(ctx) {
res = res.Add(RESOLVER_VERSION_NG)
} else {
res = res.Add(RESOLVER_VERSION)
}

return res.String()
}
Expand Down
27 changes: 15 additions & 12 deletions policy/cnspec_policy.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions policy/cnspec_policy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,16 @@ message ReportingJob {

enum Type {
UNSPECIFIED = 0;
CHECK = 1;
DATA_QUERY = 2;
CONTROL = 3;
POLICY = 4;
FRAMEWORK = 5;
RISK_FACTOR = 6;

// DO NOT USE CHECK OR DATA_QUERY, THEY ARE DEPRECATED
czunker marked this conversation as resolved.
Show resolved Hide resolved
// Here's the reason why:
// A query can be either or both. We cannot pick one in all cases
CHECK = 1;
DATA_QUERY = 2;
}

string checksum = 1;
Expand Down
Loading
Loading