-
Notifications
You must be signed in to change notification settings - Fork 912
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
update(outputs): add configuration option for tags in json outputs #1733
update(outputs): add configuration option for tags in json outputs #1733
Conversation
Signed-off-by: Jason Dellaluce <[email protected]>
Signed-off-by: Jason Dellaluce <[email protected]>
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.
LGTM.
Great improvement 👍
json_output_no_tags_property: | ||
json_output: True | ||
json_include_tags_property: False | ||
detect: True | ||
detect_level: WARNING | ||
rules_file: | ||
- rules/rule_append.yaml | ||
trace_file: trace_files/cat_write.scap | ||
stdout_contains: "^(?!.*\"tags\":[ ]*\\[.*\\],.*)" | ||
|
||
json_output_empty_tags_property: | ||
json_output: True | ||
detect: True | ||
detect_level: WARNING | ||
rules_file: | ||
- rules/rule_append.yaml | ||
trace_file: trace_files/cat_write.scap | ||
stdout_contains: "^(.*\"tags\":[ ]*\\[\\],.*)" | ||
|
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.
👍
LGTM label has been added. Git tree hash: 42163e871e0526a78dcab56258b75f3182c27bbf
|
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.
Thank you Jason for implementing my feedback. 🤗
/LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jasondellaluce, leodido The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind cleanup
/kind feature
Any specific area of the project related to this PR?
/area engine
/area tests
What this PR does / why we need it:
Since the recent merge of #1714,
tags
andsource
fields are now part of both the grpc and json outputs. However, the semantic of the json output is not clear in some corner cases, such as when no tags are defined in a rule. Also, users can't configure whether to includetags
in the json outputs or not, which instead is possible for theoutput
field. Moreover, no test cases are yet present for asserting the expected outcome of these corner cases. These issues were reported in #1714 (comment) by @leodido (thank you!!)As such, this PR contributes with the following:
json_include_tags_property
configuration option, so that users can decide whether to includetags
in the json outputs or not. By default this is set totrue
to not introduce breaking changes for clients that currently expect the field to be present.Additional Context:
The table below describes the expected outcomes in the json outputs by using the new configuration option.
json_include_tags_property = true
json_include_tags_property = false
tags=[]
tags
fieldtags=[...]
tags
fieldThese cases are covered by the following tests:
json_output_empty_tags_property
: Case (1)json_output_no_tags_property
: Cases (2) and (4)stdout_output_json_strict
: Case (3)Does this PR introduce a user-facing change?: