-
Notifications
You must be signed in to change notification settings - Fork 876
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
fix: set http output contenttype to text/plain when json output is disabled #1829
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.
Hey @FedeDP
Thank you for this PR! We really need to fix that.
However, we shouldn't pass the formatter to the output channels. Moreover, if I understood correctly, your implementation won't work with internal messages (because they don't get a formatter). See my comment below.
I propose instead to propagate m_json_ouput
to the output channels during init.
userspace/falco/outputs.h
Outdated
@@ -51,6 +51,7 @@ struct message | |||
std::string source; | |||
map<std::string, std::string> fields; | |||
std::set<std::string> tags; | |||
gen_event_formatter::output_format format; |
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.
Could we avoid passing the formatter in the message?
This approach cannot work with internal
messages, that do not have a formatter 👇
falco/userspace/falco/falco_outputs.cpp
Lines 199 to 213 in 226d1fb
void falco_outputs::handle_msg(uint64_t ts, | |
falco_common::priority_type priority, | |
std::string &msg, | |
std::string &rule, | |
std::map<std::string, std::string> &output_fields) | |
{ | |
falco_outputs::ctrl_msg cmsg = {}; | |
cmsg.ts = ts; | |
cmsg.priority = priority; | |
cmsg.source = "internal"; | |
cmsg.rule = rule; | |
cmsg.fields = output_fields; | |
if(m_json_output) | |
{ |
Moreover, the JSON formatting option is a global setting (not a per-message setting) and the message already contains the formatted text. So I believe the formatter does not really belong to the message.
I would rather pass the m_json_output
's value to each output via the init
function 👇
falco/userspace/falco/falco_outputs.cpp
Line 138 in 226d1fb
oo->init(oc, m_buffered, m_hostname); |
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.
Much simpler, you're right! Thanks ;)
… text/plain when json output is disabled Signed-off-by: Federico Di Pierro <nierro92@gmail.com> Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
0132498
to
c08d365
Compare
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.
/approve
LGTM label has been added. Git tree hash: efa6e71a68f1ba9ee93f1fae8d2e682838f0737a
|
/milestone 0.31.0 |
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.
Thanks @FedeDP! ❤️
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP, jasondellaluce, leogr 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 bug
Any specific area of the project related to this PR?
/area engine
What this PR does / why we need it:
The PR sets the http output Content-type header to a more meaningful value (text/plain) when json_output is disabled.
Which issue(s) this PR fixes:
Fixes #1824
Special notes for your reviewer:
Does this PR introduce a user-facing change?: