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

Packet capture context #4072

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

Conversation

oshaked1
Copy link
Contributor

1. Explain what the PR does

This PR adds context information to pcap files generated by Tracee. Based on the type of pcap, an interface description that contains various pieces of context information in JSON format is added.

Example of an interface description for a process pcap:

{"container":{"id":"c373adfdc4ac4c3a330c4fda09ad9398bcfb99c381b97cb044c813a397547def","name":"gallant_nightingale","image":"busybox:latest","imageDigest":"busybox@sha256:5eef5ed34e1e1ff0a4ae850395cbf665c4de6b4b83a32a0bc7bcb998e24e7bbb"},"kubernetes":{"podName":"","podNamespace":"","podUID":"","podSandbox":false},"hostName":"c373adfdc4ac","processName":"ping","process":{"threadStartTime":1716378637481073915,"processId":1,"cgroupId":526,"threadId":1,"parentProcessId":0,"hostProcessId":191684,"hostThreadId":191684,"hostParentProcessId":191665,"userId":0,"mountNamespace":4026532371,"pidNamespace":4026532374,"executable":""}}

This closes #4050.

2. Explain how to test it

An integration test was added for the context information.

To manually read the interface description containing the context information, use the following python script with the pcap file as an argument:

import sys
import pcapng

pcap_path = sys.argv[1]
with open(pcap_path, 'rb') as f:
    scanner = pcapng.FileScanner(f)
    for block in scanner:
        if isinstance(block, pcapng.blocks.InterfaceDescription):
            print(block.options['if_description'])

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.

Add context info to packet captures
1 participant