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

Follow CLI args standards in Falco #3049

Open
incertum opened this issue Feb 1, 2024 · 5 comments
Open

Follow CLI args standards in Falco #3049

incertum opened this issue Feb 1, 2024 · 5 comments
Milestone

Comments

@incertum
Copy link
Contributor

incertum commented Feb 1, 2024

Proposing to follow common and standard Program Argument Syntax Conventions for Falco's CLI options, for example see this resource. For example -pk and similar options seem to fall outside of these conventions.

@incertum incertum changed the title Follow standard CLI args standards in Falco Follow CLI args standards in Falco Feb 1, 2024
@Andreagit97 Andreagit97 added this to the 0.38.0 milestone Feb 1, 2024
@GLVSKiriti
Copy link

@Andreagit97 @incertum I am interested in this issue!
Can I work on this?

@Andreagit97
Copy link
Member

Not clear to me what was the plan @incertum had in mind when she opened this issue, so I'll let her answer here.
My 2 cents, this issue seems related to possible breaking changes in the Falco UX, maybe something that we want to tackle for Falco 1.0.0, not sure this is a "good first issue" but let's see what others think about that

@incertum
Copy link
Contributor Author

Goal is to correct the -pc, -pk or -pcontainer, -pkubernetes flags that do not conform to standard CLI practices. Usually -pc implies a combination of -p and -c.

https://falco.org/docs/outputs/formatting/

("p,print", "Print (or replace) additional information in the rule's output.\nUse -pc or -pcontainer to append container details.\nUse -pk or -pkubernetes to add both container and Kubernetes details.\nIf using gVisor, choose -pcg or -pkg variants (or -pcontainer-gvisor and -pkubernetes-gvisor, respectively).\nIf a rule's output contains %container.info, it will be replaced with the corresponding details. Otherwise, these details will be directly appended to the rule's output.\nAlternatively, use -p <output_format> for a custom format. In this case, the given <output_format> will be appended to the rule's output without any replacement.", cxxopts::value(print_additional), "<output_format>")

I would propose them being:

  • -pc -> --print-container and --print-container-gvisor or similar
  • -pk -> --print-kubernetes and --print-kubernetes-gvisor or similar

Suggesting to sync with @leogr.

@leogr
Copy link
Member

leogr commented Mar 14, 2024

Usually -pc implies a combination of -p and -c.

This is the main issue, likely.

If we follow POSIX's recommendation:

Multiple options may follow a hyphen delimiter in a single token if the options do not take arguments. Thus, ‘-abc’ is equivalent to ‘-a -b -c’.

So, -pc is not ok.

But:

An option and its argument may or may not appear as separate tokens. (In other words, the whitespace separating them is optional.) Thus, -o foo and -ofoo are equivalent.

So -pcontainer is equivalent to -p container and it would be ok (and it is what's happening here).

My recommendation is to reaudit all flags, and try to make them consistent with POSIX.
The cobra project may be a source of inspiration. Also, if we follow Cobra/posix recommendations, we will have consistency across all our other tools (which are implemented in Go).

Let's dig deeper into this once we have found some time.

@incertum
Copy link
Contributor Author

Agreed @leogr let's investigate more. It's something valuable for Falco 1.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants