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

[BUG] go engine doesn't work in code template #5759

Closed
1 task done
sttlr opened this issue Oct 22, 2024 · 0 comments · Fixed by #5767
Closed
1 task done

[BUG] go engine doesn't work in code template #5759

sttlr opened this issue Oct 22, 2024 · 0 comments · Fixed by #5767
Assignees
Labels
Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Milestone

Comments

@sttlr
Copy link
Contributor

sttlr commented Oct 22, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

Current Behavior

Nuclei code templates with engine set to go don't work.

Image

I can change the name of go binary to anything - it doesn't matter. code template still wouldn't work when engine would be pointing to go binary.

But, I can create go file in the current directory - add it to $PATH - and code template executes successfully.

export PATH="`pwd`:$PATH"
echo -e '#!/bin/bash\necho "I am a bash script, but got executed with name go"' > go

And then, when I run the same go-code-engine.yaml it works:
Image

I have no problem with running code templates with engine set to python3 or bash.

And yes, I do have go binary in $PATH.

Expected Behavior

Per Nuclei Template Docs - https://docs.projectdiscovery.io/templates/protocols/code#engine

To execute the code, a list of language interpreters, which are installed or available on the system environment, is specified. These interpreters can be and not limited to bash sh py python3, go, ps, among others, and they are searched sequentially until a suitable one is found. The identifiers for these interpreters should correspond to their respective names or identifiers recognized by the system environment.

Nuclei code templates with engine set to go should work just as with other engines (like python3).

Steps To Reproduce

  1. Create go-code-engine.yaml:
id: go-code-engine

info:
  name: go-code-engine
  author: sttlr
  severity: info

self-contained: true
code:
  - engine:
      - go
    args:
      - run
    pattern: "*.go"
    source: |
      package main

      import "fmt"

      func main() {
          fmt.Println("hello world")
      }

    extractors:
      - type: dsl
        dsl:
          - response
      - type: dsl
        dsl:
          - stderr
  1. Run nuclei -duc -code -t ./go-code-engine.yaml -v -debug -validate

Relevant log output

[ERR] Error occurred parsing template /Users/sttlr/sttlr-nuclei-templates/go-code-engine.yaml: could not compile request: [:RUNTIME] [go-code-engine] engines 'go' not available on host <- no valid engine found
[FTL] Could not validate templates: errors occurred during template validation

Environment

  • OS: MacOS 15.0.1 (24A348)
  • Nuclei: v3.3.5
  • Go: go version go1.22.2 darwin/arm64

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
4 participants