Skip to content
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

Improve -pk as needed by latest "Style Guide of Falco Rules" #2699

Closed
leogr opened this issue Jul 27, 2023 · 1 comment · Fixed by #2737
Closed

Improve -pk as needed by latest "Style Guide of Falco Rules" #2699

leogr opened this issue Jul 27, 2023 · 1 comment · Fixed by #2737
Assignees
Milestone

Comments

@leogr
Copy link
Member

leogr commented Jul 27, 2023

Motivation

See falcosecurity/falco-website#1094 (review).

Feature

Change the -p behavior as follow:

  • when only -pc 👉 container_id=%container.id container_image=%container.image.repository container_image_tag=%container.image.tag container_name=%container.name
  • when -pk 👉 as above plus k8s_ns=%k8s.ns.name k8s_pod_name=%k8s.pod.name

Alternatives

🤔

Additional context

cc @falcosecurity/falco-maintainers

See falcosecurity/falco-website#1094

void configure_output_format(falco::app::state& s)
{
std::string output_format;
bool replace_container_info = false;
if(s.options.print_additional == "c" || s.options.print_additional == "container")
{
output_format = "container=%container.name (id=%container.id)";
replace_container_info = true;
}
else if(s.options.print_additional == "cg" || s.options.print_additional == "container-gvisor")
{
output_format = "container=%container.name (id=%container.id) vpid=%proc.vpid vtid=%thread.vtid";
replace_container_info = true;
}
else if(s.options.print_additional == "k" || s.options.print_additional == "kubernetes")
{
output_format = "k8s.ns=%k8s.ns.name k8s.pod=%k8s.pod.name container=%container.id";
replace_container_info = true;
}
else if(s.options.print_additional == "kg" || s.options.print_additional == "kubernetes-gvisor")
{
output_format = "k8s.ns=%k8s.ns.name k8s.pod=%k8s.pod.name container=%container.id vpid=%proc.vpid vtid=%thread.vtid";
replace_container_info = true;
}
else if(!s.options.print_additional.empty())
{
output_format = s.options.print_additional;
replace_container_info = false;
}
if(!output_format.empty())
{
s.engine->set_extra(output_format, replace_container_info);
}
}

static void apply_output_substitutions(
rule_loader::configuration& cfg,
std::string& out)
{
if (out.find(s_container_info_fmt) != std::string::npos)
{
if (cfg.replace_output_container_info)
{
out = replace(out, s_container_info_fmt, cfg.output_extra);
return;
}
out = replace(out, s_container_info_fmt, s_default_extra_fmt);
}
out += cfg.output_extra.empty() ? "" : " " + cfg.output_extra;
}

@leogr leogr added this to the 0.36.0 milestone Jul 27, 2023
@leogr leogr self-assigned this Jul 27, 2023
@incertum
Copy link
Contributor

This is great, thank you!

@leogr leogr moved this from Todo to In progress in Falco Roadmap Aug 22, 2023
@github-project-automation github-project-automation bot moved this from In progress to Done in Falco Roadmap Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants