From 0eb87c2621da09b45147a7d2974c6b589d5ce20d Mon Sep 17 00:00:00 2001 From: Dwi Siswanto Date: Thu, 25 Dec 2025 17:16:38 +0700 Subject: [PATCH 1/4] fix(js): mysql panic due to missing `executionId` in ctx The `connectWithDSN` func used `db.Exec()` which implicitly uses `context.Background()`[1]. This caused the registered "nucleitcp" dialer callback to receive a ctx missing the `executionId`, leading to a panic during type assertion. Refactor `connectWithDSN` to accept `executionId` explicitly and use it to create a `context` for `db.PingContext()` (yeah, instead of `db.Exec()`). And, add a defensive check in the dialer callback to handle nil values gracefully. Fixes #6733 regression introduced in #6296. [1]: "Exec uses `context.Background` internally" - https://pkg.go.dev/database/sql#DB.Exec. Signed-off-by: Dwi Siswanto --- pkg/js/libs/mysql/memo.mysql.go | 4 ++-- pkg/js/libs/mysql/memo.mysql_private.go | 6 +++--- pkg/js/libs/mysql/mysql.go | 7 ++++--- pkg/js/libs/mysql/mysql_private.go | 6 ++++-- pkg/protocols/common/protocolstate/state.go | 8 +++++++- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/pkg/js/libs/mysql/memo.mysql.go b/pkg/js/libs/mysql/memo.mysql.go index a2c1d2d09..2cbe71db3 100755 --- a/pkg/js/libs/mysql/memo.mysql.go +++ b/pkg/js/libs/mysql/memo.mysql.go @@ -9,7 +9,7 @@ import ( ) func memoizedisMySQL(executionId string, host string, port int) (bool, error) { - hash := "isMySQL" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "isMySQL" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return isMySQL(executionId, host, port) @@ -25,7 +25,7 @@ func memoizedisMySQL(executionId string, host string, port int) (bool, error) { } func memoizedfingerprintMySQL(executionId string, host string, port int) (MySQLInfo, error) { - hash := "fingerprintMySQL" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "fingerprintMySQL" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return fingerprintMySQL(executionId, host, port) diff --git a/pkg/js/libs/mysql/memo.mysql_private.go b/pkg/js/libs/mysql/memo.mysql_private.go index 19d7e81b0..506aff8a9 100755 --- a/pkg/js/libs/mysql/memo.mysql_private.go +++ b/pkg/js/libs/mysql/memo.mysql_private.go @@ -8,11 +8,11 @@ import ( "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate" ) -func memoizedconnectWithDSN(dsn string) (bool, error) { - hash := "connectWithDSN" + ":" + fmt.Sprint(dsn) +func memoizedconnectWithDSN(executionId string, dsn string) (bool, error) { + hash := "connectWithDSN" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(dsn) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { - return connectWithDSN(dsn) + return connectWithDSN(executionId, dsn) }) if err != nil { return false, err diff --git a/pkg/js/libs/mysql/mysql.go b/pkg/js/libs/mysql/mysql.go index 5e57aa66c..d7f6e224d 100644 --- a/pkg/js/libs/mysql/mysql.go +++ b/pkg/js/libs/mysql/mysql.go @@ -108,7 +108,7 @@ func (c *MySQLClient) Connect(ctx context.Context, host string, port int, userna if err != nil { return false, err } - return connectWithDSN(dsn) + return connectWithDSN(executionId, dsn) } type ( @@ -190,8 +190,9 @@ func fingerprintMySQL(executionId string, host string, port int) (MySQLInfo, err // const client = new mysql.MySQLClient; // const connected = client.ConnectWithDSN('username:password@tcp(acme.com:3306)/'); // ``` -func (c *MySQLClient) ConnectWithDSN(dsn string) (bool, error) { - return memoizedconnectWithDSN(dsn) +func (c *MySQLClient) ConnectWithDSN(ctx context.Context, dsn string) (bool, error) { + executionId := ctx.Value("executionId").(string) + return memoizedconnectWithDSN(executionId, dsn) } // ExecuteQueryWithOpts connects to Mysql database using given credentials diff --git a/pkg/js/libs/mysql/mysql_private.go b/pkg/js/libs/mysql/mysql_private.go index c731efd93..a1d81e5f0 100644 --- a/pkg/js/libs/mysql/mysql_private.go +++ b/pkg/js/libs/mysql/mysql_private.go @@ -1,6 +1,7 @@ package mysql import ( + "context" "database/sql" "fmt" "net" @@ -72,7 +73,7 @@ func BuildDSN(opts MySQLOptions) (string, error) { } // @memo -func connectWithDSN(dsn string) (bool, error) { +func connectWithDSN(executionId string, dsn string) (bool, error) { db, err := sql.Open("mysql", dsn) if err != nil { return false, err @@ -83,7 +84,8 @@ func connectWithDSN(dsn string) (bool, error) { db.SetMaxOpenConns(1) db.SetMaxIdleConns(0) - _, err = db.Exec("select 1") + ctx := context.WithValue(context.Background(), "executionId", executionId) + err = db.PingContext(ctx) if err != nil { return false, err } diff --git a/pkg/protocols/common/protocolstate/state.go b/pkg/protocols/common/protocolstate/state.go index 98d30a424..61232df1a 100644 --- a/pkg/protocols/common/protocolstate/state.go +++ b/pkg/protocols/common/protocolstate/state.go @@ -200,8 +200,14 @@ func initDialers(options *types.Options) error { addr += ":3306" } - executionId := ctx.Value("executionId").(string) + var executionId string + if val := ctx.Value("executionId"); val != nil { + executionId = val.(string) + } dialer := GetDialersWithId(executionId) + if dialer == nil { + return nil, fmt.Errorf("dialers not initialized for %s", executionId) + } return dialer.Fastdialer.Dial(ctx, "tcp", addr) }) From 12176d67a9fb2949d202f3f95c29252c2b2ca8ca Mon Sep 17 00:00:00 2001 From: Dwi Siswanto Date: Fri, 26 Dec 2025 01:08:00 +0700 Subject: [PATCH 2/4] test(javascript): add mysql-connect integration test Signed-off-by: Dwi Siswanto --- cmd/integration-test/javascript.go | 52 +++++++++++++++++++ .../protocols/javascript/mysql-connect.yaml | 23 ++++++++ 2 files changed, 75 insertions(+) create mode 100644 integration_tests/protocols/javascript/mysql-connect.yaml diff --git a/cmd/integration-test/javascript.go b/cmd/integration-test/javascript.go index ccee6a6b9..63b2d59e8 100644 --- a/cmd/integration-test/javascript.go +++ b/cmd/integration-test/javascript.go @@ -18,6 +18,7 @@ var jsTestcases = []TestCaseInfo{ {Path: "protocols/javascript/oracle-auth-test.yaml", TestCase: &javascriptOracleAuthTest{}, DisableOn: func() bool { return osutils.IsWindows() || osutils.IsOSX() }}, {Path: "protocols/javascript/vnc-pass-brute.yaml", TestCase: &javascriptVncPassBrute{}}, {Path: "protocols/javascript/postgres-pass-brute.yaml", TestCase: &javascriptPostgresPassBrute{}, DisableOn: func() bool { return osutils.IsWindows() || osutils.IsOSX() }}, + {Path: "protocols/javascript/mysql-connect.yaml", TestCase: &javascriptMySQLConnect{}, DisableOn: func() bool { return osutils.IsWindows() || osutils.IsOSX() }}, {Path: "protocols/javascript/multi-ports.yaml", TestCase: &javascriptMultiPortsSSH{}}, {Path: "protocols/javascript/no-port-args.yaml", TestCase: &javascriptNoPortArgs{}}, } @@ -28,6 +29,7 @@ var ( oracleResource *dockertest.Resource vncResource *dockertest.Resource postgresResource *dockertest.Resource + mysqlResource *dockertest.Resource pool *dockertest.Pool defaultRetry = 3 ) @@ -203,6 +205,38 @@ func (j *javascriptPostgresPassBrute) Execute(filePath string) error { return multierr.Combine(errs...) } +type javascriptMySQLConnect struct{} + +func (j *javascriptMySQLConnect) Execute(filePath string) error { + if mysqlResource == nil || pool == nil { + // skip test as mysql is not running + return nil + } + tempPort := mysqlResource.GetPort("3306/tcp") + finalURL := "localhost:" + tempPort + defer purge(mysqlResource) + errs := []error{} + for i := 0; i < defaultRetry; i++ { + results := []string{} + var err error + _ = pool.Retry(func() error { + //let mysql server start + time.Sleep(5 * time.Second) + results, err = testutils.RunNucleiTemplateAndGetResults(filePath, finalURL, debug) + return nil + }) + if err != nil { + return err + } + if err := expectResultsCount(results, 1); err == nil { + return nil + } else { + errs = append(errs, err) + } + } + return multierr.Combine(errs...) +} + type javascriptMultiPortsSSH struct{} func (j *javascriptMultiPortsSSH) Execute(filePath string) error { @@ -345,4 +379,22 @@ func init() { if err := postgresResource.Expire(30); err != nil { log.Printf("Could not expire postgres resource: %s", err) } + + // setup a temporary mysql instance + mysqlResource, err = pool.RunWithOptions(&dockertest.RunOptions{ + Repository: "mysql", + Tag: "latest", + Env: []string{ + "MYSQL_ROOT_PASSWORD=secret", + }, + Platform: "linux/amd64", + }) + if err != nil { + log.Printf("Could not start mysql resource: %s", err) + return + } + // by default expire after 30 sec + if err := mysqlResource.Expire(30); err != nil { + log.Printf("Could not expire mysql resource: %s", err) + } } diff --git a/integration_tests/protocols/javascript/mysql-connect.yaml b/integration_tests/protocols/javascript/mysql-connect.yaml new file mode 100644 index 000000000..56952f90f --- /dev/null +++ b/integration_tests/protocols/javascript/mysql-connect.yaml @@ -0,0 +1,23 @@ +id: mysql-connect + +info: + name: MySQL Connect Test + author: pdteam + severity: high + +javascript: + - pre-condition: | + isPortOpen(Host, Port) + code: | + const mysql = require('nuclei/mysql'); + const client = new mysql.MySQLClient; + success = client.Connect(Host, Port, User, Pass); + args: + Host: "{{Host}}" + Port: "3306" + User: "root" + Pass: "secret" + matchers: + - type: dsl + dsl: + - "success == true" From 22469bdc2f7ef12a79506761c17f1825180316d5 Mon Sep 17 00:00:00 2001 From: Dwi Siswanto Date: Fri, 26 Dec 2025 01:08:06 +0700 Subject: [PATCH 3/4] chore(js): update memoized functions Signed-off-by: Dwi Siswanto --- pkg/js/libs/mssql/memo.mssql.go | 4 ++-- pkg/js/libs/oracle/memo.oracle.go | 2 +- pkg/js/libs/pop3/memo.pop3.go | 2 +- pkg/js/libs/postgres/memo.postgres.go | 10 +++++----- pkg/js/libs/rdp/memo.rdp.go | 6 +++--- pkg/js/libs/redis/memo.redis.go | 8 ++++---- pkg/js/libs/rsync/memo.rsync.go | 2 +- pkg/js/libs/smb/memo.smb.go | 4 ++-- pkg/js/libs/smb/memo.smb_private.go | 2 +- pkg/js/libs/smb/memo.smbghost.go | 3 ++- pkg/js/libs/telnet/memo.telnet.go | 2 +- pkg/js/libs/vnc/memo.vnc.go | 2 +- 12 files changed, 24 insertions(+), 23 deletions(-) diff --git a/pkg/js/libs/mssql/memo.mssql.go b/pkg/js/libs/mssql/memo.mssql.go index a8af1a6af..2451d4ab1 100755 --- a/pkg/js/libs/mssql/memo.mssql.go +++ b/pkg/js/libs/mssql/memo.mssql.go @@ -11,7 +11,7 @@ import ( ) func memoizedconnect(executionId string, host string, port int, username string, password string, dbName string) (bool, error) { - hash := "connect" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(username) + ":" + fmt.Sprint(password) + ":" + fmt.Sprint(dbName) + hash := "connect" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(username) + ":" + fmt.Sprint(password) + ":" + fmt.Sprint(dbName) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return connect(executionId, host, port, username, password, dbName) @@ -27,7 +27,7 @@ func memoizedconnect(executionId string, host string, port int, username string, } func memoizedisMssql(executionId string, host string, port int) (bool, error) { - hash := "isMssql" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "isMssql" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return isMssql(executionId, host, port) diff --git a/pkg/js/libs/oracle/memo.oracle.go b/pkg/js/libs/oracle/memo.oracle.go index 20931f280..da5106814 100755 --- a/pkg/js/libs/oracle/memo.oracle.go +++ b/pkg/js/libs/oracle/memo.oracle.go @@ -9,7 +9,7 @@ import ( ) func memoizedisOracle(executionId string, host string, port int) (IsOracleResponse, error) { - hash := "isOracle" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "isOracle" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return isOracle(executionId, host, port) diff --git a/pkg/js/libs/pop3/memo.pop3.go b/pkg/js/libs/pop3/memo.pop3.go index 61ef1dcd0..92a600ce4 100755 --- a/pkg/js/libs/pop3/memo.pop3.go +++ b/pkg/js/libs/pop3/memo.pop3.go @@ -9,7 +9,7 @@ import ( ) func memoizedisPoP3(executionId string, host string, port int) (IsPOP3Response, error) { - hash := "isPoP3" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "isPoP3" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return isPoP3(executionId, host, port) diff --git a/pkg/js/libs/postgres/memo.postgres.go b/pkg/js/libs/postgres/memo.postgres.go index 4cee2ddd5..f1f515d0c 100755 --- a/pkg/js/libs/postgres/memo.postgres.go +++ b/pkg/js/libs/postgres/memo.postgres.go @@ -5,15 +5,15 @@ import ( "errors" "fmt" - _ "github.com/projectdiscovery/nuclei/v3/pkg/js/utils/pgwrap" - utils "github.com/projectdiscovery/nuclei/v3/pkg/js/utils" + _ "github.com/projectdiscovery/nuclei/v3/pkg/js/utils/pgwrap" + "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate" ) func memoizedisPostgres(executionId string, host string, port int) (bool, error) { - hash := "isPostgres" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "isPostgres" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return isPostgres(executionId, host, port) @@ -29,7 +29,7 @@ func memoizedisPostgres(executionId string, host string, port int) (bool, error) } func memoizedexecuteQuery(executionId string, host string, port int, username string, password string, dbName string, query string) (*utils.SQLResult, error) { - hash := "executeQuery" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(username) + ":" + fmt.Sprint(password) + ":" + fmt.Sprint(dbName) + ":" + fmt.Sprint(query) + hash := "executeQuery" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(username) + ":" + fmt.Sprint(password) + ":" + fmt.Sprint(dbName) + ":" + fmt.Sprint(query) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return executeQuery(executionId, host, port, username, password, dbName, query) @@ -45,7 +45,7 @@ func memoizedexecuteQuery(executionId string, host string, port int, username st } func memoizedconnect(executionId string, host string, port int, username string, password string, dbName string) (bool, error) { - hash := "connect" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(username) + ":" + fmt.Sprint(password) + ":" + fmt.Sprint(dbName) + hash := "connect" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(username) + ":" + fmt.Sprint(password) + ":" + fmt.Sprint(dbName) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return connect(executionId, host, port, username, password, dbName) diff --git a/pkg/js/libs/rdp/memo.rdp.go b/pkg/js/libs/rdp/memo.rdp.go index f295e97b7..d73ee0517 100755 --- a/pkg/js/libs/rdp/memo.rdp.go +++ b/pkg/js/libs/rdp/memo.rdp.go @@ -9,7 +9,7 @@ import ( ) func memoizedisRDP(executionId string, host string, port int) (IsRDPResponse, error) { - hash := "isRDP" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "isRDP" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return isRDP(executionId, host, port) @@ -25,7 +25,7 @@ func memoizedisRDP(executionId string, host string, port int) (IsRDPResponse, er } func memoizedcheckRDPAuth(executionId string, host string, port int) (CheckRDPAuthResponse, error) { - hash := "checkRDPAuth" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "checkRDPAuth" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return checkRDPAuth(executionId, host, port) @@ -41,7 +41,7 @@ func memoizedcheckRDPAuth(executionId string, host string, port int) (CheckRDPAu } func memoizedcheckRDPEncryption(executionId string, host string, port int) (RDPEncryptionResponse, error) { - hash := "checkRDPEncryption" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "checkRDPEncryption" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return checkRDPEncryption(executionId, host, port) diff --git a/pkg/js/libs/redis/memo.redis.go b/pkg/js/libs/redis/memo.redis.go index ab587e111..0b3fc91b7 100755 --- a/pkg/js/libs/redis/memo.redis.go +++ b/pkg/js/libs/redis/memo.redis.go @@ -9,7 +9,7 @@ import ( ) func memoizedgetServerInfo(executionId string, host string, port int) (string, error) { - hash := "getServerInfo" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "getServerInfo" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return getServerInfo(executionId, host, port) @@ -25,7 +25,7 @@ func memoizedgetServerInfo(executionId string, host string, port int) (string, e } func memoizedconnect(executionId string, host string, port int, password string) (bool, error) { - hash := "connect" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(password) + hash := "connect" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(password) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return connect(executionId, host, port, password) @@ -41,7 +41,7 @@ func memoizedconnect(executionId string, host string, port int, password string) } func memoizedgetServerInfoAuth(executionId string, host string, port int, password string) (string, error) { - hash := "getServerInfoAuth" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(password) + hash := "getServerInfoAuth" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(password) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return getServerInfoAuth(executionId, host, port, password) @@ -57,7 +57,7 @@ func memoizedgetServerInfoAuth(executionId string, host string, port int, passwo } func memoizedisAuthenticated(executionId string, host string, port int) (bool, error) { - hash := "isAuthenticated" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "isAuthenticated" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return isAuthenticated(executionId, host, port) diff --git a/pkg/js/libs/rsync/memo.rsync.go b/pkg/js/libs/rsync/memo.rsync.go index 98bd45c49..0ab88cfef 100755 --- a/pkg/js/libs/rsync/memo.rsync.go +++ b/pkg/js/libs/rsync/memo.rsync.go @@ -9,7 +9,7 @@ import ( ) func memoizedisRsync(executionId string, host string, port int) (IsRsyncResponse, error) { - hash := "isRsync" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "isRsync" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return isRsync(executionId, host, port) diff --git a/pkg/js/libs/smb/memo.smb.go b/pkg/js/libs/smb/memo.smb.go index 96bdb036a..e2a4b375d 100755 --- a/pkg/js/libs/smb/memo.smb.go +++ b/pkg/js/libs/smb/memo.smb.go @@ -11,7 +11,7 @@ import ( ) func memoizedconnectSMBInfoMode(executionId string, host string, port int) (*smb.SMBLog, error) { - hash := "connectSMBInfoMode" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "connectSMBInfoMode" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return connectSMBInfoMode(executionId, host, port) @@ -27,7 +27,7 @@ func memoizedconnectSMBInfoMode(executionId string, host string, port int) (*smb } func memoizedlistShares(executionId string, host string, port int, user string, password string) ([]string, error) { - hash := "listShares" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(user) + ":" + fmt.Sprint(password) + hash := "listShares" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(user) + ":" + fmt.Sprint(password) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return listShares(executionId, host, port, user, password) diff --git a/pkg/js/libs/smb/memo.smb_private.go b/pkg/js/libs/smb/memo.smb_private.go index c209a61f1..7940d2413 100755 --- a/pkg/js/libs/smb/memo.smb_private.go +++ b/pkg/js/libs/smb/memo.smb_private.go @@ -13,7 +13,7 @@ import ( ) func memoizedcollectSMBv2Metadata(executionId string, host string, port int, timeout time.Duration) (*plugins.ServiceSMB, error) { - hash := "collectSMBv2Metadata" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(timeout) + hash := "collectSMBv2Metadata" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(timeout) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return collectSMBv2Metadata(executionId, host, port, timeout) diff --git a/pkg/js/libs/smb/memo.smbghost.go b/pkg/js/libs/smb/memo.smbghost.go index 43eee8441..dfb89b985 100755 --- a/pkg/js/libs/smb/memo.smbghost.go +++ b/pkg/js/libs/smb/memo.smbghost.go @@ -3,13 +3,14 @@ package smb import ( "errors" + "fmt" "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate" ) func memoizeddetectSMBGhost(executionId string, host string, port int) (bool, error) { - hash := "detectSMBGhost" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "detectSMBGhost" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return detectSMBGhost(executionId, host, port) diff --git a/pkg/js/libs/telnet/memo.telnet.go b/pkg/js/libs/telnet/memo.telnet.go index 0c02169f6..855aa6c16 100755 --- a/pkg/js/libs/telnet/memo.telnet.go +++ b/pkg/js/libs/telnet/memo.telnet.go @@ -9,7 +9,7 @@ import ( ) func memoizedisTelnet(executionId string, host string, port int) (IsTelnetResponse, error) { - hash := "isTelnet" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "isTelnet" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return isTelnet(executionId, host, port) diff --git a/pkg/js/libs/vnc/memo.vnc.go b/pkg/js/libs/vnc/memo.vnc.go index c0639d216..2ca343b75 100755 --- a/pkg/js/libs/vnc/memo.vnc.go +++ b/pkg/js/libs/vnc/memo.vnc.go @@ -9,7 +9,7 @@ import ( ) func memoizedisVNC(executionId string, host string, port int) (IsVNCResponse, error) { - hash := "isVNC" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + hash := "isVNC" + ":" + fmt.Sprint(executionId) + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) { return isVNC(executionId, host, port) From 49309b4ac8ffaf837aeef7dab781c7c97833d0a4 Mon Sep 17 00:00:00 2001 From: Dwi Siswanto Date: Fri, 26 Dec 2025 06:06:41 +0700 Subject: [PATCH 4/4] chore(js): no staticcheck lint Signed-off-by: Dwi Siswanto --- pkg/js/libs/mysql/mysql_private.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/js/libs/mysql/mysql_private.go b/pkg/js/libs/mysql/mysql_private.go index a1d81e5f0..fae42ecd1 100644 --- a/pkg/js/libs/mysql/mysql_private.go +++ b/pkg/js/libs/mysql/mysql_private.go @@ -84,7 +84,7 @@ func connectWithDSN(executionId string, dsn string) (bool, error) { db.SetMaxOpenConns(1) db.SetMaxIdleConns(0) - ctx := context.WithValue(context.Background(), "executionId", executionId) + ctx := context.WithValue(context.Background(), "executionId", executionId) // nolint: staticcheck err = db.PingContext(ctx) if err != nil { return false, err