-
Notifications
You must be signed in to change notification settings - Fork 7
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
APP-15731 - Support rule labels #219
Conversation
Note to self: tag before merge |
transfer_encoding: [] | ||
trailer: {} | ||
host: graphql.us.jupiterone.io | ||
remote_addr: "" | ||
request_uri: "" | ||
body: '{"query":"\nmutation CreateInlineQuestionRuleInstance ($instance: CreateInlineQuestionRuleInstanceInput!) {\n\tcreateQuestionRuleInstance: createInlineQuestionRuleInstance(instance: $instance) {\n\t\tid\n\t\tversion\n\t\tspecVersion\n\t\tquestion {\n\t\t\tqueries {\n\t\t\t\tname\n\t\t\t\tquery\n\t\t\t\tversion\n\t\t\t\tincludeDeleted\n\t\t\t}\n\t\t}\n\t\toperations {\n\t\t\twhen\n\t\t\tactions\n\t\t}\n\t}\n}\n","variables":{"instance":{"question":{"queries":[{"query":"Find DataStore with classification=(''critical'' or ''sensitive'' or ''confidential'' or ''restricted'') and encrypted!=true","name":"query0","version":"v1","includeDeleted":false}]},"templates":null,"tags":["tf_acc:1","tf_acc:2"],"name":"tf-provider-test-rule","description":"test","specVersion":1,"operations":[],"outputs":["queries.query0.total","alertLevel"],"pollingInterval":"ONE_DAY","notifyOnFailure":false,"triggerActionsOnNewEntitiesOnly":false,"ignorePreviousResults":false,"remediationSteps":"","j1Internal":false}},"operationName":"CreateInlineQuestionRuleInstance"}' | ||
body: '{"query":"\nmutation CreateInlineQuestionRuleInstance ($instance: CreateInlineQuestionRuleInstanceInput!) {\n\tcreateQuestionRuleInstance: createInlineQuestionRuleInstance(instance: $instance) {\n\t\tid\n\t\tversion\n\t\tspecVersion\n\t\tquestion {\n\t\t\tqueries {\n\t\t\t\tname\n\t\t\t\tquery\n\t\t\t\tversion\n\t\t\t\tincludeDeleted\n\t\t\t}\n\t\t}\n\t\toperations {\n\t\t\twhen\n\t\t\tactions\n\t\t}\n\t\tlabels {\n\t\t\tlabelName\n\t\t\tlabelValue\n\t\t}\n\t}\n}\n","variables":{"instance":{"question":{"queries":[{"query":"Find DataStore with classification=(''critical'' or ''sensitive'' or ''confidential'' or ''restricted'') and encrypted!=true","name":"query0","version":"v1","includeDeleted":false}]},"templates":null,"tags":["tf_acc:1","tf_acc:2"],"name":"tf-provider-test-rule","description":"test","specVersion":1,"operations":[],"outputs":["queries.query0.total","alertLevel"],"pollingInterval":"ONE_DAY","notifyOnFailure":false,"triggerActionsOnNewEntitiesOnly":false,"ignorePreviousResults":false,"remediationSteps":"","collectionId":"","labels":null,"j1Internal":false}},"operationName":"CreateInlineQuestionRuleInstance"}' |
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.
I think you can use a pipe for multi-line blocks in yaml to make this more readable
{
"query": "\nmutation CreateInlineQuestionRuleInstance ($instance: CreateInlineQuestionRuleInstanceInput!) {\n createQuestionRuleInstance: createInlineQuestionRuleInstance(instance: $instance) {\n id\n version\n specVersion\n question {\n queries {\n name\n query\n version\n includeDeleted\n }\n }\n operations {\n when\n actions\n }\n labels {\n labelName\n labelValue\n }\n }\n}\n",
"variables": {
"instance": {
"question": {
"queries": [
{
"query": "Find DataStore with classification=('critical' or 'sensitive' or 'confidential' or 'restricted') and encrypted!=true",
"name": "query0",
"version": "v1",
"includeDeleted": false
}
]
},
"templates": null,
"tags": ["tf_acc:1", "tf_acc:2"],
"name": "tf-provider-test-rule",
"description": "test",
"specVersion": 1,
"operations": [],
"outputs": ["queries.query0.total", "alertLevel"],
"pollingInterval": "ONE_DAY",
"notifyOnFailure": false,
"triggerActionsOnNewEntitiesOnly": false,
"ignorePreviousResults": false,
"remediationSteps": "",
"collectionId": "",
"labels": null,
"j1Internal": false
}
},
"operationName": "CreateInlineQuestionRuleInstance"
}
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.
This is generated!
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.
Ahhh okeee
for i, label := range r.Labels { | ||
labels[i] = client.RuleInstanceLabelInput{ | ||
LabelName: label.LabelName.ValueString(), | ||
LabelValue: label.LabelValue.ValueString(), |
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.
Will this incorrectly convert things to a string if they are an int or a bool?
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.
We will only support strings in the terraform and do parsing if needed on the rule-service side. Terraform will actually throw an error if it receives anything but a string
for i, label := range r.Labels { | ||
labels[i] = client.RuleInstanceLabelInput{ | ||
LabelName: label.LabelName.ValueString(), | ||
LabelValue: label.LabelValue.ValueString(), |
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.
How does this handle empty string?
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.
We are using a "Primitive" gql type for the value of labelValue - this gets translated to a type of string when the client is generated. Users will use strings for the values and rule-service will parse them into their respective primitive types if needed (PR: https://github.com/JupiterOne/rule-service/pull/556).
Note: I am not adding labels to the questionRuleInstance query because the primitive label values will be returned not as strings and terraform loses its mind.