mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 21:15:26 +00:00
* feat http response memory optimization + reuse buffers * update nuclei version * feat: reuse js vm's and compile to programs * fix failing http integration test * remove dead code + add -jsc * feat reuse js vms in pool with concurrency * update comments as per review * bug fix+ update interactsh test to look for dns interaction * try enabling all interactsh integration tests --------- Co-authored-by: mzack <marco.rivoli.nvh@gmail.com>
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package compiler
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/projectdiscovery/gologger"
|
|
"github.com/projectdiscovery/gologger/levels"
|
|
)
|
|
|
|
func TestNewCompilerConsoleDebug(t *testing.T) {
|
|
gotString := ""
|
|
gologger.DefaultLogger.SetMaxLevel(levels.LevelDebug)
|
|
gologger.DefaultLogger.SetWriter(&noopWriter{
|
|
Callback: func(data []byte, level levels.Level) {
|
|
gotString = string(data)
|
|
},
|
|
})
|
|
|
|
compiler := New()
|
|
_, err := compiler.Execute("console.log('hello world');", NewExecuteArgs())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.HasSuffix(gotString, "hello world") {
|
|
t.Fatalf("console.log not working, got=%v", gotString)
|
|
}
|
|
}
|
|
|
|
func TestExecuteResultGetSuccess(t *testing.T) {
|
|
compiler := New()
|
|
result, err := compiler.Execute("1+1 == 2", NewExecuteArgs())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if result.GetSuccess() != true {
|
|
t.Fatalf("expected true, got=%v", result.GetSuccess())
|
|
}
|
|
}
|
|
|
|
type noopWriter struct {
|
|
Callback func(data []byte, level levels.Level)
|
|
}
|
|
|
|
func (n *noopWriter) Write(data []byte, level levels.Level) {
|
|
if n.Callback != nil {
|
|
n.Callback(data, level)
|
|
}
|
|
}
|