mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-10 21:23:41 +00:00
fix(userspace/engine,userspace/falco): set http output contenttype to text/plain when json output is disabled
Signed-off-by: Federico Di Pierro <nierro92@gmail.com> Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
This commit is contained in:
parent
eaccfbe82d
commit
475ed0dbeb
@ -135,7 +135,7 @@ void falco_outputs::add_output(falco::outputs::config oc)
|
|||||||
throw falco_exception("Output not supported: " + oc.name);
|
throw falco_exception("Output not supported: " + oc.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
oo->init(oc, m_buffered, m_hostname);
|
oo->init(oc, m_buffered, m_hostname, m_json_output);
|
||||||
m_outputs.push_back(oo);
|
m_outputs.push_back(oo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,11 +63,12 @@ class abstract_output
|
|||||||
public:
|
public:
|
||||||
virtual ~abstract_output() {}
|
virtual ~abstract_output() {}
|
||||||
|
|
||||||
void init(config oc, bool buffered, std::string hostname)
|
void init(config oc, bool buffered, std::string hostname, bool json_output)
|
||||||
{
|
{
|
||||||
m_oc = oc;
|
m_oc = oc;
|
||||||
m_buffered = buffered;
|
m_buffered = buffered;
|
||||||
m_hostname = hostname;
|
m_hostname = hostname;
|
||||||
|
m_json_output = json_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the output's name as per its configuration.
|
// Return the output's name as per its configuration.
|
||||||
@ -89,6 +90,7 @@ protected:
|
|||||||
config m_oc;
|
config m_oc;
|
||||||
bool m_buffered;
|
bool m_buffered;
|
||||||
std::string m_hostname;
|
std::string m_hostname;
|
||||||
|
bool m_json_output;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace outputs
|
} // namespace outputs
|
||||||
|
@ -28,7 +28,12 @@ void falco::outputs::output_http::output(const message *msg)
|
|||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
if(curl)
|
if(curl)
|
||||||
{
|
{
|
||||||
slist1 = curl_slist_append(slist1, "Content-Type: application/json");
|
if (m_json_output)
|
||||||
|
{
|
||||||
|
slist1 = curl_slist_append(slist1, "Content-Type: application/json");
|
||||||
|
} else {
|
||||||
|
slist1 = curl_slist_append(slist1, "Content-Type: text/plain");
|
||||||
|
}
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1);
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1);
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, m_oc.options["url"].c_str());
|
curl_easy_setopt(curl, CURLOPT_URL, m_oc.options["url"].c_str());
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, msg->msg.c_str());
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, msg->msg.c_str());
|
||||||
|
Loading…
Reference in New Issue
Block a user