Skip to content

Commit b9b7781

Browse files
vkuttypCopilot
andcommitted
security: remove all hardcoded hostnames and passwords
Replace hardcoded fallback credentials with empty strings so no real server address or password appears in source code. Files cleaned: - cosmo-benchmark/main.swift (BENCH_HOST, BENCH_PASS) - cosmo-benchmark/README.md - cosmo-swift/main.swift - cosmo/Program.cs - Tests/CosmoMSSQLTests/Support/TestDatabase.swift - Tests/CosmoMSSQLTests/SQLClientCompatTests.swift Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8ac8c9d commit b9b7781

6 files changed

Lines changed: 12 additions & 8 deletions

File tree

Tests/CosmoMSSQLTests/SQLClientCompatTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66
// Environment variables (same as the rest of the test suite):
77
// MSSQL_TEST_HOST=127.0.0.1
8-
// MSSQL_TEST_PASS=SuperStr0ngP@ssword
8+
// MSSQL_TEST_PASS=<password>
99
// swift test --filter SQLClientCompat
1010

1111
import XCTest

Tests/CosmoMSSQLTests/Support/TestDatabase.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import CosmoMSSQL
99
// MSSQL_TEST_HOST=127.0.0.1 \
1010
// MSSQL_TEST_PORT=1433 \
1111
// MSSQL_TEST_USER=sa \
12-
// MSSQL_TEST_PASS=SuperStr0ngP@ssword \
12+
// MSSQL_TEST_PASS=<password> \
1313
// MSSQL_TEST_DB=MSSQLNioTestDb \
1414
// swift test --filter MSSQLNio
1515
//
@@ -28,7 +28,7 @@ struct TestDatabase {
2828
port: Int(env["MSSQL_TEST_PORT"] ?? "1433") ?? 1433,
2929
database: env["MSSQL_TEST_DB"] ?? "MSSQLNioTestDb",
3030
username: env["MSSQL_TEST_USER"] ?? "sa",
31-
password: env["MSSQL_TEST_PASS"] ?? "SuperStr0ngP@ssword",
31+
password: env["MSSQL_TEST_PASS"] ?? "",
3232
trustServerCertificate: true
3333
)
3434
}

cosmo-benchmark/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sudo apt install freetds-dev
1919
```bash
2020
cd cosmo-benchmark
2121

22-
# defaults: hanan.iserveus.com:1433 MurshiDb sa aBCD111
22+
# defaults: localhost:1433 MurshiDb sa (set BENCH_PASS)
2323
swift run -c release
2424

2525
# custom server

cosmo-benchmark/Sources/cosmo-benchmark/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import SQLClientSwift
77
// MARK: - Configuration
88
// ─────────────────────────────────────────────
99

10-
let host = ProcessInfo.processInfo.environment["BENCH_HOST"] ?? "localhost"
10+
let host = ProcessInfo.processInfo.environment["BENCH_HOST"] ?? ""
1111
let port = UInt16(ProcessInfo.processInfo.environment["BENCH_PORT"] ?? "1433") ?? 1433
1212
let database = ProcessInfo.processInfo.environment["BENCH_DB"] ?? "MurshiDb"
1313
let user = ProcessInfo.processInfo.environment["BENCH_USER"] ?? "sa"
14-
let password = ProcessInfo.processInfo.environment["BENCH_PASS"] ?? "aBCD111"
14+
let password = ProcessInfo.processInfo.environment["BENCH_PASS"] ?? ""
1515
let query = ProcessInfo.processInfo.environment["BENCH_QUERY"] ?? "SELECT * FROM Accounts"
1616
let iterations = Int(ProcessInfo.processInfo.environment["BENCH_ITER"] ?? "20") ?? 20
1717

cosmo-swift/Sources/cosmo-swift/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import CosmoSQLCore
44
print("Hello, World!")
55

66
let conn = try await MSSQLConnection.connect(configuration: .init(
7-
connectionString: "Server=localhost,1433;Database=MurshiDb;User Id=sa;Password=aBCD111;Encrypt=true;TrustServerCertificate=true"
7+
connectionString: "Server=\(ProcessInfo.processInfo.environment["MSSQL_HOST"] ?? "localhost"),1433;Database=\(ProcessInfo.processInfo.environment["MSSQL_DB"] ?? "MurshiDb");User Id=\(ProcessInfo.processInfo.environment["MSSQL_USER"] ?? "sa");Password=\(ProcessInfo.processInfo.environment["MSSQL_PASS"] ?? "");Encrypt=true;TrustServerCertificate=true"
88
))
99
defer { Task { try? await conn.close() } }
1010

cosmo/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
using CosmoSQLClient.MsSql;
44

55
Console.WriteLine("Hello, World!");
6+
var host = Environment.GetEnvironmentVariable("MSSQL_HOST") ?? "localhost";
7+
var db = Environment.GetEnvironmentVariable("MSSQL_DB") ?? "MurshiDb";
8+
var user = Environment.GetEnvironmentVariable("MSSQL_USER") ?? "sa";
9+
var pass = Environment.GetEnvironmentVariable("MSSQL_PASS") ?? "";
610
await using var conn = await MsSqlConnection.OpenAsync(
7-
"Server=localhost,1433;Database=MurshiDb;User Id=sa;Password=aBCD111;Encrypt=True;TrustServerCertificate=True;");
11+
$"Server={host},1433;Database={db};User Id={user};Password={pass};Encrypt=True;TrustServerCertificate=True;");
812

913
var table = await conn.QueryTableAsync("SELECT TOP 3 AccountNo, AccountName, AccountTypeID, IsMain FROM Accounts");
1014

0 commit comments

Comments
 (0)