Skip to content

feat: restore --cgroup_path CLI parameter for tls subcommand#975

Merged
cfc4n merged 7 commits into
masterfrom
copilot/fix-no-pid-cgroup-issue
Apr 5, 2026
Merged

feat: restore --cgroup_path CLI parameter for tls subcommand#975
cfc4n merged 7 commits into
masterfrom
copilot/fix-no-pid-cgroup-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 5, 2026

  • Explore cgroup validation code in openssl and gotls probes
  • Move cgroup2 filesystem check into shared GetCgroupIdFromPath() in pkg/util/ebpf/cgroup_linux.go
  • Remove now-redundant checkCgroupPath/validateCgroupPath from openssl config
  • Add test for non-cgroup2 path rejection
  • Validate with build/tests
  • Run parallel validation (passed: 0 CodeQL alerts, code review clean)

Copilot AI linked an issue Apr 5, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 5, 2026 02:13
Re-add the --cgroup_path flag that was removed in v2, maintaining
backward compatibility with v1.5.x. The flag validates cgroup v2
filesystem availability and supports fallback paths for CentOS.

Closes #768

Agent-Logs-Url: https://github.com/gojue/ecapture/sessions/df752faa-293d-46ca-9966-84dcdcbeee8f

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix no pid or cgroup issue since version 2 feat: restore --cgroup_path CLI parameter for tls subcommand Apr 5, 2026
Copilot AI requested a review from cfc4n April 5, 2026 02:16
Copilot finished work on behalf of cfc4n April 5, 2026 02:16
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 5, 2026

✅ E2E Test Results: PASSED

Test Run: #23992335336

Tests Executed:

  • TLS/OpenSSL Module (curl → github.com)
  • GnuTLS Module (wget/curl → github.com)
  • GoTLS Module (Go client → github.com)
  • ecaptureQ Module (WebSocket event streaming)

✅ All e2e tests passed successfully! The TLS capture functionality is working correctly.


Automated e2e test results for commit 57c553a

Copilot AI and others added 2 commits April 5, 2026 03:20
- kern/common.h: Add target_cgroup_id volatile constant
- kern/ecapture.h: Add cgroup ID check in filter_rejects() using
  bpf_get_current_cgroup_id()
- internal/config/base_config.go: Move CGroupPath to BaseConfig
  (shared by all probes) with getter/setter methods
- internal/domain/configuration.go: Add GetCGroupPath() to interface
- pkg/util/ebpf/cgroup_linux.go: Add GetCgroupIdFromPath() using
  unix.NameToHandleAt to resolve cgroup path to kernel cgroup ID
- pkg/util/ebpf/cgroup_ecandroid.go: No-op stub for Android
- internal/probe/openssl/openssl_probe.go: Inject target_cgroup_id
  via ConstantEditor
- internal/probe/gotls/gotls_probe.go: Inject target_cgroup_id
  via ConstantEditor
- cli/cmd/gotls.go: Add --cgroup_path flag
- cli/cmd/gnutls.go: Add --cgroup_path flag
- cli/cmd/nss.go: Add --cgroup_path flag
- Add unit tests for GetCgroupIdFromPath
- Fix existing tests for CGroupPath field migration
- All golangci-lint checks pass

Agent-Logs-Url: https://github.com/gojue/ecapture/sessions/8759f567-9f4b-4449-8f15-0ede80d562a0

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copilot finished work on behalf of cfc4n April 5, 2026 03:24
@cfc4n cfc4n marked this pull request as ready for review April 5, 2026 03:42
Copilot AI review requested due to automatic review settings April 5, 2026 03:42
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Apr 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 5, 2026

✅ E2E Test Results: PASSED

Test Run: #23993335060

Tests Executed:

  • TLS/OpenSSL Module (curl → github.com)
  • GnuTLS Module (wget/curl → github.com)
  • GoTLS Module (Go client → github.com)
  • ecaptureQ Module (WebSocket event streaming)

✅ All e2e tests passed successfully! The TLS capture functionality is working correctly.


Automated e2e test results for commit 321d433

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds back cgroup-based filtering via a --cgroup_path CLI parameter by introducing a shared config field, a utility to resolve a cgroup v2 ID, and wiring that ID into eBPF constant editors so the kernel-side filter_rejects() can drop events outside the target cgroup.

Changes:

  • Add target_cgroup_id eBPF constant + cgroup check in filter_rejects() using bpf_get_current_cgroup_id().
  • Introduce BaseConfig.CGroupPath + Configuration.GetCGroupPath() and plumb it into OpenSSL/GoTLS probes’ constant editors.
  • Add GetCgroupIdFromPath() utility + tests; expose --cgroup_path flags on multiple CLI subcommands.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
