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

✨ easier configuration for the compiler #121

Merged
merged 1 commit into from
Oct 17, 2022
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: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/spf13/pflag v1.0.6-0.20201009195203-85dd5c8bc61c
github.com/spf13/viper v1.13.0
github.com/stretchr/testify v1.8.0
go.mondoo.com/cnquery v0.0.0-20221016203430-4b6d2815157f
go.mondoo.com/cnquery v0.0.0-20221017082813-a5bce55f0560
go.mondoo.com/ranger-rpc v0.5.1-0.20220923135836-9e7732899d34
go.opentelemetry.io/otel v1.11.0
golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1566,8 +1566,8 @@ go.etcd.io/etcd v0.0.0-20200513171258-e048e166ab9c/go.mod h1:xCI7ZzBfRuGgBXyXO6y
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
go.mondoo.com/cnquery v0.0.0-20221016203430-4b6d2815157f h1:1ZIFCJcWuc0w2h/d5n4Gym04PjjD3cp2f9QNBTUi76Q=
go.mondoo.com/cnquery v0.0.0-20221016203430-4b6d2815157f/go.mod h1:E7+94D2X1SMG2Gc7HL5P6FONssPF9i0cXlK9Vr5e+G4=
go.mondoo.com/cnquery v0.0.0-20221017082813-a5bce55f0560 h1:3x5ybu3N0OIJSgjLEfXgo4+dtdH5huRATpZBDFnHJr8=
go.mondoo.com/cnquery v0.0.0-20221017082813-a5bce55f0560/go.mod h1:E7+94D2X1SMG2Gc7HL5P6FONssPF9i0cXlK9Vr5e+G4=
go.mondoo.com/ranger-rpc v0.5.1-0.20220923135836-9e7732899d34 h1:mtPZ1J+nRI/ivV+n41bjIwY6Rfxb2Jf49svZSQMGHIA=
go.mondoo.com/ranger-rpc v0.5.1-0.20220923135836-9e7732899d34/go.mod h1:3YKcqFrlPgaB4FZ4EoLgdmRtwMQdO7RoAkZYFn+F1eY=
go.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o=
Expand Down
2 changes: 1 addition & 1 deletion policy/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (e *Executor) AreAllResultsCollected() bool {

// Compile a given code with the default schema
func (e *Executor) Compile(code string, props map[string]*llx.Primitive) (*llx.CodeBundle, error) {
return mqlc.Compile(code, e.schema, cnquery.Features{byte(cnquery.PiperCode)}, props)
return mqlc.Compile(code, props, mqlc.NewConfig(e.schema, cnquery.DefaultFeatures))
}

func (e *Executor) AddCode(code string, props map[string]*llx.Primitive) (*llx.CodeBundle, error) {
Expand Down
2 changes: 1 addition & 1 deletion policy/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func runTest(t *testing.T, code string, expected map[string]value, callers ...fu
received[res.CodeID]++
})

codeBundle, err := mqlc.Compile(code, resource_pack.Registry.Schema(), cnquery.Features{byte(cnquery.PiperCode)}, nil)
codeBundle, err := mqlc.Compile(code, nil, mqlc.NewConfig(resource_pack.Registry.Schema(), cnquery.DefaultFeatures))
require.NoError(t, err)
executor.AddCodeBundle(codeBundle, nil)

Expand Down
2 changes: 1 addition & 1 deletion policy/executor/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ExecuteFilterQueries(schema *resources.Schema, runtime *resources.Runtime,

builder := internal.NewBuilder()
for _, m := range queries {
codeBundle, err := mqlc.Compile(m.Query, schema, cnquery.Features{}, nil)
codeBundle, err := mqlc.Compile(m.Query, nil, mqlc.NewConfig(schema, cnquery.DefaultFeatures))
if err != nil {
errs = append(errs, err)
continue
Expand Down
2 changes: 1 addition & 1 deletion policy/executor/mustcompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func MustCompile(code string) *llx.CodeBundle {
codeBundle, err := mqlc.Compile(code, info.Registry.Schema(), cnquery.DefaultFeatures, nil)
codeBundle, err := mqlc.Compile(code, nil, mqlc.NewConfig(info.Registry.Schema(), cnquery.DefaultFeatures))
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions policy/mquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ func (m *Mquery) Compile(props map[string]*llx.Primitive) (*llx.CodeBundle, erro

schema := info.Registry.Schema()

v2Code, err := mqlc.Compile(m.Query, schema,
cnquery.Features{byte(cnquery.PiperCode)}, props)
v2Code, err := mqlc.Compile(m.Query, props, mqlc.NewConfig(schema, cnquery.DefaultFeatures))
if err != nil {
return nil, err
}
Expand Down