diff --git a/ctrl/config.go b/ctrl/config.go index 903ecb3..6a59296 100644 --- a/ctrl/config.go +++ b/ctrl/config.go @@ -68,7 +68,7 @@ func (c *WatchVulnAppConfig) DBConnForEnt() (string, string, error) { if u.RawQuery != "" { query = u.RawQuery } - return dialect.SQLite, fmt.Sprintf("file:%s?%s", u.Host, query), nil + return dialect.SQLite, fmt.Sprintf("file:%s%s?%s", u.Host, u.Path, query), nil case dialect.MySQL: path := "" if u.Path != "" { diff --git a/ctrl/config_test.go b/ctrl/config_test.go index da30e34..e6f1fa9 100644 --- a/ctrl/config_test.go +++ b/ctrl/config_test.go @@ -17,6 +17,22 @@ func TestWatchVulnAppConfig_DBConnForEnt(t *testing.T) { assert.Equal("sqlite3", dialect) assert.Equal("file:vuln_v3.db?cache=shared&_pragma=foreign_keys(1)", conn) + c = &WatchVulnAppConfig{ + DBConn: "sqlite3:///tmp/vuln_v3.db", + } + dialect, conn, err = c.DBConnForEnt() + assert.Nil(err) + assert.Equal("sqlite3", dialect) + assert.Equal("file:/tmp/vuln_v3.db?cache=shared&_pragma=foreign_keys(1)", conn) + + c = &WatchVulnAppConfig{ + DBConn: "sqlite3://D:/vuln_v3.db", + } + dialect, conn, err = c.DBConnForEnt() + assert.Nil(err) + assert.Equal("sqlite3", dialect) + assert.Equal("file:D:/vuln_v3.db?cache=shared&_pragma=foreign_keys(1)", conn) + c = &WatchVulnAppConfig{ DBConn: "sqlite3://vuln_v3.sqlite3?cache=shared", }