Skip to content

Fix darwin cmdline fetching with ps-based implementation and add CI workflows - #4

Merged
evict merged 6 commits into
mainfrom
copilot/add-workflow-files-for-testing
Jan 31, 2026
Merged

Fix darwin cmdline fetching with ps-based implementation and add CI workflows#4
evict merged 6 commits into
mainfrom
copilot/add-workflow-files-for-testing

Conversation

Copilot AI commented Jan 31, 2026

Copy link
Copy Markdown
Contributor

Darwin cmdline fetching via sysctl kern.procargs2 was broken. Replaced with ps command parsing for both darwin and existing linux implementations to ensure reliable process allowlist validation.

Changes

  • Darwin cmdline implementation: Switched from sysctl binary parsing to ps -p <pid> -o args= for command line and ps -p <pid> -o comm= for executable path
  • Test coverage: Added cmdline_darwin_test.go and cmdline_linux_test.go to validate cmdline construction and process validation on both platforms
  • CI workflows: Added .github/workflows/test-{linux,macos}.yml that run only cmdline retrieval tests without requiring FUSE setup

Implementation

// Before: Complex sysctl binary parsing with argc/argv extraction
func getProcArgs(pid uint32) ([]string, error) {
    buf, err := unix.SysctlRaw(fmt.Sprintf("kern.procargs2.%d", pid))
    // ... 50+ lines of binary parsing ...
}

// After: Simple ps command parsing
func getProcArgs(pid uint32) ([]string, error) {
    cmd := exec.Command("ps", "-p", fmt.Sprintf("%d", pid), "-o", "args=")
    output, err := cmd.Output()
    // Parse and split on whitespace
}

The ps-based approach matches the allowlist pattern matching behavior (whitespace-split arguments) and eliminates platform-specific binary parsing complexity.

CI Configuration

The workflows run targeted cmdline tests using -run "Cmdline|ExePath|ValidateCmdline|ProcCmdline" to test only the process command line retrieval functionality without requiring FUSE installation, making CI faster and simpler.

Original prompt

Create macos and linux workflow files for running the tests of our project.

Currently for darwin or cmdline fetching behavior is broken, we should use the ps command and parse the output. Use the flags to display the cmdline on mac; we parse the output construct the allowlist.

Write tests for both platform to validate that the approaches are working. We must be able to construct the cmdline on both platforms.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 31, 2026 12:46
Co-authored-by: evict <7238650+evict@users.noreply.github.com>
Co-authored-by: evict <7238650+evict@users.noreply.github.com>
Co-authored-by: evict <7238650+evict@users.noreply.github.com>
Co-authored-by: evict <7238650+evict@users.noreply.github.com>
Copilot AI changed the title [WIP] Add macOS and Linux workflow files for running tests Fix darwin cmdline fetching with ps-based implementation and add CI workflows Jan 31, 2026
Copilot AI requested a review from evict January 31, 2026 12:51
Comment thread .github/workflows/test-macos.yml Outdated
brew install --cask macfuse

- name: Run tests
run: go test -v ./...

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot let's only run the tests that do not require using the FUSE setup. Only the cmdline retrieval for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated both workflows to only run cmdline tests without FUSE setup. Removed macFUSE and fuse3 installation steps since they're not needed for these tests. (de73c25)

Co-authored-by: evict <7238650+evict@users.noreply.github.com>
Copilot AI requested a review from evict January 31, 2026 12:54
@evict
evict marked this pull request as ready for review January 31, 2026 12:56
@evict
evict merged commit 18484f7 into main Jan 31, 2026
4 checks passed
@evict
evict deleted the copilot/add-workflow-files-for-testing branch March 7, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants