mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 11:25:26 +00:00
* initial implementation with manual code generation * testing generation * refactor to package methods + auto memoize * more memos * fixing signatures * refactor * adding gen util * adding util * regenerate memoized files --------- Co-authored-by: Tarun Koyalwar <tarun@projectdiscovery.io>
62 lines
1.8 KiB
Go
Executable File
62 lines
1.8 KiB
Go
Executable File
// Warning - This is generated code
|
|
package postgres
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
_ "github.com/lib/pq"
|
|
|
|
utils "github.com/projectdiscovery/nuclei/v3/pkg/js/utils"
|
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
|
|
)
|
|
|
|
func memoizedisPostgres(host string, port int) (bool, error) {
|
|
hash := "isPostgres" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port)
|
|
|
|
v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) {
|
|
return isPostgres(host, port)
|
|
})
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
if value, ok := v.(bool); ok {
|
|
return value, nil
|
|
}
|
|
|
|
return false, errors.New("could not convert cached result")
|
|
}
|
|
|
|
func memoizedexecuteQuery(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)
|
|
|
|
v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) {
|
|
return executeQuery(host, port, username, password, dbName, query)
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if value, ok := v.(*utils.SQLResult); ok {
|
|
return value, nil
|
|
}
|
|
|
|
return nil, errors.New("could not convert cached result")
|
|
}
|
|
|
|
func memoizedconnect(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)
|
|
|
|
v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) {
|
|
return connect(host, port, username, password, dbName)
|
|
})
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
if value, ok := v.(bool); ok {
|
|
return value, nil
|
|
}
|
|
|
|
return false, errors.New("could not convert cached result")
|
|
}
|