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

new(falco): add append_output configuration option with fields and format #3308

Merged
merged 7 commits into from
Sep 9, 2024

Conversation

LucaGuerra
Copy link
Contributor

@LucaGuerra LucaGuerra commented Aug 28, 2024

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind feature

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area engine

What this PR does / why we need it:

This addresses the need for a configuration option that allows to specify:

  1. Additional output at the end of the regular message
  2. Additional output fields, only visible in the json message, which can contain any custom message including formatted fields. Supports outputting strings with format and environment variables.

This is how it works

append_output:
  - source: syscall
    tag: persistence
    rule: some rule name
    format: "gparent=%proc.aname[2] ggparent=%proc.aname[3] gggparent=%proc.aname[4]"

  - source: k8s_audit
    fields: 
      - ka.verb
      - home_directory: "${HOME}"
      - my_field: "this is event number %evt.num"
    format: "with response code %ka.response.code"

Which issue(s) this PR fixes:

Fixes #3235

Special notes for your reviewer:

As a bonus, this gets rid of JsonCpp in Falco.

Does this PR introduce a user-facing change?:

new(falco): introduce append_output configuration

Copy link

This PR may bring feature or behavior changes in the Falco engine and may require the engine version to be bumped.

Please double check userspace/engine/falco_engine_version.h file. See versioning for FALCO_ENGINE_VERSION.

/hold

@LucaGuerra
Copy link
Contributor Author

/milestone 0.39.0

@poiana poiana added this to the 0.39.0 milestone Aug 28, 2024
@LucaGuerra
Copy link
Contributor Author

LucaGuerra commented Aug 28, 2024

The structure and functionality is there and can be reviewed, I need to figure out how to properly add this to the json schema, make sure integration tests pass and add an explanation to falco.yaml

@FedeDP
Copy link
Contributor

FedeDP commented Aug 29, 2024

/cc @incertum

@poiana poiana requested a review from incertum August 29, 2024 06:36
@LucaGuerra LucaGuerra force-pushed the new/append_output_config branch from 462c5f9 to db8b078 Compare August 29, 2024 16:54
@LucaGuerra
Copy link
Contributor Author

LucaGuerra commented Aug 29, 2024

I have updated the PR:

  • Fields specified like - ka.verb (i.e. single Falco field) are now supported. They will show up with their original type instead of being cast to string
  • The json schema should be updated to reflect these changes
  • There is an explanation in falco.yaml about how to use this feature

@LucaGuerra LucaGuerra force-pushed the new/append_output_config branch from db8b078 to 0a65d01 Compare August 29, 2024 17:02
@LucaGuerra LucaGuerra changed the title wip: new(falco): add append_output configuration option with fields and format new(falco): add append_output configuration option with fields and format Aug 29, 2024
@LucaGuerra
Copy link
Contributor Author

This fixes the falcosecurity/testing failure: falcosecurity/testing#61

@LucaGuerra LucaGuerra force-pushed the new/append_output_config branch 2 times, most recently from 700a492 to 7fc21ec Compare August 30, 2024 13:20
falco.yaml Show resolved Hide resolved
@LucaGuerra LucaGuerra force-pushed the new/append_output_config branch from 7b41d6d to c481491 Compare September 6, 2024 16:42
@LucaGuerra
Copy link
Contributor Author

Addressed @FedeDP 's comment, updated the json schema and also added a test for CLI options since the -o PR was merged in the meantime

Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@poiana
Copy link
Contributor

poiana commented Sep 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP, LucaGuerra

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana
Copy link
Contributor

poiana commented Sep 9, 2024

LGTM label has been added.

Git tree hash: 04ed804283cb84988ae80420bf2bd60f16d1f84b

@leogr
Copy link
Member

leogr commented Sep 9, 2024

This PR may bring feature or behavior changes in the Falco engine and may require the engine version to be bumped.

Please double check userspace/engine/falco_engine_version.h file. See versioning for FALCO_ENGINE_VERSION.

/hold

false positive
/unhold

Copy link
Member

@leogr leogr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits

# If none of the above are specified output is appended to all events, if more than one is
# specified output will be appended to events that match all conditions.
# And several options to add output:
# `format`: add output to the Falco message
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# `format`: add output to the Falco message
# `format`: format the given string and append it to the Falco output message

@poiana poiana merged commit df072da into falcosecurity:master Sep 9, 2024
35 checks passed
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 this pull request may close these issues.

[proposal/discussion] specify Falco additional outputs in the configuration file
4 participants