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

add tracing to all allowed cmds #2061

Merged
merged 13 commits into from
Jan 24, 2025

Conversation

James-Pickett
Copy link
Contributor

@James-Pickett James-Pickett commented Jan 23, 2025

Embeds our allowed commands in a TracedCmd struct to start a span when ever we exec.

func execFaker(filename string) func(context.Context, ...string) (*exec.Cmd, error) {
return func(ctx context.Context, _ ...string) (*exec.Cmd, error) {
return exec.CommandContext(ctx, "/bin/cat", filename), nil //nolint:forbidigo // Fine to use exec.CommandContext in test
func execFaker(filename string) func(context.Context, ...string) (*allowedcmd.TracedCmd, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the method is the reason I had to export allowedcmd.TracedCmd

ee/allowedcmd/cmd.go Outdated Show resolved Hide resolved
ee/allowedcmd/cmd.go Outdated Show resolved Hide resolved
@James-Pickett James-Pickett changed the title rough in of cmd tracing add tracing to all allowed cmds Jan 23, 2025
@James-Pickett James-Pickett marked this pull request as ready for review January 24, 2025 00:11
Copy link
Contributor

@RebeccaMahany RebeccaMahany left a comment

Choose a reason for hiding this comment

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

This is really nice! One small comment about cmd.Environ, otherwise LGTM!

ee/allowedcmd/cmd.go Outdated Show resolved Hide resolved
ee/allowedcmd/cmd.go Outdated Show resolved Hide resolved
ee/allowedcmd/cmd.go Outdated Show resolved Hide resolved
ee/allowedcmd/cmd_darwin.go Outdated Show resolved Hide resolved
Copy link
Contributor

@RebeccaMahany RebeccaMahany left a comment

Choose a reason for hiding this comment

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

🔥

@James-Pickett James-Pickett added this pull request to the merge queue Jan 24, 2025
Merged via the queue into kolide:main with commit ec72c6f Jan 24, 2025
32 checks passed
@James-Pickett James-Pickett deleted the james/trace-allowed-cmds branch January 24, 2025 17: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.

3 participants