-
Notifications
You must be signed in to change notification settings - Fork 26
Make properties work properly #5795
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing update!! woooooot 🎉
nitpick 1
go run ./apps/cnquery scan -f packprops.mql.yaml --json --props userHome='return "foo"' | jq .
followed by the example output, where we can see that the default prop from the policy is being applied. Is the command not matching the output perhaps? (it look slike the command would override it with foo, just like in the example below)
nitpick 2
any reason to include variant-check
in the last example?
I've fixed the comment for nitpick 1. I copied over the wrong command, it should not have any props in the CLI command.
|
- Props are now namespaced to either a pack or query - Props on packs need to reference props through `for` - We will automatically make the `for` references if a pack does not define any props but includes queries with props Examples: ```yaml packs: - uid: example1 name: Example policy 1 version: "1.0.0" authors: - name: Mondoo email: hello@mondoo.com groups: - title: group1 filters: return true queries: - uid: variant-1 - uid: variant-2 - uid: variant-3 - uid: variant-4 props: - uid: userHome for: - uid: home - uid: homeDir mql: return "ex" queries: - uid: variant-check title: Variant check variants: - uid: variant-1 - uid: variant-2 - uid: variant-3 - uid: variant-1 mql: props.home + " on 1" props: - uid: home mql: return "p1" - uid: variant-2 mql: props.home + " on 2" props: - uid: home mql: return "p2" - uid: variant-3 mql: props.homeDir + " on 3" props: - uid: homeDir mql: return "p3" - uid: variant-4 mql: props.user + " is the user" props: - uid: user mql: return "ada" ``` ``` go run ./apps/cnquery scan -f packprops.mql.yaml --json --props userHome='return "foo"' | jq . ``` ```json { "assets": { "//explorer.api.mondoo.com/assets/309tMfGA9ieUOgzgBdSMBNSEl6t": { "mrn": "//explorer.api.mondoo.com/assets/309tMfGA9ieUOgzgBdSMBNSEl6t", "name": "planetexpress" } }, "data": { "//explorer.api.mondoo.com/assets/309tMfGA9ieUOgzgBdSMBNSEl6t": { "values": { "FCEF4O8XoOs=": { "content": { "user.+": "ada is the user" } }, "JvBACGPwF6o=": { "content": {} }, "NsipGp24tRk=": { "content": { "home.+": "ex on 1" } }, "OU6YpdHiWPQ=": { "content": { "home.+": "ex on 2" } }, "V/uj0v1oehI=": { "content": {} }, "yNnJGUyTSts=": { "content": { "homeDir.+": "ex on 3" } } } } } } ``` ``` go run ./apps/cnquery scan -f ~/Downloads/packprops.mql.yaml --json --props userHome="return 'foo'" | jq . ``` ```json { "assets": { "//explorer.api.mondoo.com/assets/309tWggTTzYD0E1FDi20NmN4Bh2": { "mrn": "//explorer.api.mondoo.com/assets/309tWggTTzYD0E1FDi20NmN4Bh2", "name": "planetexpress" } }, "data": { "//explorer.api.mondoo.com/assets/309tWggTTzYD0E1FDi20NmN4Bh2": { "values": { "FCEF4O8XoOs=": { "content": { "user.+": "ada is the user" } }, "JvBACGPwF6o=": { "content": {} }, "NsipGp24tRk=": { "content": { "home.+": "foo on 1" } }, "OAKBq9so/78=": { "content": {} }, "OU6YpdHiWPQ=": { "content": { "home.+": "foo on 2" } }, "yNnJGUyTSts=": { "content": { "homeDir.+": "foo on 3" } } } } } } ``` ``` packs: - uid: example1 name: Example policy 1 version: "1.0.0" authors: - name: Mondoo email: hello@mondoo.com groups: - title: group1 filters: return true queries: - uid: variant-1 - uid: variant-2 - uid: variant-3 - uid: variant-4 queries: - uid: variant-check title: Variant check variants: - uid: variant-1 - uid: variant-2 - uid: variant-3 - uid: variant-1 mql: props.home + " on 1" props: - uid: home mql: return "p1" - uid: variant-2 mql: props.home + " on 2" props: - uid: home mql: return "p2" - uid: variant-3 mql: props.homeDir + " on 3" props: - uid: homeDir mql: return "p3" - uid: variant-4 mql: props.user + " is the user" props: - uid: user mql: return "ada" ``` ``` go run ./apps/cnquery scan -f ~/Downloads/packprops.mql.yaml --json --props home="return 'foo'" | jq . ``` ``` { "assets": { "//explorer.api.mondoo.com/assets/309tniQ7vAYnVTMznDD7A94kqEV": { "mrn": "//explorer.api.mondoo.com/assets/309tniQ7vAYnVTMznDD7A94kqEV", "name": "planetexpress" } }, "data": { "//explorer.api.mondoo.com/assets/309tniQ7vAYnVTMznDD7A94kqEV": { "values": { "FCEF4O8XoOs=": { "content": { "user.+": "ada is the user" } }, "JvBACGPwF6o=": { "content": {} }, "NsipGp24tRk=": { "content": { "home.+": "foo on 1" } }, "OAKBq9so/78=": { "content": {} }, "OU6YpdHiWPQ=": { "content": { "home.+": "foo on 2" } }, "SHIUM1ACvIk=": { "content": {} }, "yNnJGUyTSts=": { "content": { "homeDir.+": "p3 on 3" } } } } } } ```
DO NOT MERGE
for
for
references if a pack doesnot define any props but includes queries with props
Examples: