Skip to content

Commit

Permalink
TRY to not escape mysql pass by go-sql-driver/mysql lib
Browse files Browse the repository at this point in the history
TRY to not escape mysql pass by go-sql-driver/mysql lib
  • Loading branch information
karminski committed Feb 5, 2024
1 parent df3c745 commit f235636
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/actionruntime/mysql/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"encoding/pem"
"errors"
"fmt"
"net/url"

"github.com/go-sql-driver/mysql"
_ "github.com/go-sql-driver/mysql"
Expand All @@ -48,9 +47,9 @@ func (m *MySQLConnector) getConnectionWithOptions(resourceOptions map[string]int
}

func (m *MySQLConnector) connectPure() (db *sql.DB, err error) {
escapedPassword := url.QueryEscape(m.Resource.DatabasePassword)
// escapedPassword := url.QueryEscape(m.Resource.DatabasePassword)
dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", m.Resource.DatabaseUsername,
escapedPassword, m.Resource.Host, m.Resource.Port, m.Resource.DatabaseName)
m.Resource.DatabasePassword, m.Resource.Host, m.Resource.Port, m.Resource.DatabaseName)
db, err = sql.Open("mysql", dsn+"?timeout=30s")
if err != nil {
return nil, err
Expand All @@ -59,9 +58,9 @@ func (m *MySQLConnector) connectPure() (db *sql.DB, err error) {
}

func (m *MySQLConnector) connectViaSSL() (db *sql.DB, err error) {
escapedPassword := url.QueryEscape(m.Resource.DatabasePassword)
// escapedPassword := url.QueryEscape(m.Resource.DatabasePassword)
dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", m.Resource.DatabaseUsername,
escapedPassword, m.Resource.Host, m.Resource.Port, m.Resource.DatabaseName)
m.Resource.DatabasePassword, m.Resource.Host, m.Resource.Port, m.Resource.DatabaseName)
pool := x509.NewCertPool()
if ok := pool.AppendCertsFromPEM([]byte(m.Resource.SSL.ServerCert)); !ok {
return nil, errors.New("MySQL SSL/TLS Connection failed")
Expand Down

0 comments on commit f235636

Please sign in to comment.