Skip to content

Commit

Permalink
add useragent string to output
Browse files Browse the repository at this point in the history
Signed-off-by: Marcin Kowalski <marcin.kowalski@assecobs.pl>
  • Loading branch information
Marcin Kowalski committed Jan 12, 2022
1 parent 48a2312 commit 14d11b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions userspace/falco/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
5 changes: 4 additions & 1 deletion userspace/falco/outputs_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -50,4 +53,4 @@ void falco::outputs::output_http::output(const message *msg)
curl_slist_free_all(slist1);
slist1 = NULL;
}
}
}

0 comments on commit 14d11b9

Please sign in to comment.