-
Notifications
You must be signed in to change notification settings - Fork 0
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
chore(src): improve containerd support. #10
Conversation
Backport changes from falcosecurity/libs#2195. Signed-off-by: Federico Di Pierro <[email protected]>
Signed-off-by: Federico Di Pierro <[email protected]>
a471916
to
8c99b3f
Compare
@@ -163,7 +163,7 @@ load_plugins: [container] | |||
By default, all engines are enabled on **default sockets**: | |||
* Docker: `/var/run/docker.sock` | |||
* Podman: `/run/podman/podman.sock` for root, + `/run/user/$uid/podman/podman.sock` for each user in the system | |||
* Containerd: [`/run/containerd/containerd.sock`, `/run/k3s/containerd/containerd.sock`] | |||
* Containerd: [`/run/containerd/containerd.sock`, `/run/k3s/containerd/containerd.sock`, `/run/host-containerd/containerd.sock`] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New bottlerocket related socket.
@@ -80,59 +82,61 @@ func (c *containerdEngine) ctrToInfo(namespacedContext context.Context, containe | |||
} | |||
} | |||
|
|||
// Mounts related - TODO double check | |||
// Mounts related |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
RW: !readOnly, | ||
Propagation: spec.Linux.RootfsPropagation, | ||
}) | ||
} | ||
|
||
// Namespace related - FIXME | ||
// Namespace related - see oci.WithHostNamespace() impl: it just removes the namespace from the list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
imageDigest = image.Target().Digest.String() | ||
if config.GetWithSize() { | ||
size, _ = image.Size(context.TODO()) | ||
imageSize = image.Target().Size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -166,18 +170,39 @@ func (c *containerdEngine) ctrToInfo(namespacedContext context.Context, containe | |||
} | |||
} | |||
|
|||
// Check for privileged: | |||
// see https://github.com/containerd/containerd/blob/main/pkg/oci/spec_opts.go#L1295 | |||
privileged := true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed; a bit ugly but couldn't find a better solution.
return event.Info{ | ||
Container: event.Container{ | ||
Type: typeContainerd.ToCTValue(), | ||
ID: container.ID()[:shortIDLength], | ||
Name: container.ID()[:shortIDLength], | ||
ID: shortContainerID(container.ID()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since containerd supports container_id of any length, properly cut short ID to 12 only if it is longer than 12, to avoid crashes
ImageRepo: imageRepo, | ||
ImageTag: imageTag, | ||
User: spec.Process.User.Username, | ||
CniJson: "", // TODO | ||
User: strconv.FormatUint(uint64(spec.Process.User.UID), 10), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed; we use uid.
// sha256:digest | ||
// See https://github.com/therealbobo/libs/blob/8267fbb909167541c7f7ed655c93a7dc0c1d615b/userspace/libsinsp/cri.hpp#L320 | ||
// for the original c++ implementation. | ||
imageName := ctr.GetImage().GetImage() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied current libsinsp impl.
ImageRepo: imageRepo, | ||
ImageTag: imageTag, | ||
User: user.String(), | ||
User: strconv.FormatInt(ctr.GetUser().GetLinux().GetUid(), 10), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use uid here.
@@ -14,6 +15,191 @@ import ( | |||
"time" | |||
) | |||
|
|||
func TestCRIInfoMap(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test that we are able to unmarshal the json to our struct.
Signed-off-by: Federico Di Pierro <[email protected]>
8c99b3f
to
b62bf68
Compare
…raction. Moreover, added tests around containerd matcher. Signed-off-by: Federico Di Pierro <[email protected]>
Signed-off-by: Federico Di Pierro <[email protected]>
…support for docker and podman. Signed-off-by: Federico Di Pierro <[email protected]>
76348e1
to
3a55b0f
Compare
Signed-off-by: Federico Di Pierro <[email protected]>
3a55b0f
to
603e03e
Compare
Backport changes from falcosecurity/libs#2195.
TODO:
/default/", ""
layout; this only works for containers created in the default namespace; try to support containers created under any namespace? The go-worker containerd subscribe already retrieves info for any container in any namespace; it is a matter of fixing the matcher.Updated TODO with more info.