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

fix: panic in capture command, when no arguments are passed #62

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/ebpf/probesfacade/captor/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/binary"
"errors"
"fmt"
"path/filepath"
"sync"
Expand Down Expand Up @@ -51,6 +52,10 @@ type ebpfSetup struct {
// to the ebpf program.
// Returns the ebpfSetup struct in case of seccess, an error in case of failure.
func InitProbes(functionSymbol string, cmdArgs []string, opts CaptureOptions) (*ebpfSetup, error) {
if len(cmdArgs) == 0 {
return nil, errors.New("error no arguments provided, at least 1 argument is required")
}

if !opts.LibbpfOutput {
// suppress libbpf log ouput
bpf.SetLoggerCbs(
Expand Down
4 changes: 4 additions & 0 deletions tests/integration.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ exec harpoon capture -e -c -f main.main -- ./bin/example-app
stderr 'command execution error: fork/exec .* permission denied'
exec chmod +x bin/example-app

# test it doesn't panic when no arguments are provided
! exec harpoon capture -e -c -f main.main
stdout '.* error no arguments provided, at least 1 argument is required'

# setting up test application
exists bin/example-app
# this must be done within the testscript environment
Expand Down
Loading