Skip to content

Commit 0ed709a

Browse files
committed
fix: using default db name in mysql and pgsql plugins (fixes #37)
1 parent 0978500 commit 0ed709a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/plugins/sql/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,16 @@ impl SQL {
5151
async fn do_attempt<DB: sqlx::Database>(
5252
&self,
5353
scheme: &str,
54+
db: &str,
5455
creds: &Credentials,
5556
timeout: Duration,
5657
) -> Result<Option<Loot>, Error> {
5758
let address = utils::parse_target_address(&creds.target, self.port)?;
5859
let pool = tokio::time::timeout(
5960
timeout,
6061
PoolOptions::<DB>::new().connect(&format!(
61-
"{}://{}:{}@{}/",
62-
scheme, &creds.username, &creds.password, &address
62+
"{}://{}:{}@{}/{}",
63+
scheme, &creds.username, &creds.password, &address, db
6364
)),
6465
)
6566
.await
@@ -92,9 +93,12 @@ impl Plugin for SQL {
9293

9394
async fn attempt(&self, creds: &Credentials, timeout: Duration) -> Result<Option<Loot>, Error> {
9495
match self.flavour {
95-
Flavour::My => self.do_attempt::<MySql>("mysql", creds, timeout).await,
96+
Flavour::My => {
97+
self.do_attempt::<MySql>("mysql", "mysql", creds, timeout)
98+
.await
99+
}
96100
Flavour::PG => {
97-
self.do_attempt::<Postgres>("postgres", creds, timeout)
101+
self.do_attempt::<Postgres>("postgres", "postgres", creds, timeout)
98102
.await
99103
}
100104
}

0 commit comments

Comments
 (0)