Skip to content

Commit

Permalink
Add option to allow using cleartextPassword in DB SDN.
Browse files Browse the repository at this point in the history
  • Loading branch information
clems4ever committed Dec 3, 2020
1 parent 4d1c375 commit 4bcf1f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ go-graphkb
importer-csv

.config.yml
main
3 changes: 2 additions & 1 deletion cmd/go-graphkb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ func onInit() {
viper.GetString("mariadb_username"),
viper.GetString("mariadb_password"),
viper.GetString("mariadb_host"),
dbName)
dbName,
viper.GetBool("mariadb_allow_cleartext_password"))
}

func count(cmd *cobra.Command, args []string) {
Expand Down
6 changes: 4 additions & 2 deletions internal/database/mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"log"
"reflect"
"strconv"
"sync/atomic"
"time"

Expand All @@ -31,8 +32,9 @@ type SourceRelation struct {
}

// NewMariaDB create an instance of mariadb
func NewMariaDB(username string, password string, host string, databaseName string) *MariaDB {
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@(%s)/%s", username, password, host, databaseName))
func NewMariaDB(username string, password string, host string, databaseName string, allowCleartextPassword bool) *MariaDB {
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@(%s)/%s?allowCleartextPasswords=%s", username, password,
host, databaseName, strconv.FormatBool(allowCleartextPassword)))
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 4bcf1f4

Please sign in to comment.