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

✨ support querypack execution #944

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/cnspec/cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ func (c *scanConfig) loadPolicies() error {
return err
}

bundle.ConvertQuerypacks()

_, err = bundle.CompileExt(context.Background(), policy.BundleCompileConf{
Schema: c.runtime.Schema(),
// We don't care about failing queries for local runs. We may only
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ go 1.21

toolchain go1.21.3

require go.mondoo.com/cnquery/v9 v9.6.1
require go.mondoo.com/cnquery/v9 v9.6.2-0.20231109164815-e81f9d5724ee

require (
github.com/Masterminds/semver v1.5.0
Expand Down
10 changes: 2 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -939,14 +939,8 @@ go-simpler.org/assert v0.6.0 h1:QxSrXa4oRuo/1eHMXSBFHKvJIpWABayzKldqZyugG7E=
go-simpler.org/assert v0.6.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28=
go-simpler.org/sloglint v0.2.0 h1:XpOhA+7BCQJnl7KlDLmnFUFTSrl989ZmaVPSWWCWEtc=
go-simpler.org/sloglint v0.2.0/go.mod h1:/RQr0TeTf89IyRjLJ9ogUbIp1Zs5zJJAj02pwQoDQdg=
go.mondoo.com/cnquery/v9 v9.5.2 h1:zoe5JM288rET0ZOT8bwTR9h87w94qLf7q8NwAsYm12U=
go.mondoo.com/cnquery/v9 v9.5.2/go.mod h1:msoStMJwKnXJsBuA13ecw7jppR2SjmAaDCH7Lnd1u/w=
go.mondoo.com/cnquery/v9 v9.5.3 h1:qS3msdIXJ5417bcqgpgklYZJ3J9dpZWv5Zrq0M4nXDk=
go.mondoo.com/cnquery/v9 v9.5.3/go.mod h1:msoStMJwKnXJsBuA13ecw7jppR2SjmAaDCH7Lnd1u/w=
go.mondoo.com/cnquery/v9 v9.6.0 h1:X6sodwk/92GlXScPJwWwDLgLn2RAPv/DAJQVb4KtAmE=
go.mondoo.com/cnquery/v9 v9.6.0/go.mod h1:msoStMJwKnXJsBuA13ecw7jppR2SjmAaDCH7Lnd1u/w=
go.mondoo.com/cnquery/v9 v9.6.1 h1:1LXig8dvPXxYvVgny3QJibU5ZXgAzS5j1cADEIffLBQ=
go.mondoo.com/cnquery/v9 v9.6.1/go.mod h1:msoStMJwKnXJsBuA13ecw7jppR2SjmAaDCH7Lnd1u/w=
go.mondoo.com/cnquery/v9 v9.6.2-0.20231109164815-e81f9d5724ee h1:vTnq9XlzPhXin/OcdUWe7y2qKKa9ZRa6J5c3xk3/YOk=
go.mondoo.com/cnquery/v9 v9.6.2-0.20231109164815-e81f9d5724ee/go.mod h1:msoStMJwKnXJsBuA13ecw7jppR2SjmAaDCH7Lnd1u/w=
go.mondoo.com/ranger-rpc v0.5.2 h1:UrcVtMIinzfWsuSzZKibbMqcGZSARInKJi0Xs2AxXeU=
go.mondoo.com/ranger-rpc v0.5.2/go.mod h1:y5qqdFhOnSLKnAo8lXC0FKZoKLUYgLENvneww+q+7ws=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down
6 changes: 6 additions & 0 deletions policy/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ func aggregateBundles(a *Bundle, b *Bundle) *Bundle {

// merge in a
res.Policies = append(res.Policies, a.Policies...)
res.Packs = append(res.Packs, a.Packs...)
res.Props = append(res.Props, a.Props...)
res.Queries = append(res.Queries, a.Queries...)
res.Frameworks = append(res.Frameworks, a.Frameworks...)
res.FrameworkMaps = append(res.FrameworkMaps, a.FrameworkMaps...)

// merge in b
res.Policies = append(res.Policies, b.Policies...)
res.Packs = append(res.Packs, b.Packs...)
res.Props = append(res.Props, b.Props...)
res.Queries = append(res.Queries, b.Queries...)
res.Frameworks = append(res.Frameworks, b.Frameworks...)
Expand All @@ -181,6 +183,10 @@ func (p *Bundle) ConvertQuerypacks() {
for i := range p.Packs {
pack := p.Packs[i]

// Remove this once we reach v10 vv
pack.DeprecatedV9_ensureUIDs()
// ^^

policy := Policy{
Mrn: pack.Mrn,
Uid: pack.Uid,
Expand Down