Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gaarutyunov/go-joern
Go client for Joern
https://github.com/gaarutyunov/go-joern
joern
Last synced: 14 days ago
JSON representation
Go client for Joern
- Host: GitHub
- URL: https://github.com/gaarutyunov/go-joern
- Owner: gaarutyunov
- Created: 2024-11-12T21:37:44.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-12T21:45:27.000Z (about 2 months ago)
- Last Synced: 2024-11-25T05:42:28.427Z (about 1 month ago)
- Topics: joern
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-joern
Go client for Joern.
## Usage
1. Run Joern as a [Server](https://docs.joern.io/server/):
```bash
joern --server --server-host localhost \
--server-port 8080 \
--server-auth-username user \
--server-auth-password pass
```2. Connect using the client
```go
package mainimport (
"context"
"github.com/gaarutyunov/go-joern"
"github.com/google/uuid"
"time"
)func main() {
client := joern.NewClient(
joern.WithBaseURL("localhost:8080"),
joern.WithBasicAuth("user", "pass"),
joern.WithBufferSize(36),
joern.WithTimeout(3600*time.Second),
)
ctx := context.Background()
msg := make(chan string)err := client.Open(ctx)
if err != nil {
panic(err)
}defer func() {
client.Close()
close(msg)
}()go func() {
for m := range msg {
switch m {
case joern.Connected:
default:
id, err := uuid.FromBytes([]byte(m))
if err != nil {
panic(err)
}
result, err := client.Result(ctx, id)
if err != nil {
panic(err)
}
println(result.Stdout)
}
}
}()_, err = client.Send(ctx, "help")
if err != nil {
panic(err)
}client.Receive(ctx, msg)
}
```