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

adding an event on rule exfiltrating artifacts via kubernetes control plane with the utility of creating kind cluster #206

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

h4l0gen
Copy link
Contributor

@h4l0gen h4l0gen commented Apr 21, 2024

What type of PR is this?

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

/kind bug

/kind cleanup

/kind documentation

/kind tests

/kind feature

Any specific area of the project related to this PR?

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

/area commands

/area pkg

/area events

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #192

Special notes for your reviewer:

@poiana
Copy link

poiana commented Apr 21, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: h4l0gen
Once this PR has been reviewed and has the lgtm label, please assign fededp for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@h4l0gen
Copy link
Contributor Author

h4l0gen commented Apr 22, 2024

This PR involves the following steps:

  • First, it creates a kind cluster and places the kubeconfig file in the Host's /tmp directory.
  • Next, it calls the waitForClusterReadiness function to ensure that the cluster is fully prepared.
  • Then, it creates a test pod and a test container inside it, after creating a new default service account. A new function called newTestPod is defined, which specifies the configuration for the test container. Initially, it creates the /tmp/created-by-event-generator.txt file, which will be copied using kubectl cp later.
  • Following that, it calls verifyPodAndContainerRunning to verify that the pod and container are fully prepared and operational.

For cleanup:

  • Initially, it calls deleteTestPod.
  • Finally, it deletes the kind cluster by calling deleteKindCluster.

I've separated the above setup from the event as it can be reused (as a utility).
Finally, in event ExfiltratingArtifactsViaKubernetesControlPlane:

createKindCluster
waitForClusterReadiness
createTestPod
copyFileFromContainer
deleteTestPod
deleteKindCluster

Functions are called in sequence. copyFileFromContainer runs the kubectl cp command and deletes the copied file in the host's /tmp directory.

@h4l0gen
Copy link
Contributor Author

h4l0gen commented Apr 22, 2024

Rule triggered successfully
image

Signed-off-by: h4l0gen <[email protected]>

commits squashed

Signed-off-by: h4l0gen <[email protected]>
@h4l0gen h4l0gen force-pushed the exfiltrating_artifact_from_k8s_cp branch from 7a38c03 to 7ef0506 Compare April 24, 2024 04:35
…er initially using a kind cluster with name `kind`

Signed-off-by: Kapil Sharma <[email protected]>
@h4l0gen h4l0gen changed the title adding an event on rule exfiltrating artifacts via kubernetes control plane adding an event on rule exfiltrating artifacts via kubernetes control plane with the utility of creating kind cluster Apr 28, 2024
@h4l0gen
Copy link
Contributor Author

h4l0gen commented May 10, 2024

@leogr @FedeDP @jasondellaluce PTAL at this PR and provide me your valuable feedback. Thank you :)

@poiana
Copy link

poiana commented Aug 8, 2024

Issues go stale after 90d of inactivity.

Mark the issue as fresh with /remove-lifecycle stale.

Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Provide feedback via https://github.com/falcosecurity/community.

/lifecycle stale

@leogr
Copy link
Member

leogr commented Aug 20, 2024

/remove-lifecycle stale

@leogr leogr added this to the v0.13.0 milestone Oct 2, 2024
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.

adding event on exfiltrating artifacts via kubernetes control plane
3 participants