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

refactor!: remove K8S audit logs from Falco #1952

Merged
merged 7 commits into from
Apr 29, 2022
Merged

Conversation

jasondellaluce
Copy link
Contributor

@jasondellaluce jasondellaluce commented Mar 22, 2022

What type of PR is this?

/kind cleanup

/kind design

Any specific area of the project related to this PR?

/area build

/area engine

What this PR does / why we need it:

This is part of the ongoing effort of porting the current K8S Audit Logs support implementation out of Falco and turn it into a Falcosecurity PR. The goals of this PR are to:

  • Remove the current audit log implementation from Falco
  • Adapt all integration tests to use new K8S Audit plugin
  • Adapt the K8S default ruleset to use the new K8S Audit plugin
  • Drop the civetweb dependency
  • Re-implement the healthz endpoint with a lightweight HTTP server

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

This new plugin-based K8S Audit implementation introduces the following breaking changes:

  • The falco.yaml piece of configuration responsible of K8S Audit is now located under the plugins section
  • List field types now have explicit list typing: a field can either extract a single value or a list of values. For list values, extracting one value means extracting a list containing only one value, which is not the same thing as extracting regular single values
  • List field types now only support the in and intersects operators. For example, checks such as ka.req.role.rules.verbs contains create would be rejected and would need to be changed in the equivalent ka.req.role.rules.verbs intersects (create)
  • Failed field value extraction should be checked with the exists operator, and not by comparing with the <NA> string.
    The <NA> string literal is not returned anymore, neither in single-valued fields nor in list fields. For example, in the past field existence was occasionally checked with expressions like ka.target.subresource != <NA>, which would now inherently never be true, because if the field is absent the string comparison fails by default. Instead, prefer using the analoguous ka.target.subresource exists, which explicitly checks for missing values.
  • The /healtz endpoint cannot bind to the same port of the K8S Audit Log endpoint (e.g. /k8s-audit), due to the fact that they are now managed by two different webservers (one in Falco, one in the plugin)
  • Syscalls and K8S Audit event sources cannot be active at the same time anymore. This is caused by the current restriction of having 1 event source active per time in the libs, so that this may change in the future

Blocking PRs:

Does this PR introduce a user-facing change?:

refactor!: remove K8S audit logs from Falco

@poiana
Copy link
Contributor

poiana commented Mar 22, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jasondellaluce

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 poiana requested review from fntlnz and mstemm March 22, 2022 16:32
@jasondellaluce jasondellaluce force-pushed the refactor/k8saudit-porting branch 2 times, most recently from 579f680 to 92548f7 Compare March 23, 2022 16:41
@jasondellaluce
Copy link
Contributor Author

/milestone 0.32.0

@jasondellaluce
Copy link
Contributor Author

This is currently blocked by the changes of #1976.

@jasondellaluce jasondellaluce changed the title wip: refactor: remove K8S audit logs from Falco wip: refactor!: remove K8S audit logs from Falco Apr 21, 2022
@@ -21,4 +21,4 @@ limitations under the License.
// This is the result of running "falco --list -N | sha256sum" and
// represents the fields supported by this version of Falco. It's used
// at build time to detect a changed set of fields.
#define FALCO_FIELDS_CHECKSUM "77c4c549181b8aac1b9698c0101ac61acb5b2faede84a2c4fecb34834c6de2b9"
#define FALCO_FIELDS_CHECKSUM "a557747a209f2d16e90a3324d84d56c02cf54d000b6e3ee44598413f19885fcc"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This changes because the ka.* and jevt.* are not listed anymore with the default falco.yaml configuration.

@jasondellaluce jasondellaluce changed the title wip: refactor!: remove K8S audit logs from Falco refactor!: remove K8S audit logs from Falco Apr 22, 2022
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.

Just left a comment, otherwise SGTM! 🤩

userspace/falco/webserver.cpp Outdated Show resolved Hide resolved
Signed-off-by: Jason Dellaluce <[email protected]>
Co-authored-by: Leonardo Grasso <[email protected]>

Co-authored-by: Leonardo Grasso <[email protected]>
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.

💥

Copy link
Contributor

@mstemm mstemm left a comment

Choose a reason for hiding this comment

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

Just a couple of questions and one suggested change. Thanks for making this great change!

userspace/engine/json_evt.h Show resolved Hide resolved
}

for(const auto &src : m_options.disable_sources)
{
m_state->enabled_sources.erase(src);
}

// XXX/mstemm technically this isn't right, you could disable syscall *and* k8s_audit and configure a plugin.
// todo(jasondellaluce,leogr): change this once we attain multiple active source
Copy link
Contributor

Choose a reason for hiding this comment

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

This will increase the need to support multiple event sources within one falco process. k8s and syscalls together used to be supported together obviously, and that isn't possible atm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely. I left this comment as a remainder for when we'll work on supporting multiple sources.

@@ -148,8 +148,8 @@ if(NOT MINIMAL_BUILD)
# libcurl
include(curl)

# civetweb
include(civetweb)
# cpp-httlib
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why the switch to cpp-httplib?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Civetweb caused lots of compilation problems in the past, and was in general a troublesome dependency for us in the past. This new http server is header-only and pretty lightweight, which better serves out purposes for now since we only implement /healthz.

@poiana poiana removed the lgtm label Apr 29, 2022
@poiana poiana requested a review from leogr April 29, 2022 18:34
Copy link
Contributor

@mstemm mstemm left a comment

Choose a reason for hiding this comment

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

I'll approve it to just save a round-trip on monday. @jasondellaluce promised to update the comment and I'll check back for answers on the other questions.

Thanks again!

@poiana poiana added the lgtm label Apr 29, 2022
@poiana
Copy link
Contributor

poiana commented Apr 29, 2022

LGTM label has been added.

Git tree hash: 093cd38cf8219e09e240c466c1ea51cd9a7afd6d

@poiana poiana merged commit dbbc93f into master Apr 29, 2022
@poiana poiana deleted the refactor/k8saudit-porting branch April 29, 2022 18:47
@mstemm
Copy link
Contributor

mstemm commented Apr 29, 2022

(whoops, didn't see that @leogr had also approved). Well I'll check back for the answers and it would be nice to clean up the comment in a later PR. Not the end of the world as that code is pretty retired anyway.

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

Successfully merging this pull request may close these issues.

4 participants