diff --git a/go.mod b/go.mod index e4a71aec7d..092f4e6365 100644 --- a/go.mod +++ b/go.mod @@ -87,7 +87,7 @@ require ( github.com/projectdiscovery/goflags v0.1.64 github.com/projectdiscovery/gologger v1.1.28 github.com/projectdiscovery/gostruct v0.0.2 - github.com/projectdiscovery/gozero v0.0.2 + github.com/projectdiscovery/gozero v0.0.3-0.20241023095525-626f55f7bb32 github.com/projectdiscovery/httpx v1.6.9 github.com/projectdiscovery/mapcidr v1.1.34 github.com/projectdiscovery/n3iwf v0.0.0-20230523120440-b8cd232ff1f5 diff --git a/go.sum b/go.sum index 2223302430..6bb2803627 100644 --- a/go.sum +++ b/go.sum @@ -863,6 +863,8 @@ github.com/projectdiscovery/gostruct v0.0.2 h1:s8gP8ApugGM4go1pA+sVlPDXaWqNP5BBD github.com/projectdiscovery/gostruct v0.0.2/go.mod h1:H86peL4HKwMXcQQtEa6lmC8FuD9XFt6gkNR0B/Mu5PE= github.com/projectdiscovery/gozero v0.0.2 h1:8fJeaCjxL9tpm33uG/RsCQs6HGM/NE6eA3cjkilRQ+E= github.com/projectdiscovery/gozero v0.0.2/go.mod h1:d8bZvDWW07LWNYWrwjZ4OO1I0cpkfqaysyDfSs9ibK8= +github.com/projectdiscovery/gozero v0.0.3-0.20241023095525-626f55f7bb32 h1:PubQkk+F/BiW4+wqBhWiMwPEKYxi/LdYXjxUtHd/tpM= +github.com/projectdiscovery/gozero v0.0.3-0.20241023095525-626f55f7bb32/go.mod h1:d8bZvDWW07LWNYWrwjZ4OO1I0cpkfqaysyDfSs9ibK8= github.com/projectdiscovery/hmap v0.0.62 h1:Pb3omgGQkRHB2EBDhgXniUXVC8Jz2CBzpSMKZYRUKFs= github.com/projectdiscovery/hmap v0.0.62/go.mod h1:pNheW3ukrLOcRUDFWrq8OAZiizhosDonIKRVg/4PGnM= github.com/projectdiscovery/httpx v1.6.9 h1:ihyFclesLjvQpiJpRIlAYeebapyIbOI/arDAvvy1ES8= diff --git a/pkg/protocols/code/code_test.go b/pkg/protocols/code/code_test.go index 320f7c5481..d71b9c6f58 100644 --- a/pkg/protocols/code/code_test.go +++ b/pkg/protocols/code/code_test.go @@ -39,3 +39,34 @@ func TestCodeProtocol(t *testing.T) { require.Nil(t, err, "could not run code request") require.NotEmpty(t, gotEvent, "could not get event items") } + +func TestCodeProtocolForGO(t *testing.T) { + options := testutils.DefaultOptions + + testutils.Init(options) + templateID := "testing-code" + request := &Request{ + Engine: []string{"go"}, + Source: `package main + + import "fmt" + + func main() { + fmt.Println("hello world") + }`, + } + executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{ + ID: templateID, + Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "hello-world"}, + }) + err := request.Compile(executerOpts) + require.Nil(t, err, "could not compile code request") + + var gotEvent output.InternalEvent + ctxArgs := contextargs.NewWithInput(context.Background(), "") + err = request.ExecuteWithResults(ctxArgs, nil, nil, func(event *output.InternalWrappedEvent) { + gotEvent = event.InternalEvent + }) + require.Nil(t, err, "could not run code request") + require.NotEmpty(t, gotEvent, "could not get event items") +}