add useragent string to output

Signed-off-by: Marcin Kowalski <marcin.kowalski@assecobs.pl>
This commit is contained in:
Marcin Kowalski 2022-01-11 11:38:30 +00:00 committed by poiana
parent 3e9f8c1ef1
commit a94e6de458
2 changed files with 8 additions and 1 deletions

View File

@ -148,6 +148,10 @@ void falco_configuration::init(string conf_filename, list<string> &cmdline_optio
}
http_output.options["url"] = url;
string user_agent;
user_agent = m_config->get_scalar<string>("http_output.user_agent","falcosecurity/falco");
http_output.options["user_agent"] = user_agent;
m_outputs.push_back(http_output);
}

View File

@ -34,11 +34,14 @@ void falco::outputs::output_http::output(const message *msg)
} else {
slist1 = curl_slist_append(slist1, "Content-Type: text/plain");
}
slist1 = curl_slist_append(slist1, m_oc.options["user_agent"].c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1);
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_POSTFIELDSIZE, -1L);
res = curl_easy_perform(curl);
if(res != CURLE_OK)
@ -50,4 +53,4 @@ void falco::outputs::output_http::output(const message *msg)
curl_slist_free_all(slist1);
slist1 = NULL;
}
}
}