pkg/util/ebpf/cgroup_test.go Adds tests for GetCgroupIdFromPath() behavior.
pkg/util/ebpf/cgroup_linux.go Implements cgroup v2 ID lookup via unix.NameToHandleAt.
pkg/util/ebpf/cgroup_ecandroid.go Android stub implementation returning no filtering.
kern/ecapture.h Adds cgroup-based rejection logic in filter_rejects().
kern/common.h Declares new target_cgroup_id volatile constant.
internal/probe/openssl/openssl_probe.go Injects target_cgroup_id via constant editors.
internal/probe/openssl/config.go Adds cgroup-path validation step to OpenSSL config validation.
internal/probe/openssl/config_test.go Adds tests around CGroupPath defaults/serialization/validation.
internal/probe/openssl/config_linux.go Implements Linux cgroup path validation/resolution logic.
internal/probe/openssl/config_ecandroid.go Android no-op for cgroup-path validation.
internal/probe/gotls/gotls_probe.go Injects target_cgroup_id via constant editors.
internal/domain/configuration.go Extends configuration interface with GetCGroupPath().
internal/config/base_config.go Adds CGroupPath field + getters/setters in BaseConfig.
cli/cmd/tls.go Adds --cgroup_path flag to OpenSSL (tls) subcommand.
cli/cmd/nss.go Adds --cgroup_path flag to NSPR/NSS subcommand.
cli/cmd/gotls.go Adds --cgroup_path flag to GoTLS subcommand.
cli/cmd/gnutls.go Adds --cgroup_path flag to GnuTLS subcommand.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/util/ebpf/cgroup_linux.go
Comment thread pkg/util/ebpf/cgroup_test.go
Comment thread internal/probe/openssl/config.go
Comment thread internal/probe/openssl/config_linux.go
Comment thread internal/probe/openssl/config_linux.go Outdated
Comment thread cli/cmd/tls.go Outdated
Comment thread cli/cmd/gotls.go Outdated
Comment thread cli/cmd/gnutls.go Outdated
Comment thread cli/cmd/nss.go Outdated
Comment thread pkg/util/ebpf/cgroup_linux.go
devin-ai-integration[bot]

This comment was marked as resolved.

1. checkCgroupPath now strictly validates cgroup v2 (CGROUP2_SUPER_MAGIC)
   instead of silently falling back to hardcoded paths (issues 1, 2, 4)
2. Fix misleading help text for --cgroup_path flags (issue 3)
3. Update comment to reflect cgroup v2-only support (issue 5)
4. Add test for invalid cgroup path

Agent-Logs-Url: https://github.com/gojue/ecapture/sessions/9b93d099-ff11-43f8-b780-b5dc5138b39a

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copilot finished work on behalf of cfc4n April 5, 2026 04:13
Copy link
Copy Markdown
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 5, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 5, 2026

✅ E2E Test Results: PASSED

Test Run: #23994019225

Tests Executed:

  • TLS/OpenSSL Module (curl → github.com)
  • GnuTLS Module (wget/curl → github.com)
  • GoTLS Module (Go client → github.com)
  • ecaptureQ Module (WebSocket event streaming)

✅ All e2e tests passed successfully! The TLS capture functionality is working correctly.


Automated e2e test results for commit d184950

The gotls probe called GetCgroupIdFromPath without first validating
the path is on a cgroup v2 filesystem. The openssl probe had this
validation in its own Config.Validate() via checkCgroupPath().

Move the cgroup2 filesystem type check (CGROUP2_SUPER_MAGIC) into
GetCgroupIdFromPath itself, so all callers are protected automatically.
Remove the now-redundant checkCgroupPath from the openssl config and
delegate validateCgroupPath to the shared function.

Agent-Logs-Url: https://github.com/gojue/ecapture/sessions/001d3691-f178-4956-b1eb-dbf374d9ed73

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copilot finished work on behalf of cfc4n April 5, 2026 04:48
Copy link
Copy Markdown
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 5, 2026

✅ E2E Test Results: PASSED

Test Run: #23994473654

Tests Executed:

  • TLS/OpenSSL Module (curl → github.com)
  • GnuTLS Module (wget/curl → github.com)
  • GoTLS Module (Go client → github.com)
  • ecaptureQ Module (WebSocket event streaming)

✅ All e2e tests passed successfully! The TLS capture functionality is working correctly.


Automated e2e test results for commit 0fe2b5f

@cfc4n cfc4n merged commit 320baae into master Apr 5, 2026
11 of 12 checks passed
@cfc4n cfc4n deleted the copilot/fix-no-pid-cgroup-issue branch April 5, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

no pid or cgroup since version 2

3 participants