Skip to content

Commit 4bcf1f4

Browse files
committed
Add option to allow using cleartextPassword in DB SDN.
1 parent 4d1c375 commit 4bcf1f4

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ go-graphkb
2222
importer-csv
2323

2424
.config.yml
25+
main

cmd/go-graphkb/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ func onInit() {
8888
viper.GetString("mariadb_username"),
8989
viper.GetString("mariadb_password"),
9090
viper.GetString("mariadb_host"),
91-
dbName)
91+
dbName,
92+
viper.GetBool("mariadb_allow_cleartext_password"))
9293
}
9394

9495
func count(cmd *cobra.Command, args []string) {

internal/database/mariadb.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"log"
99
"reflect"
10+
"strconv"
1011
"sync/atomic"
1112
"time"
1213

@@ -31,8 +32,9 @@ type SourceRelation struct {
3132
}
3233

3334
// NewMariaDB create an instance of mariadb
34-
func NewMariaDB(username string, password string, host string, databaseName string) *MariaDB {
35-
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@(%s)/%s", username, password, host, databaseName))
35+
func NewMariaDB(username string, password string, host string, databaseName string, allowCleartextPassword bool) *MariaDB {
36+
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@(%s)/%s?allowCleartextPasswords=%s", username, password,
37+
host, databaseName, strconv.FormatBool(allowCleartextPassword)))
3638
if err != nil {
3739
log.Fatal(err)
3840
}

0 commit comments

Comments
 (0)